def test_cancel_editing_key_value(self): """ Scenario: Test that advanced settings does not save the key value, if cancel is clicked from notification bar Given a staff logs in to studio When this user goes to advanced settings page and enters and new course name Then he clicks 'cancel' buttin when asked to save changes When this user reloads the page And then he does not see any change in the original course name """ original_course_display_name = self.advanced_settings.get(self.course_name_key) new_course_name = 'New Course Name' type_in_codemirror(self.advanced_settings, 16, new_course_name) self.advanced_settings.cancel() self.advanced_settings.refresh_and_wait_for_load() self.assertNotEqual( original_course_display_name, new_course_name, ( 'original course name:{} can not not be equal to unsaved course name {}'.format( original_course_display_name, new_course_name ) ) ) self.assertEqual( self.advanced_settings.get(self.course_name_key), original_course_display_name, ( 'course name from the page should be same as original_course_display_name:{}'.format( original_course_display_name ) ) )
def submit_update(self, message): """ Adds update text to the new update CodeMirror form and submits that text. Arguments: message (str): The message to be added and saved. """ type_in_codemirror(self, 0, message) self.click_new_update_save_button()
def set_codemirror_text(self, text, index=0): """ Set the text of a CodeMirror editor that is part of this xblock's settings. """ type_in_codemirror(self, index, text, find_prefix=u'$("{}").find'.format( self.editor_selector))
def set_values(self, key_value_map): """ Make multiple settings changes and save them. """ for key, value in key_value_map.iteritems(): index = self._get_index_of(key) type_in_codemirror(self, index, value) self.save()
def set_raw_content(self, content): """Types content in raw html mode, leaving the component open. Arguments: content (str): The content to be used. """ self.q(css=self.editor_mode_css).click() self.q(css='[aria-label="Edit HTML"]').click() self.wait_for_element_visibility('.mce-title', 'Wait for CodeMirror editor') # Set content in the CodeMirror editor. type_in_codemirror(self, 0, content) self.q(css='.mce-foot .mce-primary').click()
def _studio_add_content(self, studio_course_outline, html_content): """ Add content to first section on studio course page. """ # create a unit in course outline studio_course_outline.visit() subsection = studio_course_outline.section_at(0).subsection_at(0) subsection.expand_subsection() subsection.add_unit() # got to unit and create an HTML component and save (not publish) unit_page = ContainerPage(self.browser, None) unit_page.wait_for_page() add_html_component(unit_page, 0) unit_page.wait_for_element_presence('.edit-button', 'Edit button is visible') click_css(unit_page, '.edit-button', 0, require_notification=False) unit_page.wait_for_element_visibility('.modal-editor', 'Modal editor is visible') type_in_codemirror(unit_page, 0, html_content) click_css(unit_page, '.action-save', 0)
def _studio_add_content(self, section_index): """ Add content on studio course page under specified section """ self._auto_auth(self.STAFF_USERNAME, self.STAFF_EMAIL, True) # create a unit in course outline self.studio_course_outline.visit() subsection = self.studio_course_outline.section_at(section_index).subsection_at(0) subsection.expand_subsection() subsection.add_unit() # got to unit and create an HTML component and save (not publish) unit_page = ContainerPage(self.browser, None) unit_page.wait_for_page() add_html_component(unit_page, 0) unit_page.wait_for_element_presence('.edit-button', 'Edit button is visible') click_css(unit_page, '.edit-button', 0, require_notification=False) unit_page.wait_for_element_visibility('.modal-editor', 'Modal editor is visible') type_in_codemirror(unit_page, 0, self.HTML_CONTENT) click_css(unit_page, '.action-save', 0)
def test_raw_html_component_does_not_change_text(self): """ Scenario: Raw HTML component does not change text Given I have created a raw HTML component When I edit the page And type "<li>zzzz<ol> " into the Raw Editor And I save the page Then the page text contains: "" <li>zzzz<ol> "" And I edit the page Then the Raw Editor contains exactly: "" <li>zzzz<ol> "" """ content = "<li>zzzz</li>" # Add Raw HTML type component self._add_component('Raw HTML') self.container_page.edit() # Set content in tinymce editor type_in_codemirror(self.html_editor, 0, content) self.html_editor.save_content() # The HTML of the content added through tinymce editor html = self.container_page.content_html # The text content should be present with its tag preserved self.assertIn(content, html) self.container_page.edit() editor_value = self.html_editor.editor_value # The tinymce editor value should not be different from the content added in the start self.assertEqual(content, editor_value)
def change_course_description(self, change_text): """ Changes the course description """ type_in_codemirror(self, 0, change_text, find_prefix="$")
def set(self, key, new_value): index = self._get_index_of(key) type_in_codemirror(self, index, new_value) self.save()
def replace_wiki_content(self, content): """ Editor must be open already. This will replace any content in the editor with new content """ type_in_codemirror(self, 0, content)
def set_codemirror_text(self, text, index=0): """ Set the text of a CodeMirror editor that is part of this xblock's settings. """ type_in_codemirror(self, index, text, find_prefix='$("{}").find'.format(self.editor_selector))