diff --git a/lms/djangoapps/courseware/tests/test_date_summary.py b/lms/djangoapps/courseware/tests/test_date_summary.py index 8d2abe377e..245e4bda80 100644 --- a/lms/djangoapps/courseware/tests/test_date_summary.py +++ b/lms/djangoapps/courseware/tests/test_date_summary.py @@ -17,6 +17,7 @@ from pytz import utc from common.djangoapps.course_modes.models import CourseMode from common.djangoapps.course_modes.tests.factories import CourseModeFactory from lms.djangoapps.commerce.models import CommerceConfiguration +from lms.djangoapps.course_home_api.toggles import COURSE_HOME_MICROFRONTEND from lms.djangoapps.courseware.courses import get_course_date_blocks from lms.djangoapps.courseware.date_summary import ( CertificateAvailableDate, @@ -33,6 +34,7 @@ from lms.djangoapps.courseware.models import ( DynamicUpgradeDeadlineConfiguration, OrgDynamicUpgradeDeadlineConfiguration ) +from lms.djangoapps.experiments.testutils import override_experiment_waffle_flag from lms.djangoapps.verify_student.models import VerificationDeadline from lms.djangoapps.verify_student.services import IDVerificationService from lms.djangoapps.verify_student.tests.factories import SoftwareSecurePhotoVerificationFactory @@ -709,24 +711,38 @@ class CourseDateSummaryTest(SharedModuleStoreTestCase): block = VerificationDeadlineDate(course, user) assert block.relative_datestring == expected_date_string - @ddt.data('info', 'openedx.course_experience.course_home') + @ddt.data( + ('info', True), + ('info', False), + ('openedx.course_experience.course_home', True), + ('openedx.course_experience.course_home', False), + ) + @ddt.unpack @override_waffle_flag(DISABLE_UNIFIED_COURSE_TAB_FLAG, active=False) @override_waffle_flag(RELATIVE_DATES_FLAG, active=True) - def test_dates_tab_link_render(self, url_name): + def test_dates_tab_link_render(self, url_name, mfe_active): """ The dates tab link should only show for enrolled or staff users """ course = create_course_run() html_elements = [ 'class="dates-tab-link"', 'View all course dates', - '/courses/' + str(course.id) + '/dates' ] + # The url should change based on the mfe being active. + if mfe_active: + html_elements.append('/course/' + str(course.id) + '/dates') + else: + html_elements.append('/courses/' + str(course.id) + '/dates') url = reverse(url_name, args=(course.id,)) def assert_html_elements(assert_function, user): self.client.login(username=user.username, password=TEST_PASSWORD) - response = self.client.get(url, follow=True) - for html in html_elements: - assert_function(response, html) + with override_experiment_waffle_flag(COURSE_HOME_MICROFRONTEND, active=mfe_active): + response = self.client.get(url, follow=True) + if mfe_active and not user.is_staff: + assert 404 == response.status_code + else: + for html in html_elements: + assert_function(response, html) self.client.logout() with freeze_time('2015-01-02'):