def setup_thread_page(self, thread_id):
     """
     This is called by BaseDiscussionMixin.setup_thread.
     """
     self.thread_page = DiscussionTabSingleThreadPage(
         self.browser, self.course_id, self.discussion_id, thread_id)
     self.thread_page.visit()
Example #2
0
    def setUp(self):
        super(DiscussionTabMultipleThreadTest, self).setUp()
        AutoAuthPage(self.browser, course_id=self.course_id).visit()
        self.thread_count = 2
        self.thread_ids = []
        self.setup_multiple_threads(thread_count=self.thread_count)

        self.thread_page_1 = DiscussionTabSingleThreadPage(
            self.browser, self.course_id, self.discussion_id,
            self.thread_ids[0])
        self.thread_page_2 = DiscussionTabSingleThreadPage(
            self.browser, self.course_id, self.discussion_id,
            self.thread_ids[1])
        self.thread_page_1.visit()
Example #3
0
 def create_single_thread_page(self, thread_id):
     """
     Sets up a `DiscussionTabSingleThreadPage` for a given
     `thread_id`.
     """
     return DiscussionTabSingleThreadPage(self.browser, self.course_id,
                                          self.discussion_id, thread_id)
Example #4
0
class DiscussionTabMultipleThreadTest(BaseDiscussionTestCase, BaseDiscussionMixin):
    """
    Tests for the discussion page with multiple threads
    """
    def setUp(self):
        super(DiscussionTabMultipleThreadTest, self).setUp()  # lint-amnesty, pylint: disable=super-with-arguments
        AutoAuthPage(self.browser, course_id=self.course_id).visit()
        self.thread_count = 2
        self.thread_ids = []
        self.setup_multiple_threads(thread_count=self.thread_count)

        self.thread_page_1 = DiscussionTabSingleThreadPage(
            self.browser,
            self.course_id,
            self.discussion_id,
            self.thread_ids[0]
        )
        self.thread_page_2 = DiscussionTabSingleThreadPage(
            self.browser,
            self.course_id,
            self.discussion_id,
            self.thread_ids[1]
        )
        self.thread_page_1.visit()

    @attr('a11y')
    def test_page_accessibility(self):
        self.thread_page_1.a11y_audit.config.set_rules({
            "ignore": [
                'section',  # TODO: AC-491
                'aria-required-children',  # TODO: AC-534
                'aria-valid-attr',  # TODO: LEARNER-6611 & LEARNER-6865
                'region',  # TODO: AC-932
            ]
        })

        self.thread_page_1.a11y_audit.check_for_accessibility_errors()

        self.thread_page_2.a11y_audit.config.set_rules({
            "ignore": [
                'section',  # TODO: AC-491
                'aria-required-children',  # TODO: AC-534
                'region'  # TODO: AC-932
            ]
        })

        self.thread_page_2.a11y_audit.check_for_accessibility_errors()
Example #5
0
class DiscussionTabSingleThreadTest(BaseDiscussionTestCase):
    """
    Tests for the discussion page displaying a single thread.
    """
    def setUp(self):
        super(DiscussionTabSingleThreadTest, self).setUp()
        self.setup_cohorts()
        AutoAuthPage(self.browser, course_id=self.course_id).visit()

    def setup_thread_page(self, thread_id):
        self.thread_page = DiscussionTabSingleThreadPage(self.browser, self.course_id, self.discussion_id, thread_id)  # pylint: disable=attribute-defined-outside-init
        self.thread_page.visit()

    # pylint: disable=unused-argument
    def refresh_thread_page(self, thread_id):
        self.browser.refresh()
        self.thread_page.wait_for_page()
 def setup_thread_page(self, thread_id):
     """
     This is called by BaseDiscussionMixin.setup_thread.
     """
     self.thread_page = DiscussionTabSingleThreadPage(
         self.browser, self.course_id, self.discussion_id, thread_id
     )
     self.thread_page.visit()
Example #7
0
class DiscussionTabSingleThreadTest(BaseDiscussionTestCase):
    """
    Tests for the discussion page displaying a single thread.
    """
    def setUp(self):
        super(DiscussionTabSingleThreadTest, self).setUp()
        self.setup_cohorts()
        AutoAuthPage(self.browser, course_id=self.course_id).visit()

    def setup_thread_page(self, thread_id):
        self.thread_page = DiscussionTabSingleThreadPage(self.browser, self.course_id, self.discussion_id, thread_id)  # pylint: disable=attribute-defined-outside-init
        self.thread_page.visit()

    # pylint: disable=unused-argument
    def refresh_thread_page(self, thread_id):
        self.browser.refresh()
        self.thread_page.wait_for_page()
