Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion common/test/acceptance/pages/lms/courseware.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,19 @@ def num_subsections(self):
"""
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):
"""
Expand Down
9 changes: 8 additions & 1 deletion common/test/acceptance/pages/lms/instructor_dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,10 @@ def get_selected_cohort(self):
"""
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]
)
Expand Down Expand Up @@ -163,7 +167,10 @@ def add_cohort(self, cohort_name, content_group=None):
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:
Expand Down
7 changes: 5 additions & 2 deletions common/test/acceptance/pages/studio/auto_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class AutoAuthPage(PageObject):
this url will create a user and log them in.
"""

def __init__(self, browser, username=None, email=None, password=None, staff=None, course_id=None, roles=None):
def __init__(self, browser, username=None, email=None, password=None, staff=None, course_id=None, roles=None, no_login=None):

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note to reviewers: these changes were taken from #6283, which has not yet merged to master.

"""
Auto-auth is an end-point for HTTP GET requests.
By default, it will create accounts with random user credentials,
Expand Down Expand Up @@ -51,6 +51,9 @@ def __init__(self, browser, username=None, email=None, password=None, staff=None
if roles is not None:
self._params['roles'] = roles

if no_login:
self._params['no_login'] = True

@property
def url(self):
"""
Expand All @@ -66,7 +69,7 @@ def url(self):

def is_browser_on_page(self):
message = self.q(css='BODY').text[0]
match = re.search(r'Logged in user ([^$]+) with password ([^$]+) and user_id ([^$]+)$', message)
match = re.search(r'(Logged in|Created) user ([^$]+) with password ([^$]+) and user_id ([^$]+)$', message)
return True if match else False

def get_user_id(self):
Expand Down
49 changes: 29 additions & 20 deletions common/test/acceptance/tests/lms/test_lms_user_preview.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,28 +266,26 @@ def populate_course_fixture(self, course_fixture):
</problem>
""")

self.alpha_text = "VISIBLE TO ALPHA"

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note to reviewers: making all caps to make the string comparison easier. Currently the LMS uppercases display names. By making the names uppercase initially, we don't have to worry about that (and if the LMS stops uppercasing display names, the test won't need to change).

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(

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note to reviewers: when I wrote this test, I followed the pattern of other tests in the file that put problems directly under subsections. I have changed it now to represent the structure that would be created by Studio (problems in a unit).

Because of that, I can't use course_nav.sequence_items, which only returns the display name of the first component on that page (which would be the unit display name). If I put each problem into its own unit it also doesn't work because all students will see each unit, even if it has no content for a particular student.

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
Expand All @@ -296,8 +294,8 @@ def test_staff_sees_all_problems(self):
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):
"""
Expand All @@ -310,7 +308,7 @@ def test_student_not_in_content_group(self):
"""
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):
"""
Expand All @@ -323,7 +321,7 @@ def test_as_student_in_alpha(self):
"""
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):
"""
Expand All @@ -336,4 +334,15 @@ def test_as_student_in_beta(self):
"""
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)
4 changes: 2 additions & 2 deletions common/test/acceptance/tests/studio/base_studio_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
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
Expand Down
Loading