Commit 39acbdcb by cahrens Committed by Andy Armstrong

End-to-end bok choy test for cohorted courseware.

parent 8abec98c
......@@ -34,11 +34,18 @@ class CoursewarePage(CoursePage):
return len(self.q(css=self.subsection_selector))
@property
def xblock_components(self):
"""
Return the xblock components within the unit on the page.
"""
return self.q(css=self.xblock_component_selector)
@property
def num_xblock_components(self):
"""
Return the number of rendered xblocks within the unit on the page
"""
return len(self.q(css=self.xblock_component_selector))
return len(self.xblock_components)
def xblock_component_type(self, index=0):
"""
......
......@@ -133,6 +133,10 @@ class MembershipPageCohortManagementSection(PageObject):
"""
Returns the name of the selected cohort.
"""
EmptyPromise(
lambda: len(self._get_cohort_options().results) > 0,
"Waiting for cohort selector to populate"
).fulfill()
return self._cohort_name(
self._get_cohort_options().filter(lambda el: el.is_selected()).first.text[0]
)
......@@ -163,7 +167,10 @@ class MembershipPageCohortManagementSection(PageObject):
Adds a new manual cohort with the specified name.
If a content group should also be associated, the name of the content group should be specified.
"""
self.q(css=self._bounded_selector("div.cohort-management-nav .action-create")).first.click()
create_buttons = self.q(css=self._bounded_selector(".action-create"))
# There are 2 create buttons on the page. The second one is only present when no cohort yet exists
# (in which case the first is not visible). Click on the last present create button.
create_buttons.results[len(create_buttons.results) - 1].click()
textinput = self.q(css=self._bounded_selector("#cohort-name")).results[0]
textinput.send_keys(cohort_name)
if content_group:
......
......@@ -266,28 +266,26 @@ class CourseWithContentGroupsTest(StaffViewTest):
</problem>
""")
self.alpha_text = "VISIBLE TO ALPHA"
self.beta_text = "VISIBLE TO BETA"
self.everyone_text = "VISIBLE TO EVERYONE"
course_fixture.add_children(
XBlockFixtureDesc('chapter', 'Test Section').add_children(
XBlockFixtureDesc('sequential', 'Test Subsection').add_children(
XBlockFixtureDesc(
'problem', 'Visible to alpha', data=problem_data, metadata={"group_access": {0: [0]}}
),
XBlockFixtureDesc(
'problem', 'Visible to beta', data=problem_data, metadata={"group_access": {0: [1]}}
),
XBlockFixtureDesc('problem', 'Visible to everyone', data=problem_data)
XBlockFixtureDesc('vertical', 'Test Unit').add_children(
XBlockFixtureDesc(
'problem', self.alpha_text, data=problem_data, metadata={"group_access": {0: [0]}}
),
XBlockFixtureDesc(
'problem', self.beta_text, data=problem_data, metadata={"group_access": {0: [1]}}
),
XBlockFixtureDesc('problem', self.everyone_text, data=problem_data)
)
)
)
)
def _verify_visible_problems(self, expected_items):
"""
Verify that the expected problems are visible.
"""
course_nav = CourseNavPage(self.browser)
actual_items = course_nav.sequence_items
self.assertItemsEqual(expected_items, actual_items)
def test_staff_sees_all_problems(self):
"""
Scenario: Staff see all problems
......@@ -296,8 +294,8 @@ class CourseWithContentGroupsTest(StaffViewTest):
When I view the courseware in the LMS with staff access
Then I see all the problems, regardless of their group_access property
"""
self._goto_staff_page()
self._verify_visible_problems(['Visible to alpha', 'Visible to beta', 'Visible to everyone'])
course_page = self._goto_staff_page()
verify_expected_problem_visibility(self, course_page, [self.alpha_text, self.beta_text, self.everyone_text])
def test_student_not_in_content_group(self):
"""
......@@ -310,7 +308,7 @@ class CourseWithContentGroupsTest(StaffViewTest):
"""
course_page = self._goto_staff_page()
course_page.set_staff_view_mode('Student')
self._verify_visible_problems(['Visible to everyone'])
verify_expected_problem_visibility(self, course_page, [self.everyone_text])
def test_as_student_in_alpha(self):
"""
......@@ -323,7 +321,7 @@ class CourseWithContentGroupsTest(StaffViewTest):
"""
course_page = self._goto_staff_page()
course_page.set_staff_view_mode('Student in alpha')
self._verify_visible_problems(['Visible to alpha', 'Visible to everyone'])
verify_expected_problem_visibility(self, course_page, [self.alpha_text, self.everyone_text])
def test_as_student_in_beta(self):
"""
......@@ -336,4 +334,15 @@ class CourseWithContentGroupsTest(StaffViewTest):
"""
course_page = self._goto_staff_page()
course_page.set_staff_view_mode('Student in beta')
self._verify_visible_problems(['Visible to beta', 'Visible to everyone'])
verify_expected_problem_visibility(self, course_page, [self.beta_text, self.everyone_text])
def verify_expected_problem_visibility(test, courseware_page, expected_problems):
"""
Helper method that checks that the expected problems are visible on the current page.
"""
test.assertEqual(
len(expected_problems), courseware_page.num_xblock_components, "Incorrect number of visible problems"
)
for index, expected_problem in enumerate(expected_problems):
test.assertIn(expected_problem, courseware_page.xblock_components[index].text)
......@@ -58,12 +58,12 @@ class ContainerBase(StudioCourseTest):
Base class for tests that do operations on the container page.
"""
def setUp(self):
def setUp(self, is_staff=False):
"""
Create a unique identifier for the course used in this test.
"""
# Ensure that the superclass sets up
super(ContainerBase, self).setUp()
super(ContainerBase, self).setUp(is_staff=is_staff)
self.outline = CourseOutlinePage(
self.browser,
......
......@@ -14,7 +14,6 @@ from bok_choy.promise import Promise, EmptyPromise
from ...fixtures.course import XBlockFixtureDesc
from ...pages.studio.component_editor import ComponentEditorView
from ...pages.studio.overview import CourseOutlinePage, CourseOutlineUnit
from ...pages.studio.settings_advanced import AdvancedSettingsPage
from ...pages.studio.container import ContainerPage
from ...pages.studio.settings_group_configurations import GroupConfigurationsPage
from ...pages.studio.utils import add_advanced_component
......
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