Commit 86cfda32 by Jay Zoldak

Add synchronization for rendering to studio xblock tests

parent 42a1f6e3
......@@ -3,7 +3,7 @@ Container page in Studio
"""
from bok_choy.page_object import PageObject
from bok_choy.promise import Promise
from . import BASE_URL
......@@ -22,11 +22,18 @@ class ContainerPage(PageObject):
return "{}/container/{}".format(BASE_URL, self.unit_locator)
def is_browser_on_page(self):
# Wait until all components have been loaded
def _is_finished_loading():
# Wait until all components have been loaded
is_done = len(self.q(css=XBlockWrapper.BODY_SELECTOR).results) == len(
self.q(css='{} .xblock'.format(XBlockWrapper.BODY_SELECTOR)).results)
return (is_done, is_done)
# First make sure that an element with the view-container class is present on the page,
# and then wait to make sure that the xblocks are all there.
return (
self.q(css='body.view-container').present and
len(self.q(css=XBlockWrapper.BODY_SELECTOR).results) == len(
self.q(css='{} .xblock'.format(XBlockWrapper.BODY_SELECTOR)).results)
Promise(_is_finished_loading, 'Finished rendering the xblock wrappers.').fulfill()
)
@property
......
......@@ -3,7 +3,7 @@ Unit page in Studio
"""
from bok_choy.page_object import PageObject
from bok_choy.promise import EmptyPromise
from bok_choy.promise import EmptyPromise, Promise
from . import BASE_URL
from .container import ContainerPage
......@@ -24,12 +24,19 @@ class UnitPage(PageObject):
return "{}/unit/{}".format(BASE_URL, self.unit_locator)
def is_browser_on_page(self):
# Wait until all components have been loaded
number_of_leaf_xblocks = len(self.q(css='{} .xblock-student_view'.format(Component.BODY_SELECTOR)).results)
number_of_container_xblocks = len(self.q(css='{} .wrapper-xblock'.format(Component.BODY_SELECTOR)).results)
def _is_finished_loading():
# Wait until all components have been loaded
number_of_leaf_xblocks = len(self.q(css='{} .xblock-student_view'.format(Component.BODY_SELECTOR)).results)
number_of_container_xblocks = len(self.q(css='{} .wrapper-xblock'.format(Component.BODY_SELECTOR)).results)
is_done = len(self.q(css=Component.BODY_SELECTOR).results) == number_of_leaf_xblocks + number_of_container_xblocks
return (is_done, is_done)
# First make sure that an element with the view-unit class is present on the page,
# and then wait to make sure that the xblocks are all there
return (
self.q(css='body.view-unit').present and
len(self.q(css=Component.BODY_SELECTOR).results) == number_of_leaf_xblocks + number_of_container_xblocks
Promise(_is_finished_loading, 'Finished rendering the xblocks in the unit.').fulfill()
)
@property
......
......@@ -3,7 +3,7 @@ PageObjects related to the AcidBlock
"""
from bok_choy.page_object import PageObject
from bok_choy.promise import EmptyPromise, BrokenPromise
from bok_choy.promise import EmptyPromise, BrokenPromise, Promise
class AcidView(PageObject):
"""
......@@ -24,9 +24,17 @@ class AcidView(PageObject):
self.context_selector = context_selector
def is_browser_on_page(self):
def _is_finished_loading():
# Wait for the xblock javascript to finish initializing
is_done = self.browser.execute_script("return $({!r}).data('initialized')".format(self.context_selector))
return (is_done, is_done)
# First make sure that an element with the view-container class is present on the page,
# and then wait to make sure that the xblock has finished initializing.
return (
self.q(css='{} .acid-block'.format(self.context_selector)).present and
self.browser.execute_script("return $({!r}).data('initialized')".format(self.context_selector))
Promise(_is_finished_loading, 'Finished initializing the xblock.').fulfill()
)
def test_passed(self, test_selector):
......
......@@ -25,7 +25,7 @@ from ..pages.studio.textbooks import TextbooksPage
from ..pages.xblock.acid import AcidView
from ..fixtures.course import CourseFixture, XBlockFixtureDesc
from .helpers import UniqueCourseTest, load_data_str
from .helpers import UniqueCourseTest
class LoggedOutTest(WebAppTest):
......@@ -170,7 +170,6 @@ class XBlockAcidBase(WebAppTest):
acid_block = AcidView(self.browser, unit.components[0].preview_selector)
self.validate_acid_block_preview(acid_block)
@skip('Temporarily diabling because it is failing in Jenkins. TE-369')
def test_acid_block_editor(self):
"""
Verify that all expected acid block tests pass in studio editor
......@@ -189,7 +188,6 @@ class XBlockAcidBase(WebAppTest):
self.assertTrue(acid_block.scope_passed('settings'))
@skip('Temporarily diabling because it is failing in Jenkins. TE-369')
class XBlockAcidNoChildTest(XBlockAcidBase):
"""
Tests of an AcidBlock with no children
......@@ -226,7 +224,6 @@ class XBlockAcidParentBase(XBlockAcidBase):
super(XBlockAcidParentBase, self).validate_acid_block_preview(acid_block)
self.assertTrue(acid_block.child_tests_passed)
@skip('Intermittently failing, needs a better page definition that waits until the unit is fully rendered')
def test_acid_block_preview(self):
"""
Verify that all expected acid block tests pass in studio preview
......
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