Merge pull request #12974 from edx/kkim/gate_banner

Gated Subsection Staff Banner
This commit is contained in:
Kevin Kim
2016-07-27 11:27:52 -04:00
committed by GitHub
9 changed files with 135 additions and 28 deletions

View File

@@ -229,6 +229,12 @@ class CoursewarePage(CoursePage):
return self.entrance_exam_message_selector.is_present() \
and "You have passed the entrance exam" in self.entrance_exam_message_selector.text[0]
def has_banner(self):
"""
Returns boolean indicating presence of banner
"""
return self.q(css='.pattern-library-shim').is_present()
@property
def is_timer_bar_present(self):
"""

View File

@@ -9,6 +9,7 @@ from ...pages.studio.auto_auth import AutoAuthPage
from ...pages.studio.overview import CourseOutlinePage
from ...pages.lms.courseware import CoursewarePage
from ...pages.lms.problem import ProblemPage
from ...pages.lms.staff_view import StaffPage
from ...pages.common.logout import LogoutPage
from ...fixtures.course import CourseFixture, XBlockFixtureDesc
@@ -17,8 +18,11 @@ class GatingTest(UniqueCourseTest):
"""
Test gating feature in LMS.
"""
USERNAME = "STUDENT_TESTER"
EMAIL = "student101@example.com"
STAFF_USERNAME = "STAFF_TESTER"
STAFF_EMAIL = "staff101@example.com"
STUDENT_USERNAME = "STUDENT_TESTER"
STUDENT_EMAIL = "student101@example.com"
def setUp(self):
super(GatingTest, self).setUp()
@@ -82,7 +86,7 @@ class GatingTest(UniqueCourseTest):
Make the first subsection a prerequisite
"""
# Login as staff
self._auto_auth("STAFF_TESTER", "staff101@example.com", True)
self._auto_auth(self.STAFF_USERNAME, self.STAFF_EMAIL, True)
# Make the first subsection a prerequisite
self.course_outline.visit()
@@ -95,7 +99,7 @@ class GatingTest(UniqueCourseTest):
Gate the second subsection on the first subsection
"""
# Login as staff
self._auto_auth("STAFF_TESTER", "staff101@example.com", True)
self._auto_auth(self.STAFF_USERNAME, self.STAFF_EMAIL, True)
# Gate the second subsection based on the score achieved in the first subsection
self.course_outline.visit()
@@ -103,6 +107,15 @@ class GatingTest(UniqueCourseTest):
self.course_outline.select_advanced_tab(desired_item='gated_content')
self.course_outline.add_prerequisite_to_subsection("80")
def _fulfill_prerequisite(self):
"""
Fulfill the prerequisite needed to see gated content
"""
problem_page = ProblemPage(self.browser)
self.assertEqual(problem_page.wait_for_page().problem_name, 'HEIGHT OF EIFFEL TOWER')
problem_page.click_choice('choice_1')
problem_page.click_check()
def test_subsection_gating_in_studio(self):
"""
Given that I am a staff member
@@ -132,7 +145,7 @@ class GatingTest(UniqueCourseTest):
self.assertTrue(self.course_outline.gating_prerequisites_dropdown_is_visible())
self.assertTrue(self.course_outline.gating_prerequisite_min_score_is_visible())
def test_gated_subsection_in_lms(self):
def test_gated_subsection_in_lms_for_student(self):
"""
Given that I am a student
When I visit the LMS Courseware
@@ -143,15 +156,58 @@ class GatingTest(UniqueCourseTest):
self._setup_prereq()
self._setup_gated_subsection()
self._auto_auth(self.USERNAME, self.EMAIL, False)
self._auto_auth(self.STUDENT_USERNAME, self.STUDENT_EMAIL, False)
self.courseware_page.visit()
self.assertEqual(self.courseware_page.num_subsections, 1)
# Fulfill prerequisite and verify that gated subsection is shown
problem_page = ProblemPage(self.browser)
self.assertEqual(problem_page.wait_for_page().problem_name, 'HEIGHT OF EIFFEL TOWER')
problem_page.click_choice('choice_1')
problem_page.click_check()
self._fulfill_prerequisite()
self.courseware_page.visit()
self.assertEqual(self.courseware_page.num_subsections, 2)
def test_gated_subsection_in_lms_for_staff(self):
"""
Given that I am a staff member
When I visit the LMS Courseware
Then I can see all gated subsections
Displayed along with notification banners
Then if I masquerade as a student
Then I cannot see a gated subsection
When I fufill the gating prerequisite
Then I can see the gated subsection (without a banner)
"""
self._setup_prereq()
self._setup_gated_subsection()
# Fulfill prerequisites for specific student
self._auto_auth(self.STUDENT_USERNAME, self.STUDENT_EMAIL, False)
self.courseware_page.visit()
self._fulfill_prerequisite()
self._auto_auth(self.STAFF_USERNAME, self.STAFF_EMAIL, True)
self.courseware_page.visit()
staff_page = StaffPage(self.browser, self.course_id)
self.assertEqual(staff_page.staff_view_mode, 'Staff')
self.assertEqual(self.courseware_page.num_subsections, 2)
# Click on gated section and check for banner
self.courseware_page.q(css='.chapter-content-container a').nth(1).click()
self.courseware_page.wait_for_page()
self.assertTrue(self.courseware_page.has_banner())
self.courseware_page.q(css='.chapter-content-container a').nth(0).click()
self.courseware_page.wait_for_page()
staff_page.set_staff_view_mode('Student')
self.assertEqual(self.courseware_page.num_subsections, 1)
self.assertFalse(self.courseware_page.has_banner())
staff_page.set_staff_view_mode_specific_student(self.STUDENT_USERNAME)
self.assertEqual(self.courseware_page.num_subsections, 2)
self.courseware_page.q(css='.chapter-content-container a').nth(1).click()
self.courseware_page.wait_for_page()
self.assertFalse(self.courseware_page.has_banner())