Commit 70819203 by Martyn James

Merge pull request #7443 from edx/mjevtic/SOL-336

Fixed flaky test(s) - SOL-336 - merging updates
parents 68ba1786 29bceffc
...@@ -222,7 +222,7 @@ class CourseOutlineContainer(CourseOutlineItem): ...@@ -222,7 +222,7 @@ class CourseOutlineContainer(CourseOutlineItem):
require_notification=require_notification, require_notification=require_notification,
) )
def toggle_expand(self): def expand_subsection(self):
""" """
Toggle the expansion of this subsection. Toggle the expansion of this subsection.
""" """
...@@ -236,12 +236,15 @@ class CourseOutlineContainer(CourseOutlineItem): ...@@ -236,12 +236,15 @@ class CourseOutlineContainer(CourseOutlineItem):
currently_expanded = subsection_expanded() currently_expanded = subsection_expanded()
self.q(css=self._bounded_selector('.ui-toggle-expansion i')).first.click() self.q(css=self._bounded_selector('.ui-toggle-expansion i')).first.click()
self.wait_for_element_presence(self._bounded_selector(self.ADD_BUTTON_SELECTOR), 'Subsection is expanded')
EmptyPromise( EmptyPromise(
lambda: subsection_expanded() != currently_expanded, lambda: subsection_expanded() != currently_expanded,
"Check that the container {} has been toggled".format(self.locator) "Check that the container {} has been toggled".format(self.locator)
).fulfill() ).fulfill()
self.browser.execute_script("jQuery.fx.off = false;")
return self return self
@property @property
...@@ -564,10 +567,10 @@ class CourseOutlinePage(CoursePage, CourseOutlineContainer): ...@@ -564,10 +567,10 @@ class CourseOutlinePage(CoursePage, CourseOutlineContainer):
""" """
for section in self.sections(): for section in self.sections():
if section.is_collapsed: if section.is_collapsed:
section.toggle_expand() section.expand_subsection()
for subsection in section.subsections(): for subsection in section.subsections():
if subsection.is_collapsed: if subsection.is_collapsed:
subsection.toggle_expand() subsection.expand_subsection()
@property @property
def xblocks(self): def xblocks(self):
......
...@@ -44,7 +44,7 @@ class StudioPagePerformanceTest(WebAppTest): ...@@ -44,7 +44,7 @@ class StudioPagePerformanceTest(WebAppTest):
Produce a HAR for loading a unit page. Produce a HAR for loading a unit page.
""" """
course_outline_page = CourseOutlinePage(self.browser, self.course_org, self.course_num, self.course_run).visit() course_outline_page = CourseOutlinePage(self.browser, self.course_org, self.course_num, self.course_run).visit()
course_outline_unit = course_outline_page.section(section_title).subsection(subsection_title).toggle_expand().unit(unit_title) course_outline_unit = course_outline_page.section(section_title).subsection(subsection_title).expand_subsection().unit(unit_title)
har_name = 'UnitPage_{org}_{course}'.format( har_name = 'UnitPage_{org}_{course}'.format(
org=self.course_org, org=self.course_org,
course=self.course_num course=self.course_num
......
...@@ -119,7 +119,7 @@ class LibraryContentTestBase(UniqueCourseTest): ...@@ -119,7 +119,7 @@ class LibraryContentTestBase(UniqueCourseTest):
self._auto_auth(self.STAFF_USERNAME, self.STAFF_EMAIL, True) self._auto_auth(self.STAFF_USERNAME, self.STAFF_EMAIL, True)
self.course_outline.visit() self.course_outline.visit()
subsection = self.course_outline.section(SECTION_NAME).subsection(SUBSECTION_NAME) subsection = self.course_outline.section(SECTION_NAME).subsection(SUBSECTION_NAME)
return subsection.toggle_expand().unit(UNIT_NAME).go_to() return subsection.expand_subsection().unit(UNIT_NAME).go_to()
def _goto_library_block_page(self, block_id=None): def _goto_library_block_page(self, block_id=None):
""" """
......
...@@ -4,8 +4,6 @@ Test courseware search ...@@ -4,8 +4,6 @@ Test courseware search
import os import os
import json import json
from flaky import flaky
from ..helpers import UniqueCourseTest from ..helpers import UniqueCourseTest
from ...pages.common.logout import LogoutPage from ...pages.common.logout import LogoutPage
from ...pages.studio.utils import add_html_component, click_css, type_in_codemirror from ...pages.studio.utils import add_html_component, click_css, type_in_codemirror
...@@ -99,7 +97,7 @@ class CoursewareSearchTest(UniqueCourseTest): ...@@ -99,7 +97,7 @@ class CoursewareSearchTest(UniqueCourseTest):
""" """
self.course_outline.visit() self.course_outline.visit()
subsection = self.course_outline.section_at(section_index).subsection_at(0) subsection = self.course_outline.section_at(section_index).subsection_at(0)
subsection.toggle_expand() subsection.expand_subsection()
unit = subsection.unit_at(0) unit = subsection.unit_at(0)
unit.publish() unit.publish()
...@@ -119,7 +117,7 @@ class CoursewareSearchTest(UniqueCourseTest): ...@@ -119,7 +117,7 @@ class CoursewareSearchTest(UniqueCourseTest):
# create a unit in course outline # create a unit in course outline
self.course_outline.visit() self.course_outline.visit()
subsection = self.course_outline.section_at(section_index).subsection_at(0) subsection = self.course_outline.section_at(section_index).subsection_at(0)
subsection.toggle_expand() subsection.expand_subsection()
subsection.add_unit() subsection.add_unit()
# got to unit and create an HTML component and save (not publish) # got to unit and create an HTML component and save (not publish)
...@@ -167,7 +165,6 @@ class CoursewareSearchTest(UniqueCourseTest): ...@@ -167,7 +165,6 @@ class CoursewareSearchTest(UniqueCourseTest):
self.courseware_search_page.search_for_term(self.SEARCH_STRING) self.courseware_search_page.search_for_term(self.SEARCH_STRING)
assert self.SEARCH_STRING in self.courseware_search_page.search_results.html[0] assert self.SEARCH_STRING in self.courseware_search_page.search_results.html[0]
@flaky # TODO fix this, see SOL-336
def test_reindex(self): def test_reindex(self):
""" """
Make sure new content gets reindexed on button press. Make sure new content gets reindexed on button press.
......
...@@ -93,7 +93,7 @@ class ContainerBase(StudioCourseTest): ...@@ -93,7 +93,7 @@ class ContainerBase(StudioCourseTest):
""" """
self.outline.visit() self.outline.visit()
subsection = self.outline.section(section_name).subsection(subsection_name) subsection = self.outline.section(section_name).subsection(subsection_name)
return subsection.toggle_expand().unit(unit_name).go_to() return subsection.expand_subsection().unit(unit_name).go_to()
def do_action_and_verify(self, action, expected_ordering): def do_action_and_verify(self, action, expected_ordering):
""" """
......
...@@ -69,7 +69,7 @@ class XBlockAcidBase(WebAppTest): ...@@ -69,7 +69,7 @@ class XBlockAcidBase(WebAppTest):
self.outline.visit() self.outline.visit()
subsection = self.outline.section('Test Section').subsection('Test Subsection') subsection = self.outline.section('Test Section').subsection('Test Subsection')
unit = subsection.toggle_expand().unit('Test Unit').go_to() unit = subsection.expand_subsection().unit('Test Unit').go_to()
acid_block = AcidView(self.browser, unit.xblocks[0].preview_selector) acid_block = AcidView(self.browser, unit.xblocks[0].preview_selector)
self.validate_acid_block_preview(acid_block) self.validate_acid_block_preview(acid_block)
...@@ -81,7 +81,7 @@ class XBlockAcidBase(WebAppTest): ...@@ -81,7 +81,7 @@ class XBlockAcidBase(WebAppTest):
self.outline.visit() self.outline.visit()
subsection = self.outline.section('Test Section').subsection('Test Subsection') subsection = self.outline.section('Test Section').subsection('Test Subsection')
unit = subsection.toggle_expand().unit('Test Unit').go_to() unit = subsection.expand_subsection().unit('Test Unit').go_to()
acid_block = AcidView(self.browser, unit.xblocks[0].edit().editor_selector) acid_block = AcidView(self.browser, unit.xblocks[0].edit().editor_selector)
self.assertTrue(acid_block.init_fn_passed) self.assertTrue(acid_block.init_fn_passed)
...@@ -133,7 +133,7 @@ class XBlockAcidParentBase(XBlockAcidBase): ...@@ -133,7 +133,7 @@ class XBlockAcidParentBase(XBlockAcidBase):
self.outline.visit() self.outline.visit()
subsection = self.outline.section('Test Section').subsection('Test Subsection') subsection = self.outline.section('Test Section').subsection('Test Subsection')
unit = subsection.toggle_expand().unit('Test Unit').go_to() unit = subsection.expand_subsection().unit('Test Unit').go_to()
container = unit.xblocks[0].go_to_container() container = unit.xblocks[0].go_to_container()
acid_block = AcidView(self.browser, container.xblocks[0].preview_selector) acid_block = AcidView(self.browser, container.xblocks[0].preview_selector)
......
...@@ -131,7 +131,7 @@ class DiscussionPreviewTest(StudioCourseTest): ...@@ -131,7 +131,7 @@ class DiscussionPreviewTest(StudioCourseTest):
self.course_info['run'] self.course_info['run']
) )
cop.visit() cop.visit()
self.unit = cop.section('Test Section').subsection('Test Subsection').toggle_expand().unit('Test Unit') self.unit = cop.section('Test Section').subsection('Test Subsection').expand_subsection().unit('Test Unit')
self.unit.go_to() self.unit.go_to()
def populate_course_fixture(self, course_fixture): def populate_course_fixture(self, course_fixture):
......
...@@ -40,7 +40,7 @@ class StudioLibraryContainerTest(StudioLibraryTest, UniqueCourseTest): ...@@ -40,7 +40,7 @@ class StudioLibraryContainerTest(StudioLibraryTest, UniqueCourseTest):
self.outline.visit() self.outline.visit()
subsection = self.outline.section(SECTION_NAME).subsection(SUBSECTION_NAME) subsection = self.outline.section(SECTION_NAME).subsection(SUBSECTION_NAME)
self.unit_page = subsection.toggle_expand().unit(UNIT_NAME).go_to() self.unit_page = subsection.expand_subsection().unit(UNIT_NAME).go_to()
def populate_library_fixture(self, library_fixture): def populate_library_fixture(self, library_fixture):
""" """
......
...@@ -292,7 +292,7 @@ class WarningMessagesTest(CourseOutlineTest): ...@@ -292,7 +292,7 @@ class WarningMessagesTest(CourseOutlineTest):
self.course_outline_page.visit() self.course_outline_page.visit()
section = self.course_outline_page.section(unit_state.name) section = self.course_outline_page.section(unit_state.name)
subsection = section.subsection_at(0) subsection = section.subsection_at(0)
subsection.toggle_expand() subsection.expand_subsection()
unit = subsection.unit_at(0) unit = subsection.unit_at(0)
if expected_status_message == self.STAFF_ONLY_WARNING: if expected_status_message == self.STAFF_ONLY_WARNING:
self.assertEqual(section.status_message, self.STAFF_ONLY_WARNING) self.assertEqual(section.status_message, self.STAFF_ONLY_WARNING)
...@@ -314,7 +314,7 @@ class WarningMessagesTest(CourseOutlineTest): ...@@ -314,7 +314,7 @@ class WarningMessagesTest(CourseOutlineTest):
name = unit_state.name name = unit_state.name
self.course_outline_page.visit() self.course_outline_page.visit()
subsection = self.course_outline_page.section(name).subsection(name) subsection = self.course_outline_page.section(name).subsection(name)
subsection.toggle_expand() subsection.expand_subsection()
if unit_state.publish_state == self.PublishState.UNPUBLISHED_CHANGES: if unit_state.publish_state == self.PublishState.UNPUBLISHED_CHANGES:
unit = subsection.unit(name).go_to() unit = subsection.unit(name).go_to()
...@@ -962,7 +962,7 @@ class EditNamesTest(CourseOutlineTest): ...@@ -962,7 +962,7 @@ class EditNamesTest(CourseOutlineTest):
Then the section is collapsed Then the section is collapsed
""" """
self.course_outline_page.visit() self.course_outline_page.visit()
self.course_outline_page.section_at(0).toggle_expand() self.course_outline_page.section_at(0).expand_subsection()
self.assertFalse(self.course_outline_page.section_at(0).in_editable_form()) self.assertFalse(self.course_outline_page.section_at(0).in_editable_form())
self.assertTrue(self.course_outline_page.section_at(0).is_collapsed) self.assertTrue(self.course_outline_page.section_at(0).is_collapsed)
self.course_outline_page.section_at(0).edit_name() self.course_outline_page.section_at(0).edit_name()
...@@ -1138,7 +1138,7 @@ class DeleteContentTest(CourseOutlineTest): ...@@ -1138,7 +1138,7 @@ class DeleteContentTest(CourseOutlineTest):
And the unit should immediately be deleted from the course outline And the unit should immediately be deleted from the course outline
""" """
self.course_outline_page.visit() self.course_outline_page.visit()
self.course_outline_page.section_at(0).subsection_at(0).toggle_expand() self.course_outline_page.section_at(0).subsection_at(0).expand_subsection()
self.assertEqual(len(self.course_outline_page.section_at(0).subsection_at(0).units()), 1) self.assertEqual(len(self.course_outline_page.section_at(0).subsection_at(0).units()), 1)
self.course_outline_page.section_at(0).subsection_at(0).unit_at(0).delete() self.course_outline_page.section_at(0).subsection_at(0).unit_at(0).delete()
self.assertEqual(len(self.course_outline_page.section_at(0).subsection_at(0).units()), 0) self.assertEqual(len(self.course_outline_page.section_at(0).subsection_at(0).units()), 0)
...@@ -1153,7 +1153,7 @@ class DeleteContentTest(CourseOutlineTest): ...@@ -1153,7 +1153,7 @@ class DeleteContentTest(CourseOutlineTest):
And the unit should remain in the course outline And the unit should remain in the course outline
""" """
self.course_outline_page.visit() self.course_outline_page.visit()
self.course_outline_page.section_at(0).subsection_at(0).toggle_expand() self.course_outline_page.section_at(0).subsection_at(0).expand_subsection()
self.assertEqual(len(self.course_outline_page.section_at(0).subsection_at(0).units()), 1) self.assertEqual(len(self.course_outline_page.section_at(0).subsection_at(0).units()), 1)
self.course_outline_page.section_at(0).subsection_at(0).unit_at(0).delete(cancel=True) self.course_outline_page.section_at(0).subsection_at(0).unit_at(0).delete(cancel=True)
self.assertEqual(len(self.course_outline_page.section_at(0).subsection_at(0).units()), 1) self.assertEqual(len(self.course_outline_page.section_at(0).subsection_at(0).units()), 1)
...@@ -1208,7 +1208,7 @@ class ExpandCollapseMultipleSectionsTest(CourseOutlineTest): ...@@ -1208,7 +1208,7 @@ class ExpandCollapseMultipleSectionsTest(CourseOutlineTest):
Toggles the expand collapse state of all sections. Toggles the expand collapse state of all sections.
""" """
for section in self.course_outline_page.sections(): for section in self.course_outline_page.sections():
section.toggle_expand() section.expand_subsection()
def test_expanded_by_default(self): def test_expanded_by_default(self):
""" """
...@@ -1265,7 +1265,7 @@ class ExpandCollapseMultipleSectionsTest(CourseOutlineTest): ...@@ -1265,7 +1265,7 @@ class ExpandCollapseMultipleSectionsTest(CourseOutlineTest):
""" """
self.course_outline_page.visit() self.course_outline_page.visit()
self.verify_all_sections(collapsed=False) self.verify_all_sections(collapsed=False)
self.course_outline_page.section_at(0).toggle_expand() self.course_outline_page.section_at(0).expand_subsection()
self.course_outline_page.toggle_expand_collapse() self.course_outline_page.toggle_expand_collapse()
self.assertEquals(self.course_outline_page.expand_collapse_link_state, ExpandCollapseLinkState.EXPAND) self.assertEquals(self.course_outline_page.expand_collapse_link_state, ExpandCollapseLinkState.EXPAND)
self.verify_all_sections(collapsed=True) self.verify_all_sections(collapsed=True)
...@@ -1299,7 +1299,7 @@ class ExpandCollapseMultipleSectionsTest(CourseOutlineTest): ...@@ -1299,7 +1299,7 @@ class ExpandCollapseMultipleSectionsTest(CourseOutlineTest):
self.course_outline_page.visit() self.course_outline_page.visit()
self.course_outline_page.toggle_expand_collapse() self.course_outline_page.toggle_expand_collapse()
self.assertEquals(self.course_outline_page.expand_collapse_link_state, ExpandCollapseLinkState.EXPAND) self.assertEquals(self.course_outline_page.expand_collapse_link_state, ExpandCollapseLinkState.EXPAND)
self.course_outline_page.section_at(0).toggle_expand() self.course_outline_page.section_at(0).expand_subsection()
self.course_outline_page.toggle_expand_collapse() self.course_outline_page.toggle_expand_collapse()
self.assertEquals(self.course_outline_page.expand_collapse_link_state, ExpandCollapseLinkState.COLLAPSE) self.assertEquals(self.course_outline_page.expand_collapse_link_state, ExpandCollapseLinkState.COLLAPSE)
self.verify_all_sections(collapsed=False) self.verify_all_sections(collapsed=False)
...@@ -1449,7 +1449,7 @@ class UnitNavigationTest(CourseOutlineTest): ...@@ -1449,7 +1449,7 @@ class UnitNavigationTest(CourseOutlineTest):
Then I will be taken to the appropriate unit page Then I will be taken to the appropriate unit page
""" """
self.course_outline_page.visit() self.course_outline_page.visit()
self.course_outline_page.section_at(0).subsection_at(0).toggle_expand() self.course_outline_page.section_at(0).subsection_at(0).expand_subsection()
unit = self.course_outline_page.section_at(0).subsection_at(0).unit_at(0).go_to() unit = self.course_outline_page.section_at(0).subsection_at(0).unit_at(0).go_to()
self.assertTrue(unit.is_browser_on_page) self.assertTrue(unit.is_browser_on_page)
...@@ -1575,6 +1575,6 @@ class PublishSectionTest(CourseOutlineTest): ...@@ -1575,6 +1575,6 @@ class PublishSectionTest(CourseOutlineTest):
""" """
section = self.course_outline_page.section(SECTION_NAME) section = self.course_outline_page.section(SECTION_NAME)
subsection = section.subsection(SUBSECTION_NAME) subsection = section.subsection(SUBSECTION_NAME)
unit = subsection.toggle_expand().unit(UNIT_NAME) unit = subsection.expand_subsection().unit(UNIT_NAME)
return (section, subsection, unit) return (section, subsection, unit)
...@@ -94,7 +94,7 @@ class CourseRerunTest(StudioCourseTest): ...@@ -94,7 +94,7 @@ class CourseRerunTest(StudioCourseTest):
EmptyPromise(lambda: not outline_page.has_rerun_notification, "Rerun notification dismissed").fulfill() EmptyPromise(lambda: not outline_page.has_rerun_notification, "Rerun notification dismissed").fulfill()
subsection = outline_page.section(self.SECTION_NAME).subsection(self.SUBSECITON_NAME) subsection = outline_page.section(self.SECTION_NAME).subsection(self.SUBSECITON_NAME)
subsection.toggle_expand() subsection.expand_subsection()
unit_page = subsection.unit(self.UNIT_NAME).go_to() unit_page = subsection.unit(self.UNIT_NAME).go_to()
unit_page.view_published_version() unit_page.view_published_version()
......
...@@ -53,7 +53,7 @@ class ORAComponentTest(StudioCourseTest): ...@@ -53,7 +53,7 @@ class ORAComponentTest(StudioCourseTest):
def _go_to_unit_page(self, section_name='Test Section', subsection_name='Test Subsection', unit_name='Test Unit'): def _go_to_unit_page(self, section_name='Test Section', subsection_name='Test Subsection', unit_name='Test Unit'):
self.course_outline_page.visit() self.course_outline_page.visit()
subsection = self.course_outline_page.section(section_name).subsection(subsection_name) subsection = self.course_outline_page.section(section_name).subsection(subsection_name)
return subsection.toggle_expand().unit(unit_name).go_to() return subsection.expand_subsection().unit(unit_name).go_to()
def test_edit_save_and_export(self): def test_edit_save_and_export(self):
""" """
......
...@@ -83,7 +83,7 @@ class CMSVideoBaseTest(UniqueCourseTest): ...@@ -83,7 +83,7 @@ class CMSVideoBaseTest(UniqueCourseTest):
self.outline.visit() self.outline.visit()
# Visit Unit page # Visit Unit page
self.unit_page = self.outline.section('Test Section').subsection('Test Subsection').toggle_expand().unit( self.unit_page = self.outline.section('Test Section').subsection('Test Subsection').expand_subsection().unit(
'Test Unit').go_to() 'Test Unit').go_to()
self.video.wait_for_video_component_render() self.video.wait_for_video_component_render()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment