Commit 3f1604ac by Jesse Zoldak

Merge pull request #6736 from edx/zoldak/content-library

Fix flaky content library test
parents 46f64305 07e0eee2
""" """
Library edit page in Studio Library edit page in Studio
""" """
from bok_choy.javascript import js_defined, wait_for_js
from bok_choy.page_object import PageObject from bok_choy.page_object import PageObject
from bok_choy.promise import EmptyPromise from bok_choy.promise import EmptyPromise
from selenium.webdriver.common.keys import Keys from selenium.webdriver.common.keys import Keys
...@@ -252,12 +252,19 @@ class StudioLibraryContentXBlockEditModal(CourseOutlineModal, PageObject): ...@@ -252,12 +252,19 @@ class StudioLibraryContentXBlockEditModal(CourseOutlineModal, PageObject):
return element return element
@js_defined('window.LibraryContentAuthorView')
class StudioLibraryContainerXBlockWrapper(XBlockWrapper): class StudioLibraryContainerXBlockWrapper(XBlockWrapper):
""" """
Wraps :class:`.container.XBlockWrapper` for use with LibraryContent blocks Wraps :class:`.container.XBlockWrapper` for use with LibraryContent blocks
""" """
url = None url = None
def is_browser_on_page(self):
"""
Returns true iff the library content area has been loaded
"""
return self.q(css='article.content-primary').visible
@classmethod @classmethod
def from_xblock_wrapper(cls, xblock_wrapper): def from_xblock_wrapper(cls, xblock_wrapper):
""" """
...@@ -271,11 +278,18 @@ class StudioLibraryContainerXBlockWrapper(XBlockWrapper): ...@@ -271,11 +278,18 @@ class StudioLibraryContainerXBlockWrapper(XBlockWrapper):
""" """
return self.q(css=self._bounded_selector(".xblock-message-area p")) return self.q(css=self._bounded_selector(".xblock-message-area p"))
@wait_for_js # Wait for the fragment.initialize_js('LibraryContentAuthorView') call to finish
def refresh_children(self): def refresh_children(self):
""" """
Click "Update now..." button Click "Update now..." button
""" """
btn_selector = self._bounded_selector(".library-update-btn") btn_selector = self._bounded_selector(".library-update-btn")
refresh_button = self.q(css=btn_selector) self.wait_for_element_presence(btn_selector, 'Update now button is present.')
refresh_button.click() self.q(css=btn_selector).first.click()
self.wait_for_element_absence(btn_selector, 'Wait for the XBlock to reload')
# This causes a reload (see cms/static/xmodule_js/public/js/library_content_edit.js)
self.wait_for(lambda: self.is_browser_on_page(), 'StudioLibraryContainerXBlockWrapper has reloaded.')
# And wait to make sure the ajax post has finished.
self.wait_for_ajax()
self.wait_for_element_absence(btn_selector, 'Wait for the XBlock to finish reloading')
...@@ -3,7 +3,6 @@ Acceptance tests for Library Content in LMS ...@@ -3,7 +3,6 @@ Acceptance tests for Library Content in LMS
""" """
import textwrap import textwrap
import ddt import ddt
from unittest import skip
from .base_studio_test import StudioLibraryTest from .base_studio_test import StudioLibraryTest
from ...fixtures.course import CourseFixture from ...fixtures.course import CourseFixture
...@@ -254,7 +253,6 @@ class StudioLibraryContainerTest(StudioLibraryTest, UniqueCourseTest): ...@@ -254,7 +253,6 @@ class StudioLibraryContainerTest(StudioLibraryTest, UniqueCourseTest):
library_container.validation_warning_text library_container.validation_warning_text
) )
@skip("Flaky: 01/16/2015")
def test_settings_overrides(self): def test_settings_overrides(self):
""" """
Scenario: Given I have a library, a course and library content xblock in a course Scenario: Given I have a library, a course and library content xblock in a course
...@@ -294,6 +292,7 @@ class StudioLibraryContainerTest(StudioLibraryTest, UniqueCourseTest): ...@@ -294,6 +292,7 @@ class StudioLibraryContainerTest(StudioLibraryTest, UniqueCourseTest):
container_page.visit() # Reload container_page.visit() # Reload
self.assertTrue(library_block.has_validation_warning) self.assertTrue(library_block.has_validation_warning)
library_block.refresh_children() library_block.refresh_children()
container_page.wait_for_page() # Wait for the page to reload container_page.wait_for_page() # Wait for the page to reload
......
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