Example #8
0
    def setUp(self):
        super(DiscussionTabMultipleThreadTest, self).setUp()  # lint-amnesty, pylint: disable=super-with-arguments
        AutoAuthPage(self.browser, course_id=self.course_id).visit()
        self.thread_count = 2
        self.thread_ids = []
        self.setup_multiple_threads(thread_count=self.thread_count)

        self.thread_page_1 = DiscussionTabSingleThreadPage(
            self.browser,
            self.course_id,
            self.discussion_id,
            self.thread_ids[0]
        )
        self.thread_page_2 = DiscussionTabSingleThreadPage(
            self.browser,
            self.course_id,
            self.discussion_id,
            self.thread_ids[1]
        )
        self.thread_page_1.visit()
class DivisionSchemeTest(BaseDividedDiscussionTest, BaseDiscussionMixin):
    """
    Tests for changing the division scheme for Discussions.
    """
    def add_modes_and_view_discussion_mgmt_page(self, modes):
        """
        Adds enrollment modes to the course, and then goes to the
        discussion tab on the instructor dashboard.
        """
        add_enrollment_course_modes(self.browser, self.course_id, modes)
        self.view_discussion_management_page()

    def view_discussion_management_page(self):
        """
        Go to the discussion tab on the instructor dashboard.
        """
        self.instructor_dashboard_page.visit()
        self.assertTrue(
            self.instructor_dashboard_page.is_discussion_management_visible())
        self.instructor_dashboard_page.select_discussion_management()
        self.discussion_management_page.wait_for_page()

    def setup_thread_page(self, thread_id):
        """
        This is called by BaseDiscussionMixin.setup_thread.
        """
        self.thread_page = DiscussionTabSingleThreadPage(
            self.browser, self.course_id, self.discussion_id, thread_id)
        self.thread_page.visit()

    def test_not_divided_hides_discussion_topics(self):
        """
        Tests that discussion topics are hidden iff discussion division is disabled.
        """
        # Initially "Cohort" is the selected scheme.
        self.assertTrue(
            self.discussion_management_page.division_scheme_visible(
                self.discussion_management_page.COHORT_SCHEME))
        self.assertEqual(self.discussion_management_page.COHORT_SCHEME,
                         self.discussion_management_page.get_selected_scheme())
        self.check_discussion_topic_visibility(visible=True)

        self.discussion_management_page.select_division_scheme(
            self.discussion_management_page.NOT_DIVIDED_SCHEME)
        self.verify_save_confirmation_message(self.scheme_key)
        self.check_discussion_topic_visibility(visible=False)

        # Reload the page and make sure that the change was persisted
        self.reload_page(topics_visible=False)
        self.assertTrue(
            self.discussion_management_page.division_scheme_visible(
                self.discussion_management_page.COHORT_SCHEME))
        self.assertEqual(self.discussion_management_page.NOT_DIVIDED_SCHEME,
                         self.discussion_management_page.get_selected_scheme())

        # Select "cohort" again and make sure that the discussion topics appear.
        self.discussion_management_page.select_division_scheme(
            self.discussion_management_page.COHORT_SCHEME)
        self.verify_save_confirmation_message(self.scheme_key)
        self.check_discussion_topic_visibility(visible=True)

    def test_disabling_cohorts(self):
        """
        Test that the discussions management tab hides when there is <= 1 enrollment track, the Cohort division scheme
         is not selected, and cohorts are disabled.
        (even without reloading the page).
        """
        self.disable_cohorting(self.course_fixture)
        self.instructor_dashboard_page.visit()
        self.assertFalse(
            self.instructor_dashboard_page.is_discussion_management_visible())

    def test_disabling_cohorts_while_selected(self):
        """
        Test that disabling cohorts does not hide the discussion tab when there is more than one enrollment track.
        Also that the division scheme for cohorts is visible iff it was selected.
        (even without reloading the page).
        """
        add_enrollment_course_modes(self.browser, self.course_id,
                                    ['audit', 'verified'])

        # Verify that the tab is visible, the cohort scheme is selected by default for divided discussions
        self.disable_cohorting(self.course_fixture)

        # Go to Discussions tab and ensure that the correct scheme options are visible
        self.view_discussion_management_page()
        self.assertTrue(
            self.discussion_management_page.division_scheme_visible(
                self.discussion_management_page.COHORT_SCHEME))

    def test_disabling_cohorts_while_not_selected(self):
        """
        Test that disabling cohorts does not hide the discussion tab when there is more than one enrollment track.
        Also that the division scheme for cohorts is not visible when cohorts are disabled and another scheme is
        selected for division.
        (even without reloading the page).
        """
        add_enrollment_course_modes(self.browser, self.course_id,
                                    ['audit', 'verified'])

        # Verify that the tab is visible
        self.view_discussion_management_page()
        self.discussion_management_page.select_division_scheme(
            self.discussion_management_page.ENROLLMENT_TRACK_SCHEME)
        self.verify_save_confirmation_message(self.scheme_key)
        self.disable_cohorting(self.course_fixture)

        # Go to Discussions tab and ensure that the correct scheme options are visible
        self.view_discussion_management_page()
        self.assertFalse(
            self.discussion_management_page.division_scheme_visible(
                self.discussion_management_page.COHORT_SCHEME))

    def test_single_enrollment_mode(self):
        """
        Test that the enrollment track scheme is not visible if there is a single enrollment mode.
        """
        self.add_modes_and_view_discussion_mgmt_page(['audit'])
        self.assertFalse(
            self.discussion_management_page.division_scheme_visible(
                self.discussion_management_page.ENROLLMENT_TRACK_SCHEME))

    def test_radio_buttons_with_multiple_enrollment_modes(self):
        """
        Test that the enrollment track scheme is visible if there are multiple enrollment tracks,
        and that the selection can be persisted.

        Also verifies that the cohort division scheme is not presented if cohorts are disabled and cohorts
        are not the selected division scheme.
        """
        self.add_modes_and_view_discussion_mgmt_page(['audit', 'verified'])
        self.assertTrue(
            self.discussion_management_page.division_scheme_visible(
                self.discussion_management_page.ENROLLMENT_TRACK_SCHEME))
        # And the cohort scheme is initially visible because it is selected (and cohorts are enabled).
        self.assertTrue(
            self.discussion_management_page.division_scheme_visible(
                self.discussion_management_page.COHORT_SCHEME))

        self.discussion_management_page.select_division_scheme(
            self.discussion_management_page.ENROLLMENT_TRACK_SCHEME)
        self.verify_save_confirmation_message(self.scheme_key)
        self.check_discussion_topic_visibility(visible=True)

        # Also disable cohorts so we can verify that the cohort scheme choice goes away.
        self.disable_cohorting(self.course_fixture)

        self.reload_page(topics_visible=True)
        self.assertEqual(
            self.discussion_management_page.ENROLLMENT_TRACK_SCHEME,
            self.discussion_management_page.get_selected_scheme())
        # Verify that the cohort scheme is no longer visible as cohorts are disabled.
        self.assertFalse(
            self.discussion_management_page.division_scheme_visible(
                self.discussion_management_page.COHORT_SCHEME))

    def test_enrollment_track_discussion_visibility_label(self):
        """
        If enrollment tracks are the division scheme, verifies that discussion visibility labels
        correctly render.

        Note that there are similar tests for cohorts in test_cohorts.py.
        """
        def refresh_thread_page():
            self.browser.refresh()
            self.thread_page.wait_for_page()

        # Make moderator for viewing all groups in discussions.
        AutoAuthPage(self.browser,
                     course_id=self.course_id,
                     roles="Moderator",
                     staff=True).visit()

        self.add_modes_and_view_discussion_mgmt_page(['audit', 'verified'])
        self.discussion_management_page.select_division_scheme(
            self.discussion_management_page.ENROLLMENT_TRACK_SCHEME)
        self.verify_save_confirmation_message(self.scheme_key)
        # Set "always divide" as the thread we will be creating will be an inline thread,
        # and this way the thread does not need to be explicitly divided.
        self.enable_always_divide_inline_discussions(self.course_fixture)

        # Create a thread with group_id corresponding to the Audit enrollment mode.
        # The Audit group ID is 1, and for the comment service group_id we negate it.
        self.setup_thread(1, group_id=-1)

        refresh_thread_page()
        self.assertEquals(self.thread_page.get_group_visibility_label(),
                          u"This post is visible only to {}.".format("Audit"))

        # Disable dividing discussions and verify that the post now shows as visible to everyone.
        self.view_discussion_management_page()
        self.discussion_management_page.select_division_scheme(
            self.discussion_management_page.NOT_DIVIDED_SCHEME)
        self.verify_save_confirmation_message(self.scheme_key)

        self.thread_page.visit()
        self.assertEquals(self.thread_page.get_group_visibility_label(),
                          "This post is visible to everyone.")
