diff --git a/common/test/acceptance/pages/lms/staff_view.py b/common/test/acceptance/pages/lms/staff_view.py new file mode 100644 index 0000000000..d16b5e3248 --- /dev/null +++ b/common/test/acceptance/pages/lms/staff_view.py @@ -0,0 +1,59 @@ +""" +Staff view of courseware +""" +from bok_choy.page_object import PageObject + + +class StaffPage(PageObject): + """ + View of courseware pages while logged in as course staff + """ + + url = None + + def is_browser_on_page(self): + return self.q(css='#staffstatus').present + + @property + def staff_status(self): + """ + Return the current status, either Staff view or Student view + """ + return self.q(css='#staffstatus').text[0] + + def open_staff_debug_info(self): + """ + Open the staff debug window + Return the page object for it. + """ + self.q(css='a.instructor-info-action').first.click() + staff_debug_page = StaffDebugPage(self.browser) + staff_debug_page.wait_for_page() + return staff_debug_page + + +class StaffDebugPage(PageObject): + """ + Staff Debug modal + """ + + url = None + + def is_browser_on_page(self): + return self.q(css='section.staff-modal').present + + def _click_link(self, link_text): + for link in self.q(css='section.staff-modal a').execute(): + if link.text == link_text: + return link.click() + + raise Exception('Could not find the {} link to click on.'.format( + link_text)) + + def reset_attempts(self): + self._click_link('Reset Attempts') + + @property + def idash_msg(self): + self.wait_for_ajax() + return self.q(css='#idash_msg').text diff --git a/common/test/acceptance/tests/test_staff_view.py b/common/test/acceptance/tests/test_staff_view.py new file mode 100644 index 0000000000..64dd052b94 --- /dev/null +++ b/common/test/acceptance/tests/test_staff_view.py @@ -0,0 +1,61 @@ +# -*- coding: utf-8 -*- +""" +E2E tests for the LMS. +""" + +from .helpers import UniqueCourseTest +from ..pages.studio.auto_auth import AutoAuthPage +from ..pages.lms.courseware import CoursewarePage +from ..pages.lms.staff_view import StaffPage +from ..fixtures.course import CourseFixture, XBlockFixtureDesc +from textwrap import dedent + + +class StaffDebugTest(UniqueCourseTest): + """ + Tests that verify the staff debug info. + """ + + def setUp(self): + super(StaffDebugTest, self).setUp() + + self.courseware_page = CoursewarePage(self.browser, self.course_id) + + # Install a course with sections/problems, tabs, updates, and handouts + course_fix = CourseFixture( + self.course_info['org'], self.course_info['number'], + self.course_info['run'], self.course_info['display_name'] + ) + + problem_data = dedent(""" + +

Choose Yes.

+ + + Yes + + +
+ """) + + course_fix.add_children( + XBlockFixtureDesc('chapter', 'Test Section').add_children( + XBlockFixtureDesc('sequential', 'Test Subsection').add_children( + XBlockFixtureDesc('problem', 'Test Problem 1', data=problem_data) + ) + ) + ).install() + + # Auto-auth register for the course. + # Do this as global staff so that you will see the Staff View + AutoAuthPage(self.browser, course_id=self.course_id, staff=True).visit() + + def test_staff_debug(self): + self.courseware_page.visit() + staff_page = StaffPage(self.browser) + self.assertEqual(staff_page.staff_status, 'Staff view') + staff_debug_page = staff_page.open_staff_debug_info() + staff_debug_page.reset_attempts() + + msg = staff_debug_page.idash_msg + self.assertEqual('foo', msg) # Not sure what is supposed to happen