2323from lms .djangoapps .courseware .access import has_access
2424from lms .djangoapps .courseware .tests .helpers import CourseAccessTestMixin , LoginEnrollmentTestCase
2525from lms .djangoapps .instructor .toggles import LEGACY_INSTRUCTOR_DASHBOARD
26+ from openedx .features .course_experience import course_home_url
2627from openedx .features .enterprise_support .tests .mixins .enterprise import EnterpriseTestConsentRequired
2728from xmodule .modulestore .django import modulestore
2829from xmodule .modulestore .tests .django_utils import ModuleStoreTestCase
@@ -58,10 +59,13 @@ def _check_non_staff_light(self, course):
5859
5960 `course` is an instance of CourseBlock.
6061 """
61- urls = [reverse ('about_course' , kwargs = {'course_id' : str (course .id )}),
62- reverse ('courses' )]
63- for url in urls :
64- self .assert_request_status_code (200 , url )
62+ about_url = reverse ('about_course' , kwargs = {'course_id' : str (course .id )})
63+ response = self .client .get (about_url )
64+ assert response .status_code == 302
65+ assert response ['Location' ] == course_home_url (course .id )
66+
67+ # courses view redirects to / when no marketing URL is configured
68+ self .assert_request_status_code (302 , reverse ('courses' ))
6569
6670 def _check_non_staff_dark (self , course ):
6771 """
@@ -94,9 +98,14 @@ def _check_staff(self, course):
9498 for index in range (len (course .textbooks ))
9599 ])
96100 for url in urls :
97- # Instructor dashboard returns 302 (MFE redirect) by default
98101 if 'instructor' in url :
102+ # Instructor dashboard returns 302 (MFE redirect) by default
99103 self .assert_request_status_code (302 , url )
104+ elif 'about' in url :
105+ # about_course redirects enrolled users to course home MFE
106+ response = self .client .get (url )
107+ assert response .status_code == 302
108+ assert response ['Location' ] == course_home_url (course .id )
100109 else :
101110 self .assert_request_status_code (200 , url )
102111
@@ -127,8 +136,14 @@ def _check_staff_legacy(self, course):
127136 for index in range (len (course .textbooks ))
128137 ])
129138 for url in urls :
130- # With legacy flag enabled, all URLs return 200 (instructor dashboard skips MFE redirect)
131- self .assert_request_status_code (200 , url )
139+ if 'about' in url :
140+ # about_course redirects enrolled users to course home MFE
141+ response = self .client .get (url )
142+ assert response .status_code == 302
143+ assert response ['Location' ] == course_home_url (course .id )
144+ else :
145+ # With legacy flag enabled, all other URLs return 200
146+ self .assert_request_status_code (200 , url )
132147
133148 # The student progress tab behavior is affected by legacy flag in normal scenarios
134149 url = reverse (
@@ -153,8 +168,14 @@ def _check_staff_legacy_dark_launch(self, course):
153168 for index in range (len (course .textbooks ))
154169 ])
155170 for url in urls :
156- # With legacy flag enabled, all URLs return 200 (instructor dashboard skips MFE redirect)
157- self .assert_request_status_code (200 , url )
171+ if 'about' in url :
172+ # about_course redirects enrolled users to course home MFE
173+ response = self .client .get (url )
174+ assert response .status_code == 302
175+ assert response ['Location' ] == course_home_url (course .id )
176+ else :
177+ # With legacy flag enabled, all other URLs return 200
178+ self .assert_request_status_code (200 , url )
158179
159180 # In dark launch scenarios, student progress URL still returns 302 even with legacy flag
160181 # because course access restrictions take precedence
0 commit comments