Example #10
0
 def setup_thread_page(self, thread_id):
     self.thread_page = DiscussionTabSingleThreadPage(
         self.browser, self.course_id, self.discussion_id, thread_id)  # pylint: disable=attribute-defined-outside-init
     self.thread_page.visit()
Example #11
0
 def setup_thread_page(self, thread_id):
     self.thread_page = DiscussionTabSingleThreadPage(self.browser, self.course_id, self.discussion_id, thread_id)  # pylint: disable=attribute-defined-outside-init
     self.thread_page.visit()
class DivisionSchemeTest(BaseDividedDiscussionTest, BaseDiscussionMixin):
    """
    Tests for changing the division scheme for Discussions.
    """

    def add_modes_and_view_discussion_mgmt_page(self, modes):
        """
        Adds enrollment modes to the course, and then goes to the
        discussion tab on the instructor dashboard.
        """
        add_enrollment_course_modes(self.browser, self.course_id, modes)
        self.view_discussion_management_page()

    def view_discussion_management_page(self):
        """
        Go to the discussion tab on the instructor dashboard.
        """
        self.instructor_dashboard_page.visit()
        self.assertTrue(self.instructor_dashboard_page.is_discussion_management_visible())
        self.instructor_dashboard_page.select_discussion_management()
        self.discussion_management_page.wait_for_page()

    def setup_thread_page(self, thread_id):
        """
        This is called by BaseDiscussionMixin.setup_thread.
        """
        self.thread_page = DiscussionTabSingleThreadPage(
            self.browser, self.course_id, self.discussion_id, thread_id
        )
        self.thread_page.visit()

    def test_not_divided_hides_discussion_topics(self):
        """
        Tests that discussion topics are hidden iff discussion division is disabled.
        """
        # Initially "Cohort" is the selected scheme.
        self.assertTrue(
            self.discussion_management_page.division_scheme_visible(self.discussion_management_page.COHORT_SCHEME)
        )
        self.assertEqual(
            self.discussion_management_page.COHORT_SCHEME,
            self.discussion_management_page.get_selected_scheme()
        )
        self.check_discussion_topic_visibility(visible=True)

        self.discussion_management_page.select_division_scheme(self.discussion_management_page.NOT_DIVIDED_SCHEME)
        self.verify_save_confirmation_message(self.scheme_key)
        self.check_discussion_topic_visibility(visible=False)

        # Reload the page and make sure that the change was persisted
        self.reload_page(topics_visible=False)
        self.assertTrue(self.discussion_management_page.division_scheme_visible(
            self.discussion_management_page.COHORT_SCHEME)
        )
        self.assertEqual(
            self.discussion_management_page.NOT_DIVIDED_SCHEME,
            self.discussion_management_page.get_selected_scheme()
        )

        # Select "cohort" again and make sure that the discussion topics appear.
        self.discussion_management_page.select_division_scheme(self.discussion_management_page.COHORT_SCHEME)
        self.verify_save_confirmation_message(self.scheme_key)
        self.check_discussion_topic_visibility(visible=True)

    def test_disabling_cohorts(self):
        """
        Test that the discussions management tab hides when there is <= 1 enrollment track, the Cohort division scheme
         is not selected, and cohorts are disabled.
        (even without reloading the page).
        """
        self.disable_cohorting(self.course_fixture)
        self.instructor_dashboard_page.visit()
        self.assertFalse(self.instructor_dashboard_page.is_discussion_management_visible())

    def test_disabling_cohorts_while_selected(self):
        """
        Test that disabling cohorts does not hide the discussion tab when there is more than one enrollment track.
        Also that the division scheme for cohorts is visible iff it was selected.
        (even without reloading the page).
        """
        add_enrollment_course_modes(self.browser, self.course_id, ['audit', 'verified'])

        # Verify that the tab is visible, the cohort scheme is selected by default for divided discussions
        self.disable_cohorting(self.course_fixture)

        # Go to Discussions tab and ensure that the correct scheme options are visible
        self.view_discussion_management_page()
        self.assertTrue(
            self.discussion_management_page.division_scheme_visible(
                self.discussion_management_page.COHORT_SCHEME
            )
        )

    def test_disabling_cohorts_while_not_selected(self):
        """
        Test that disabling cohorts does not hide the discussion tab when there is more than one enrollment track.
        Also that the division scheme for cohorts is not visible when cohorts are disabled and another scheme is
        selected for division.
        (even without reloading the page).
        """
        add_enrollment_course_modes(self.browser, self.course_id, ['audit', 'verified'])

        # Verify that the tab is visible
        self.view_discussion_management_page()
        self.discussion_management_page.select_division_scheme(self.discussion_management_page.ENROLLMENT_TRACK_SCHEME)
        self.verify_save_confirmation_message(self.scheme_key)
        self.disable_cohorting(self.course_fixture)

        # Go to Discussions tab and ensure that the correct scheme options are visible
        self.view_discussion_management_page()
        self.assertFalse(
            self.discussion_management_page.division_scheme_visible(
                self.discussion_management_page.COHORT_SCHEME
            )
        )

    def test_single_enrollment_mode(self):
        """
        Test that the enrollment track scheme is not visible if there is a single enrollment mode.
        """
        self.add_modes_and_view_discussion_mgmt_page(['audit'])
        self.assertFalse(
            self.discussion_management_page.division_scheme_visible(
                self.discussion_management_page.ENROLLMENT_TRACK_SCHEME
            )
        )

    def test_radio_buttons_with_multiple_enrollment_modes(self):
        """
        Test that the enrollment track scheme is visible if there are multiple enrollment tracks,
        and that the selection can be persisted.

        Also verifies that the cohort division scheme is not presented if cohorts are disabled and cohorts
        are not the selected division scheme.
        """
        self.add_modes_and_view_discussion_mgmt_page(['audit', 'verified'])
        self.assertTrue(
            self.discussion_management_page.division_scheme_visible(
                self.discussion_management_page.ENROLLMENT_TRACK_SCHEME
            )
        )
        # And the cohort scheme is initially visible because it is selected (and cohorts are enabled).
        self.assertTrue(
            self.discussion_management_page.division_scheme_visible(self.discussion_management_page.COHORT_SCHEME)
        )

        self.discussion_management_page.select_division_scheme(self.discussion_management_page.ENROLLMENT_TRACK_SCHEME)
        self.verify_save_confirmation_message(self.scheme_key)
        self.check_discussion_topic_visibility(visible=True)

        # Also disable cohorts so we can verify that the cohort scheme choice goes away.
        self.disable_cohorting(self.course_fixture)

        self.reload_page(topics_visible=True)
        self.assertEqual(
            self.discussion_management_page.ENROLLMENT_TRACK_SCHEME,
            self.discussion_management_page.get_selected_scheme()
        )
        # Verify that the cohort scheme is no longer visible as cohorts are disabled.
        self.assertFalse(
            self.discussion_management_page.division_scheme_visible(self.discussion_management_page.COHORT_SCHEME)
        )

    def test_enrollment_track_discussion_visibility_label(self):
        """
        If enrollment tracks are the division scheme, verifies that discussion visibility labels
        correctly render.

        Note that there are similar tests for cohorts in test_cohorts.py.
        """
        def refresh_thread_page():
            self.browser.refresh()
            self.thread_page.wait_for_page()

        # Make moderator for viewing all groups in discussions.
        AutoAuthPage(self.browser, course_id=self.course_id, roles="Moderator", staff=True).visit()

        self.add_modes_and_view_discussion_mgmt_page(['audit', 'verified'])
        self.discussion_management_page.select_division_scheme(self.discussion_management_page.ENROLLMENT_TRACK_SCHEME)
        self.verify_save_confirmation_message(self.scheme_key)
        # Set "always divide" as the thread we will be creating will be an inline thread,
        # and this way the thread does not need to be explicitly divided.
        self.enable_always_divide_inline_discussions(self.course_fixture)

        # Create a thread with group_id corresponding to the Audit enrollment mode.
        # The Audit group ID is 1, and for the comment service group_id we negate it.
        self.setup_thread(1, group_id=-1)

        refresh_thread_page()
        self.assertEquals(
            self.thread_page.get_group_visibility_label(),
            "This post is visible only to {}.".format("Audit")
        )

        # Disable dividing discussions and verify that the post now shows as visible to everyone.
        self.view_discussion_management_page()
        self.discussion_management_page.select_division_scheme(self.discussion_management_page.NOT_DIVIDED_SCHEME)
        self.verify_save_confirmation_message(self.scheme_key)

        self.thread_page.visit()
        self.assertEquals(self.thread_page.get_group_visibility_label(), "This post is visible to everyone.")