Add test fixes and fix expand collapse behavior
Stop propagation of clicks in XBlockStringFieldEditor Fix collapsed subsections expanding when creating or deleting subsections Prevent clicking in display name textbox from toggling expand collapse Add test for published title when not live
This commit is contained in:
@@ -6,7 +6,7 @@ from bok_choy.promise import EmptyPromise
|
||||
|
||||
from .course_page import CoursePage
|
||||
from .container import ContainerPage
|
||||
from .utils import set_input_value_and_save, click_css, confirm_prompt
|
||||
from .utils import set_input_value_and_save, click_css, confirm_prompt, set_input_value
|
||||
|
||||
|
||||
class CourseOutlineItem(object):
|
||||
@@ -46,11 +46,23 @@ class CourseOutlineItem(object):
|
||||
else:
|
||||
return None
|
||||
|
||||
def edit_name(self):
|
||||
"""
|
||||
Puts the item's name into editable form.
|
||||
"""
|
||||
self.q(css=self._bounded_selector(self.EDIT_BUTTON_SELECTOR)).first.click()
|
||||
|
||||
def enter_name(self, new_name):
|
||||
"""
|
||||
Enters new_name as the item's display name.
|
||||
"""
|
||||
set_input_value(self, self._bounded_selector(self.NAME_INPUT_SELECTOR), new_name)
|
||||
|
||||
def change_name(self, new_name):
|
||||
"""
|
||||
Changes the container's name.
|
||||
"""
|
||||
self.q(css=self._bounded_selector(self.EDIT_BUTTON_SELECTOR)).first.click()
|
||||
self.edit_name()
|
||||
set_input_value_and_save(self, self._bounded_selector(self.NAME_INPUT_SELECTOR), new_name)
|
||||
self.wait_for_ajax()
|
||||
|
||||
@@ -130,7 +142,7 @@ class CourseOutlineContainer(CourseOutlineItem):
|
||||
|
||||
currently_expanded = subsection_expanded()
|
||||
|
||||
self.q(css=self._bounded_selector('.ui-toggle-expansion')).first.click()
|
||||
self.q(css=self._bounded_selector('.ui-toggle-expansion i')).first.click()
|
||||
|
||||
EmptyPromise(
|
||||
lambda: subsection_expanded() != currently_expanded,
|
||||
@@ -144,7 +156,7 @@ class CourseOutlineContainer(CourseOutlineItem):
|
||||
"""
|
||||
Return whether this outline item is currently collapsed.
|
||||
"""
|
||||
return "collapsed" in self.q(css=self._bounded_selector('')).first.attrs("class")[0]
|
||||
return "is-collapsed" in self.q(css=self._bounded_selector('')).first.attrs("class")[0]
|
||||
|
||||
|
||||
class CourseOutlineChild(PageObject, CourseOutlineItem):
|
||||
|
||||
@@ -139,14 +139,3 @@ def set_input_value_and_save(page, css, value):
|
||||
action = action.send_keys(Keys.BACKSPACE)
|
||||
# Send the new text, then hit the enter key so that the change event is triggered).
|
||||
action.send_keys(value).send_keys(Keys.ENTER).perform()
|
||||
|
||||
|
||||
def confirm_prompt(page, cancel=False):
|
||||
"""
|
||||
Ensures that a modal prompt and confirmation button are visible, then clicks the button. The prompt is canceled iff
|
||||
cancel is True.
|
||||
"""
|
||||
page.wait_for_element_visibility('.prompt', 'Prompt is visible')
|
||||
confirmation_button_css = '.prompt .action-' + ('secondary' if cancel else 'primary')
|
||||
page.wait_for_element_visibility(confirmation_button_css, 'Confirmation button is visible')
|
||||
click_css(page, confirmation_button_css, require_notification=(not cancel))
|
||||
|
||||
@@ -131,6 +131,25 @@ class EditNamesTest(CourseOutlineTest):
|
||||
'Test Subsection'
|
||||
)
|
||||
|
||||
def test_editing_names_does_not_expand_collapse(self):
|
||||
"""
|
||||
Scenario: A section stays in the same expand/collapse state while its name is edited
|
||||
Given that I have created a section
|
||||
And the section is expanded
|
||||
When I click on the name of the section
|
||||
Then the section is expanded
|
||||
And given that I have entered a new name
|
||||
Then the section is expanded
|
||||
"""
|
||||
self.course_outline_page.visit()
|
||||
self.assertFalse(self.course_outline_page.section_at(0).in_editable_form())
|
||||
self.assertFalse(self.course_outline_page.section_at(0).is_collapsed)
|
||||
self.course_outline_page.section_at(0).edit_name()
|
||||
self.assertTrue(self.course_outline_page.section_at(0).in_editable_form())
|
||||
self.assertFalse(self.course_outline_page.section_at(0).is_collapsed)
|
||||
self.course_outline_page.section_at(0).enter_name('Changed')
|
||||
self.assertFalse(self.course_outline_page.section_at(0).is_collapsed)
|
||||
|
||||
|
||||
class CreateSectionsTest(CourseOutlineTest):
|
||||
"""
|
||||
@@ -469,6 +488,22 @@ class ExpandCollapseSingleSectionTest(CourseOutlineTest):
|
||||
self.assertEquals(self.course_outline_page.expand_collapse_link_state, ExpandCollapseLinkState.MISSING)
|
||||
self.assertTrue(self.course_outline_page.has_no_content_message)
|
||||
|
||||
def test_old_subsection_stays_collapsed_after_creation(self):
|
||||
"""
|
||||
Scenario: Collapsed subsection stays collapsed after creating a new subsection
|
||||
Given I have a course with one section and subsection
|
||||
And I navigate to the course outline page
|
||||
Then the subsection is collapsed
|
||||
And when I create a new subsection
|
||||
Then the first subsection is collapsed
|
||||
And the second subsection is expanded
|
||||
"""
|
||||
self.course_outline_page.visit()
|
||||
self.assertTrue(self.course_outline_page.section_at(0).subsection_at(0).is_collapsed)
|
||||
self.course_outline_page.section_at(0).add_subsection()
|
||||
self.assertTrue(self.course_outline_page.section_at(0).subsection_at(0).is_collapsed)
|
||||
self.assertFalse(self.course_outline_page.section_at(0).subsection_at(1).is_collapsed)
|
||||
|
||||
|
||||
class ExpandCollapseEmptyTest(CourseOutlineTest):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user