Upgrade CodeMirror to 3.21.0 (with accessibility changes from
http://bgrins.github.io/codemirror-accessible/) LMS-1802
This commit is contained in:
@@ -3,10 +3,9 @@
|
||||
|
||||
from lettuce import world, step
|
||||
from nose.tools import assert_false, assert_equal, assert_regexp_matches # pylint: disable=E0611
|
||||
from common import type_in_codemirror, press_the_notification_button
|
||||
from common import type_in_codemirror, press_the_notification_button, get_codemirror_value
|
||||
|
||||
KEY_CSS = '.key input.policy-key'
|
||||
VALUE_CSS = 'textarea.json'
|
||||
DISPLAY_NAME_KEY = "display_name"
|
||||
DISPLAY_NAME_VALUE = '"Robot Super Course"'
|
||||
|
||||
@@ -101,7 +100,7 @@ def assert_policy_entries(expected_keys, expected_values):
|
||||
for key, value in zip(expected_keys, expected_values):
|
||||
index = get_index_of(key)
|
||||
assert_false(index == -1, "Could not find key: {key}".format(key=key))
|
||||
found_value = world.css_find(VALUE_CSS)[index].value
|
||||
found_value = get_codemirror_value(index)
|
||||
assert_equal(
|
||||
value, found_value,
|
||||
"Expected {} to have value {} but found {}".format(key, value, found_value)
|
||||
@@ -120,15 +119,13 @@ def get_index_of(expected_key):
|
||||
|
||||
def get_display_name_value():
|
||||
index = get_index_of(DISPLAY_NAME_KEY)
|
||||
return world.css_value(VALUE_CSS, index=index)
|
||||
|
||||
return get_codemirror_value(index)
|
||||
|
||||
def change_display_name_value(step, new_value):
|
||||
change_value(step, DISPLAY_NAME_KEY, new_value)
|
||||
|
||||
|
||||
def change_value(step, key, new_value):
|
||||
type_in_codemirror(get_index_of(key), new_value)
|
||||
world.wait(0.5)
|
||||
index = get_index_of(key)
|
||||
type_in_codemirror(index, new_value)
|
||||
press_the_notification_button(step, "Save")
|
||||
world.wait_for_ajax_complete()
|
||||
|
||||
@@ -319,20 +319,18 @@ def i_am_shown_a_notification(step):
|
||||
|
||||
|
||||
def type_in_codemirror(index, text):
|
||||
world.wait(1) # For now, slow this down so that it works. TODO: fix it.
|
||||
world.css_click("div.CodeMirror-lines", index=index)
|
||||
world.browser.execute_script("$('div.CodeMirror.CodeMirror-focused > div').css('overflow', '')")
|
||||
g = world.css_find("div.CodeMirror.CodeMirror-focused > div > textarea")
|
||||
if world.is_mac():
|
||||
g._element.send_keys(Keys.COMMAND + 'a')
|
||||
else:
|
||||
g._element.send_keys(Keys.CONTROL + 'a')
|
||||
g._element.send_keys(Keys.DELETE)
|
||||
g._element.send_keys(text)
|
||||
if world.is_firefox():
|
||||
world.trigger_event('div.CodeMirror', index=index, event='blur')
|
||||
script = """
|
||||
var cm = $('div.CodeMirror:eq({})').get(0).CodeMirror;
|
||||
cm.getInputField().focus();
|
||||
cm.setValue(arguments[0]);
|
||||
cm.getInputField().blur();""".format(index)
|
||||
world.browser.driver.execute_script(script, str(text))
|
||||
world.wait_for_ajax_complete()
|
||||
|
||||
def get_codemirror_value(index=0):
|
||||
return world.browser.driver.execute_script("""
|
||||
return $('div.CodeMirror:eq({})').get(0).CodeMirror.getValue();
|
||||
""".format(index))
|
||||
|
||||
def upload_file(filename):
|
||||
path = os.path.join(TEST_ROOT, filename)
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
from lettuce import world, step
|
||||
from selenium.webdriver.common.keys import Keys
|
||||
from common import type_in_codemirror
|
||||
from common import type_in_codemirror, get_codemirror_value
|
||||
from nose.tools import assert_in # pylint: disable=E0611
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@ def change_date(_step, new_date):
|
||||
@step(u'I should see the date "([^"]*)"$')
|
||||
def check_date(_step, date):
|
||||
date_css = 'span.date-display'
|
||||
assert date == world.css_html(date_css)
|
||||
assert_in(date, world.css_html(date_css))
|
||||
|
||||
|
||||
@step(u'I modify the handout to "([^"]*)"$')
|
||||
@@ -87,7 +87,7 @@ def edit_handouts(_step, text):
|
||||
@step(u'I see the handout "([^"]*)"$')
|
||||
def check_handout(_step, handout):
|
||||
handout_css = 'div.handouts-content'
|
||||
assert handout in world.css_html(handout_css)
|
||||
assert_in(handout, world.css_html(handout_css))
|
||||
|
||||
|
||||
@step(u'I see the handout error text')
|
||||
@@ -127,6 +127,6 @@ def change_text(text):
|
||||
|
||||
def verify_text_in_editor_and_update(button_css, before, after):
|
||||
world.css_click(button_css)
|
||||
text = world.css_find(".cm-string").html
|
||||
assert before in text
|
||||
text = get_codemirror_value()
|
||||
assert_in(before, text)
|
||||
change_text(after)
|
||||
|
||||
@@ -173,7 +173,7 @@ def cancel_does_not_save_changes(step):
|
||||
def enable_latex_compiler(step):
|
||||
url = world.browser.url
|
||||
step.given("I select the Advanced Settings")
|
||||
change_value(step, 'use_latex_compiler', True)
|
||||
change_value(step, 'use_latex_compiler', 'true')
|
||||
world.visit(url)
|
||||
world.wait_for_xmodule()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user