Detailed commit messages: deleted old tinymce new tinymce js changes to support new tinymce scss changes for alignments Include all the controls on the toolbar that we previously had. Changes to support Bulk e-mail usage. adding new studio skin for TinyMCE4 Get handling of static image links working again. Delete old Studio skin. Version 1.3 of CodeMirror plugin. Modify paths for location of CodeMirror files. Fire events when CodeMirror Editor is open and closed. Needed to switch static links back and forth. Remove CodeMirror tabbed editor. fixed tinymce visual editor css Change how we detect that an image has been inserted. made the codemirror look more studio-like reordered the tinymce buttons Update unit tests. Update acceptance test for image plugin. Make sure to strip out temporary caret. It can get left behind in style blocks. Test for style block being maintained. Allow TinyMCE to create p's, else formatting doesn't work. Add tests for toolbar buttons and converting links. Add test for code format toolbar button. Remove unnecessary code. Remove unused testing templates and unused tabs. Update tinymce paths. Fire an event with the link plugin closes so we can rewrite links. pep8 Updates from code review. Change the name of the button to "Edit HTML". Changed menu name for consistency, but we don't show it. Changed name of "code" toolbar button to "Code block". Switch from tabbed Visual/HTML Editor for HTML modules to showing the code editor as a plugin within TinyMCE (triggered from toolbar). STUD-1422 Fire events before and after the image dialog is shown. We use this to rewrite links. Change the event handling for image plugin. Fixes FireFox bug, and allows us to correct the image path when we show the plugin (as opposed ot only correcting path when we close the plugin). Code review feedback. Fire events before and after the link dialog is shown. This allows us to convert the static links. Remove unnecessary helper method. keeping the component editor inside the component window Use compressed CodeMirror file. replaced code icon in TinyMCE editor; simplified UI on TMCE toolbar Change code editor icon to say HTML. Move code style block button. Update tests for minor UI changes. Code editor button no longer shows an icon, and code style toolbar button location has moved. Fix typos.
202 lines
5.7 KiB
Python
202 lines
5.7 KiB
Python
# disable missing docstring
|
|
# pylint: disable=C0111
|
|
|
|
from lettuce import world, step
|
|
from nose.tools import assert_in, assert_equal # pylint: disable=no-name-in-module
|
|
from common import type_in_codemirror, get_codemirror_value
|
|
|
|
CODEMIRROR_SELECTOR_PREFIX = "$('iframe').contents().find"
|
|
|
|
|
|
@step('I have created a Blank HTML Page$')
|
|
def i_created_blank_html_page(step):
|
|
world.create_course_with_unit()
|
|
world.create_component_instance(
|
|
step=step,
|
|
category='html',
|
|
component_type='Text'
|
|
)
|
|
|
|
|
|
@step('I see only the HTML display name setting$')
|
|
def i_see_only_the_html_display_name(step):
|
|
world.verify_all_setting_entries([['Display Name', "Text", False]])
|
|
|
|
|
|
@step('I have created an E-text Written in LaTeX$')
|
|
def i_created_etext_in_latex(step):
|
|
world.create_course_with_unit()
|
|
step.given('I have enabled latex compiler')
|
|
world.create_component_instance(
|
|
step=step,
|
|
category='html',
|
|
component_type='E-text Written in LaTeX'
|
|
)
|
|
|
|
|
|
@step('I edit the page$')
|
|
def i_click_on_edit_icon(step):
|
|
world.edit_component()
|
|
|
|
|
|
@step('I add an image with static link "(.*)" via the Image Plugin Icon$')
|
|
def i_click_on_image_plugin_icon(step, path):
|
|
use_plugin(
|
|
'.mce-i-image',
|
|
lambda: world.css_fill('.mce-textbox', path, 0)
|
|
)
|
|
|
|
|
|
@step('the link is shown as "(.*)" in the Image Plugin$')
|
|
def check_link_in_image_plugin(step, path):
|
|
use_plugin(
|
|
'.mce-i-image',
|
|
lambda: assert_equal(path, world.css_find('.mce-textbox')[0].value)
|
|
)
|
|
|
|
|
|
@step('I add a link with static link "(.*)" via the Link Plugin Icon$')
|
|
def i_click_on_link_plugin_icon(step, path):
|
|
def fill_in_link_fields():
|
|
world.css_fill('.mce-textbox', path, 0)
|
|
world.css_fill('.mce-textbox', 'picture', 1)
|
|
|
|
use_plugin('.mce-i-link', fill_in_link_fields)
|
|
|
|
|
|
@step('the link is shown as "(.*)" in the Link Plugin$')
|
|
def check_link_in_link_plugin(step, path):
|
|
# Ensure caret position is within the link just created.
|
|
script = """
|
|
var editor = tinyMCE.activeEditor;
|
|
editor.selection.select(editor.dom.select('a')[0]);"""
|
|
world.browser.driver.execute_script(script)
|
|
world.wait_for_ajax_complete()
|
|
|
|
use_plugin(
|
|
'.mce-i-link',
|
|
lambda: assert_equal(path, world.css_find('.mce-textbox')[0].value)
|
|
)
|
|
|
|
|
|
@step('type "(.*)" in the code editor and press OK$')
|
|
def type_in_codemirror_plugin(step, text):
|
|
use_code_editor(
|
|
lambda: type_in_codemirror(0, text, CODEMIRROR_SELECTOR_PREFIX)
|
|
)
|
|
|
|
|
|
@step('and the code editor displays "(.*)"$')
|
|
def verify_code_editor_text(step, text):
|
|
use_code_editor(
|
|
lambda: assert_equal(text, get_codemirror_value(0, CODEMIRROR_SELECTOR_PREFIX))
|
|
)
|
|
|
|
|
|
def use_plugin(button_class, action):
|
|
# Click on plugin button
|
|
world.css_click(button_class)
|
|
perform_action_in_plugin(action)
|
|
|
|
|
|
def use_code_editor(action):
|
|
# Click on plugin button
|
|
buttons = world.css_find('div.mce-widget>button')
|
|
|
|
code_editor = [button for button in buttons if button.text == 'HTML']
|
|
assert_equal(1, len(code_editor))
|
|
code_editor[0].click()
|
|
|
|
perform_action_in_plugin(action)
|
|
|
|
|
|
def perform_action_in_plugin(action):
|
|
# Wait for the plugin window to open.
|
|
world.wait_for_visible('.mce-window')
|
|
|
|
# Trigger the action
|
|
action()
|
|
|
|
# Click OK
|
|
world.css_click('.mce-primary')
|
|
|
|
|
|
@step('I save the page$')
|
|
def i_click_on_save(step):
|
|
world.save_component(step)
|
|
|
|
|
|
@step('the page text contains:')
|
|
def check_page_text(step):
|
|
assert_in(step.multiline, world.css_find('.xmodule_HtmlModule').html)
|
|
|
|
|
|
@step('the src link is rewritten to "(.*)"$')
|
|
def image_static_link_is_rewritten(step, path):
|
|
# Find the TinyMCE iframe within the main window
|
|
with world.browser.get_iframe('mce_0_ifr') as tinymce:
|
|
image = tinymce.find_by_tag('img').first
|
|
assert_in(path, image['src'])
|
|
|
|
|
|
@step('the href link is rewritten to "(.*)"$')
|
|
def link_static_link_is_rewritten(step, path):
|
|
# Find the TinyMCE iframe within the main window
|
|
with world.browser.get_iframe('mce_0_ifr') as tinymce:
|
|
link = tinymce.find_by_tag('a').first
|
|
assert_in(path, link['href'])
|
|
|
|
|
|
@step('the expected toolbar buttons are displayed$')
|
|
def check_toolbar_buttons(step):
|
|
dropdowns = world.css_find('.mce-listbox')
|
|
assert_equal(2, len(dropdowns))
|
|
|
|
# Format dropdown
|
|
assert_equal('Paragraph', dropdowns[0].text)
|
|
# Font dropdown
|
|
assert_equal('Font Family', dropdowns[1].text)
|
|
|
|
buttons = world.css_find('.mce-ico')
|
|
|
|
# Note that the code editor icon is not present because we are now showing text instead of an icon.
|
|
# However, other test points user the code editor, so we have already verified its presence.
|
|
expected_buttons = [
|
|
'bold',
|
|
'italic',
|
|
'underline',
|
|
'forecolor',
|
|
# This is our custom "code style" button, which uses an image instead of a class.
|
|
'none',
|
|
'bullist',
|
|
'numlist',
|
|
'outdent',
|
|
'indent',
|
|
'blockquote',
|
|
'link',
|
|
'unlink',
|
|
'image'
|
|
]
|
|
|
|
assert_equal(len(expected_buttons), len(buttons))
|
|
|
|
for index, button in enumerate(expected_buttons):
|
|
class_names = buttons[index]._element.get_attribute('class')
|
|
assert_equal("mce-ico mce-i-" + button, class_names)
|
|
|
|
|
|
@step('I set the text to "(.*)" and I select the text$')
|
|
def set_text_and_select(step, text):
|
|
script = """
|
|
var editor = tinyMCE.activeEditor;
|
|
editor.setContent(arguments[0]);
|
|
editor.selection.select(editor.dom.select('p')[0]);"""
|
|
world.browser.driver.execute_script(script, str(text))
|
|
world.wait_for_ajax_complete()
|
|
|
|
|
|
@step('I select the code toolbar button$')
|
|
def select_code_button(step):
|
|
# This is our custom "code style" button. It uses an image instead of a class.
|
|
world.css_click(".mce-i-none")
|