|
29 | 29 | from lms.djangoapps.courseware.tabs import get_course_tab_list |
30 | 30 | from lms.djangoapps.courseware.tests.factories import StudentModuleFactory |
31 | 31 | from lms.djangoapps.courseware.tests.helpers import LoginEnrollmentTestCase |
| 32 | +from lms.djangoapps.discussion.django_comment_client.tests.factories import RoleFactory |
32 | 33 | from lms.djangoapps.grades.config.waffle import WRITABLE_GRADEBOOK |
33 | 34 | from lms.djangoapps.instructor.toggles import DATA_DOWNLOAD_V2 |
34 | 35 | from lms.djangoapps.instructor.views.gradebook_api import calculate_page_info |
|
37 | 38 | ENABLE_PAGES_AND_RESOURCES_MICROFRONTEND, |
38 | 39 | OVERRIDE_DISCUSSION_LEGACY_SETTINGS_FLAG |
39 | 40 | ) |
| 41 | +from openedx.core.djangoapps.django_comment_common.models import FORUM_ROLE_ADMINISTRATOR |
40 | 42 | from openedx.core.djangoapps.site_configuration.models import SiteConfiguration |
41 | 43 |
|
42 | 44 |
|
@@ -308,6 +310,56 @@ def test_membership_reason_field_visibility(self, enbale_reason_field): |
308 | 310 | else: |
309 | 311 | self.assertNotContains(response, reason_field) |
310 | 312 |
|
| 313 | + def test_membership_tab_for_eshe_instructor(self): |
| 314 | + """ |
| 315 | + Verify that eSHE instructors don't have access to membership tab and |
| 316 | + work correctly with other roles. |
| 317 | + """ |
| 318 | + |
| 319 | + membership_section = ( |
| 320 | + '<li class="nav-item">' |
| 321 | + '<button type="button" class="btn-link membership" data-section="membership">' |
| 322 | + 'Membership' |
| 323 | + '</button>' |
| 324 | + '</li>' |
| 325 | + ) |
| 326 | + batch_enrollment = ( |
| 327 | + '<fieldset class="batch-enrollment membership-section">' |
| 328 | + ) |
| 329 | + |
| 330 | + user = UserFactory.create() |
| 331 | + self.client.login(username=user.username, password="test") |
| 332 | + |
| 333 | + # eSHE instructors shouldn't have access to membership tab |
| 334 | + CourseAccessRoleFactory( |
| 335 | + course_id=self.course.id, |
| 336 | + user=user, |
| 337 | + role='eshe_instructor', |
| 338 | + org=self.course.id.org |
| 339 | + ) |
| 340 | + response = self.client.get(self.url) |
| 341 | + self.assertNotContains(response, membership_section) |
| 342 | + |
| 343 | + # However if combined with forum_admin, they should have access to this |
| 344 | + # tab, but not to batch enrollment |
| 345 | + forum_admin_role = RoleFactory(name=FORUM_ROLE_ADMINISTRATOR, course_id=self.course.id) |
| 346 | + forum_admin_role.users.add(user) |
| 347 | + response = self.client.get(self.url) |
| 348 | + self.assertContains(response, membership_section) |
| 349 | + self.assertNotContains(response, batch_enrollment) |
| 350 | + |
| 351 | + # Combined with course staff, should have union of all three roles |
| 352 | + # permissions sets |
| 353 | + CourseAccessRoleFactory( |
| 354 | + course_id=self.course.id, |
| 355 | + user=user, |
| 356 | + role='staff', |
| 357 | + org=self.course.id.org |
| 358 | + ) |
| 359 | + response = self.client.get(self.url) |
| 360 | + self.assertContains(response, membership_section) |
| 361 | + self.assertContains(response, batch_enrollment) |
| 362 | + |
311 | 363 | def test_student_admin_staff_instructor(self): |
312 | 364 | """ |
313 | 365 | Verify that staff users are not able to see course-wide options, while still |
|
0 commit comments