test: add tests to test override_legacy_discussion_settings flag with different roles
This commit is contained in:
@@ -144,21 +144,27 @@ class TestInstructorDashboard(ModuleStoreTestCase, LoginEnrollmentTestCase, XssT
|
||||
('staff', False, False, True),
|
||||
('staff', True, False, False),
|
||||
('staff', True, True, True),
|
||||
('staff', False, True, True),
|
||||
('instructor', False, False, True),
|
||||
('instructor', True, False, False),
|
||||
('instructor', True, True, True),
|
||||
('instructor', False, True, True)
|
||||
)
|
||||
@ddt.unpack
|
||||
def test_discussion_tab(self, access_role, is_pages_and_resources_enabled, is_legacy_discussion_setting_enabled,
|
||||
is_discussion_tab_available):
|
||||
def test_discussion_tab_for_course_staff_role(self, access_role, is_pages_and_resources_enabled,
|
||||
is_legacy_discussion_setting_enabled, is_discussion_tab_available):
|
||||
"""
|
||||
Verify that the Discussion tab only shows up when Pages & Resources flag is off for course
|
||||
Verify that the Discussion tab is available for course for course staff role.
|
||||
"""
|
||||
discussion_section = '<li class="nav-item"><button type="button" class="btn-link discussions_management" ' \
|
||||
'data-section="discussions_management">Discussions</button></li>'
|
||||
discussion_section = ('<li class="nav-item"><button type="button" class="btn-link discussions_management" '
|
||||
'data-section="discussions_management">Discussions</button></li>')
|
||||
|
||||
with override_waffle_flag(ENABLE_PAGES_AND_RESOURCES_MICROFRONTEND, is_pages_and_resources_enabled):
|
||||
with override_waffle_flag(OVERRIDE_DISCUSSION_LEGACY_SETTINGS_FLAG, is_legacy_discussion_setting_enabled):
|
||||
user = UserFactory.create()
|
||||
CourseAccessRoleFactory(
|
||||
course_id=self.course.id,
|
||||
user=self.user,
|
||||
user=user,
|
||||
role=access_role,
|
||||
org=self.course.id.org
|
||||
)
|
||||
@@ -167,6 +173,29 @@ class TestInstructorDashboard(ModuleStoreTestCase, LoginEnrollmentTestCase, XssT
|
||||
response = self.client.get(self.url).content.decode('utf-8')
|
||||
self.assertEqual(discussion_section in response, is_discussion_tab_available)
|
||||
|
||||
@ddt.data(
|
||||
(False, False, True),
|
||||
(True, False, False),
|
||||
(True, True, True),
|
||||
(False, True, True),
|
||||
)
|
||||
@ddt.unpack
|
||||
def test_discussion_tab_for_global_user(self, is_pages_and_resources_enabled,
|
||||
is_legacy_discussion_setting_enabled, is_discussion_tab_available):
|
||||
"""
|
||||
Verify that the Discussion tab is available for course for global user.
|
||||
"""
|
||||
discussion_section = ('<li class="nav-item"><button type="button" class="btn-link discussions_management" '
|
||||
'data-section="discussions_management">Discussions</button></li>')
|
||||
|
||||
with override_waffle_flag(ENABLE_PAGES_AND_RESOURCES_MICROFRONTEND, is_pages_and_resources_enabled):
|
||||
with override_waffle_flag(OVERRIDE_DISCUSSION_LEGACY_SETTINGS_FLAG, is_legacy_discussion_setting_enabled):
|
||||
user = UserFactory.create(is_staff=True)
|
||||
set_course_cohorted(self.course.id, True)
|
||||
self.client.login(username=user.username, password='test')
|
||||
response = self.client.get(self.url).content.decode('utf-8')
|
||||
self.assertEqual(discussion_section in response, is_discussion_tab_available)
|
||||
|
||||
@ddt.data(
|
||||
('staff', False, False),
|
||||
('instructor', False, False),
|
||||
|
||||
@@ -17,8 +17,8 @@ WAFFLE_NAMESPACE = LegacyWaffleFlagNamespace(name='discussions')
|
||||
# .. toggle_use_cases: temporary, open_edx
|
||||
# .. toggle_creation_date: 2021-06-15
|
||||
# .. toggle_target_removal_date: 2021-12-31
|
||||
# .. toggle_warnings: Discussion settings will be visible when this flag is enabled with Pages & Resources flag enabled.
|
||||
# .. toggle_tickets: https://openedx.atlassian.net/browse/TNL-8389
|
||||
# .. toggle_warnings: When the flag is ON, the discussion settings will be available on legacy experience.
|
||||
# .. toggle_tickets: TNL-8389
|
||||
OVERRIDE_DISCUSSION_LEGACY_SETTINGS_FLAG = CourseWaffleFlag(
|
||||
waffle_namespace=WAFFLE_NAMESPACE,
|
||||
flag_name='override_discussion_legacy_settings',
|
||||
@@ -33,8 +33,8 @@ OVERRIDE_DISCUSSION_LEGACY_SETTINGS_FLAG = CourseWaffleFlag(
|
||||
# .. toggle_use_cases: temporary, open_edx
|
||||
# .. toggle_creation_date: 2021-05-24
|
||||
# .. toggle_target_removal_date: 2021-12-31
|
||||
# .. toggle_warnings: Also set settings.COURSE_AUTHORING_MICROFRONTEND_URL.
|
||||
# .. toggle_tickets: https://openedx.atlassian.net/browse/TNL-7791
|
||||
# .. toggle_warnings: When the flag is ON, the new experience for Pages and Resources will be enabled.
|
||||
# .. toggle_tickets: TNL-7791
|
||||
ENABLE_PAGES_AND_RESOURCES_MICROFRONTEND = CourseWaffleFlag(
|
||||
waffle_namespace=WAFFLE_NAMESPACE,
|
||||
flag_name='pages_and_resources_mfe',
|
||||
|
||||
Reference in New Issue
Block a user