From f018cfe70e5066eac64bf76476ddf5b156667cf1 Mon Sep 17 00:00:00 2001 From: Serhii Nanai Date: Fri, 30 May 2025 17:34:49 +0300 Subject: [PATCH 01/12] feat: update course_about & catalog link generation --- cms/envs/test.py | 2 ++ common/djangoapps/util/course.py | 5 ++- common/djangoapps/util/tests/test_course.py | 39 +++++++++++++++++++++ lms/djangoapps/learner_home/test_views.py | 21 +++++++++++ lms/djangoapps/learner_home/views.py | 7 +++- lms/envs/common.py | 4 +++ lms/envs/test.py | 2 ++ 7 files changed, 78 insertions(+), 2 deletions(-) diff --git a/cms/envs/test.py b/cms/envs/test.py index 9a294bf10b01..5b6b4facbec6 100644 --- a/cms/envs/test.py +++ b/cms/envs/test.py @@ -373,3 +373,5 @@ SOFTWARE_SECURE_VERIFICATION_ROUTING_KEY = "edx.lms.core.default" STATIC_ROOT_BASE = "/edx/var/edxapp/staticfiles" STATIC_URL_BASE = "/static/" + +CATALOG_MICROFRONTEND_URL = "http://catalog-mfe" diff --git a/common/djangoapps/util/course.py b/common/djangoapps/util/course.py index fa82f9c4aaeb..ebc5b587851e 100644 --- a/common/djangoapps/util/course.py +++ b/common/djangoapps/util/course.py @@ -9,6 +9,7 @@ from django.conf import settings from opaque_keys.edx.keys import CourseKey, UsageKey +from lms.djangoapps.branding.toggles import catalog_mfe_enabled, use_new_course_about_page from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers from openedx_filters.learning.filters import CourseAboutPageURLRequested @@ -50,7 +51,9 @@ def get_link_for_about_page(course): 'SOCIAL_SHARING_SETTINGS', getattr(settings, 'SOCIAL_SHARING_SETTINGS', {}) ).get('CUSTOM_COURSE_URLS') - if is_social_sharing_enabled and course.social_sharing_url: + if catalog_mfe_enabled() and use_new_course_about_page(course.id): + course_about_url = f'{settings.CATALOG_MICROFRONTEND_URL}/courses/{course.id}/about' + elif is_social_sharing_enabled and course.social_sharing_url: course_about_url = course.social_sharing_url elif settings.FEATURES.get('ENABLE_MKTG_SITE') and getattr(course, 'marketing_url', None): course_about_url = course.marketing_url diff --git a/common/djangoapps/util/tests/test_course.py b/common/djangoapps/util/tests/test_course.py index 1c476b9756f5..75c700bbc4f6 100644 --- a/common/djangoapps/util/tests/test_course.py +++ b/common/djangoapps/util/tests/test_course.py @@ -5,7 +5,10 @@ import ddt from django.conf import settings +from django.test import override_settings +from edx_toggles.toggles.testutils import override_waffle_flag +from lms.djangoapps.branding.toggles import ENABLE_NEW_COURSE_ABOUT_PAGE from openedx.core.djangoapps.content.course_overviews.models import CourseOverview from common.djangoapps.util.course import get_link_for_about_page from xmodule.modulestore import ModuleStoreEnum # lint-amnesty, pylint: disable=wrong-import-order @@ -126,3 +129,39 @@ def test_sharing_link_with_course_block(self, enable_social_sharing, expected_co use_overview=False, ) assert actual_course_sharing_link == expected_course_sharing_link + + @ddt.data( + ( + True, + True, + f'{settings.CATALOG_MICROFRONTEND_URL}/courses/course-v1:test_org+test_number+test_run/about' + ), + ( + True, + False, + f'{settings.LMS_ROOT_URL}/courses/course-v1:test_org+test_number+test_run/about' + ), + ( + False, + True, + f'{settings.LMS_ROOT_URL}/courses/course-v1:test_org+test_number+test_run/about' + ), + ( + False, + False, + f'{settings.LMS_ROOT_URL}/courses/course-v1:test_org+test_number+test_run/about' + ) + ) + @ddt.unpack + def test_sharing_link_with_new_course_about_page( + self, catalog_mfe_enabled, use_new_course_about_page, expected_course_sharing_link + ): + """ + Verify the method gives correct course sharing url when new course about page is used. + """ + with override_waffle_flag(ENABLE_NEW_COURSE_ABOUT_PAGE, active=use_new_course_about_page): + features = settings.FEATURES.copy() + features['ENABLE_CATALOG_MICROFRONTEND'] = catalog_mfe_enabled + with override_settings(FEATURES=features): + actual_course_sharing_link = get_link_for_about_page(self.course_overview) + assert actual_course_sharing_link == expected_course_sharing_link diff --git a/lms/djangoapps/learner_home/test_views.py b/lms/djangoapps/learner_home/test_views.py index 5b098939718d..427bc97d7d35 100644 --- a/lms/djangoapps/learner_home/test_views.py +++ b/lms/djangoapps/learner_home/test_views.py @@ -13,6 +13,7 @@ from django.urls import reverse from django.utils import timezone from django.test import TestCase, override_settings +from edx_toggles.toggles.testutils import override_waffle_flag from opaque_keys.edx.keys import CourseKey from rest_framework.test import APITestCase @@ -23,6 +24,7 @@ UserFactory, ) from common.djangoapps.util.course import get_encoded_course_sharing_utm_params +from lms.djangoapps.branding.toggles import ENABLE_NEW_CATALOG_PAGE from lms.djangoapps.bulk_email.models import Optout from lms.djangoapps.learner_home.test_utils import ( create_test_enrollment, @@ -61,6 +63,7 @@ ENTERPRISE_ENABLED = "ENABLE_ENTERPRISE_INTEGRATION" +@ddt.ddt class TestGetPlatformSettings(TestCase): """Tests for get_platform_settings""" @@ -88,6 +91,24 @@ def test_happy_path(self, mock_marketing_link): }, ) + @ddt.data( + (True, True, f'{settings.CATALOG_MICROFRONTEND_URL}/courses'), + (True, False, '/courses'), + (False, True, '/courses'), + (False, False, '/courses') + ) + @ddt.unpack + def test_link_with_new_catalog_page(self, catalog_mfe_enabled, use_new_catalog_page, expected_catalog_link): + """ + Test that the catalog link is constructed correctly based on the MFE flags. + """ + with override_waffle_flag(ENABLE_NEW_CATALOG_PAGE, active=use_new_catalog_page): + features = settings.FEATURES.copy() + features['ENABLE_CATALOG_MICROFRONTEND'] = catalog_mfe_enabled + with override_settings(FEATURES=features): + actual_course_sharing_link = get_platform_settings()["courseSearchUrl"] + assert actual_course_sharing_link == expected_catalog_link + @ddt.ddt class TestGetUserAccountConfirmationInfo(SharedModuleStoreTestCase): diff --git a/lms/djangoapps/learner_home/views.py b/lms/djangoapps/learner_home/views.py index b97f9a20f461..cfa66854c39d 100644 --- a/lms/djangoapps/learner_home/views.py +++ b/lms/djangoapps/learner_home/views.py @@ -41,6 +41,7 @@ from common.djangoapps.util.milestones_helpers import ( get_pre_requisite_courses_not_completed, ) +from lms.djangoapps.branding import toggles from lms.djangoapps.bulk_email.models import Optout from lms.djangoapps.bulk_email.models_api import is_bulk_email_feature_enabled from lms.djangoapps.commerce.utils import EcommerceService @@ -71,10 +72,14 @@ def get_platform_settings(): """Get settings used for platform level connections: emails, url routes, etc.""" + course_search_url = marketing_link("COURSES") + if toggles.catalog_mfe_enabled() and toggles.use_new_catalog_page(): + course_search_url = f"{settings.CATALOG_MICROFRONTEND_URL}/courses" + return { "supportEmail": settings.DEFAULT_FEEDBACK_EMAIL, "billingEmail": settings.PAYMENT_SUPPORT_EMAIL, - "courseSearchUrl": marketing_link("COURSES"), + "courseSearchUrl": course_search_url, } diff --git a/lms/envs/common.py b/lms/envs/common.py index 046b7cfef3ea..3dde7156b93e 100644 --- a/lms/envs/common.py +++ b/lms/envs/common.py @@ -3217,6 +3217,10 @@ # .. setting_default: None # .. setting_description: Base URL of the exams dashboard micro-frontend for instructors. EXAMS_DASHBOARD_MICROFRONTEND_URL = None +# .. setting_name: CATALOG_MICROFRONTEND_URL +# .. setting_default: None +# .. setting_description: Base URL of the micro-frontend-based course catalog page. +CATALOG_MICROFRONTEND_URL = None # .. setting_name: DISCUSSION_SPAM_URLS # .. setting_default: [] diff --git a/lms/envs/test.py b/lms/envs/test.py index 958a54be0180..367714e04137 100644 --- a/lms/envs/test.py +++ b/lms/envs/test.py @@ -747,3 +747,5 @@ STATIC_URL_BASE = "/static/" ZENDESK_API_KEY = "" ZENDESK_USER = "" + +CATALOG_MICROFRONTEND_URL = "http://catalog-mfe" From 1c1fa1b1a1810591c2c7a212411af736b5640f49 Mon Sep 17 00:00:00 2001 From: Serhii Nanai Date: Wed, 2 Jul 2025 18:30:18 +0300 Subject: [PATCH 02/12] refactor: switch to global mfe state check --- .../rest_api/v1/views/tests/test_settings.py | 1 + .../contentstore/tests/test_contentstore.py | 2 ++ .../tests/test_course_settings.py | 7 ++++- .../views/tests/test_credit_eligibility.py | 1 + .../views/tests/test_exam_settings_view.py | 1 + common/djangoapps/student/tests/test_views.py | 1 + common/djangoapps/util/course.py | 4 +-- common/djangoapps/util/tests/test_course.py | 30 +++++-------------- lms/djangoapps/learner_home/test_views.py | 13 ++++---- lms/djangoapps/learner_home/views.py | 2 +- 10 files changed, 28 insertions(+), 34 deletions(-) diff --git a/cms/djangoapps/contentstore/rest_api/v1/views/tests/test_settings.py b/cms/djangoapps/contentstore/rest_api/v1/views/tests/test_settings.py index 15b0992fdf1a..81101e541bd5 100644 --- a/cms/djangoapps/contentstore/rest_api/v1/views/tests/test_settings.py +++ b/cms/djangoapps/contentstore/rest_api/v1/views/tests/test_settings.py @@ -17,6 +17,7 @@ @ddt.ddt +@patch.dict("django.conf.settings.FEATURES", {"ENABLE_CATALOG_MICROFRONTEND": False}) class CourseSettingsViewTest(CourseTestCase, PermissionAccessMixin): """ Tests for CourseSettingsView. diff --git a/cms/djangoapps/contentstore/tests/test_contentstore.py b/cms/djangoapps/contentstore/tests/test_contentstore.py index 8b6aa6d2bba5..4380c1e9383f 100644 --- a/cms/djangoapps/contentstore/tests/test_contentstore.py +++ b/cms/djangoapps/contentstore/tests/test_contentstore.py @@ -91,6 +91,7 @@ def decorated_func(*args, **kwargs): @override_settings(CONTENTSTORE=TEST_DATA_CONTENTSTORE) +@mock.patch.dict("django.conf.settings.FEATURES", {"ENABLE_CATALOG_MICROFRONTEND": False}) class ContentStoreTestCase(CourseTestCase): """ Base class for Content Store Test Cases @@ -1049,6 +1050,7 @@ def _check_verticals(self, locations): @ddt.ddt +@mock.patch.dict("django.conf.settings.FEATURES", {"ENABLE_CATALOG_MICROFRONTEND": False}) class ContentStoreTest(ContentStoreTestCase): """ Tests for the CMS ContentStore application. diff --git a/cms/djangoapps/contentstore/tests/test_course_settings.py b/cms/djangoapps/contentstore/tests/test_course_settings.py index a72d14e931f7..197e55a6da58 100644 --- a/cms/djangoapps/contentstore/tests/test_course_settings.py +++ b/cms/djangoapps/contentstore/tests/test_course_settings.py @@ -180,7 +180,10 @@ def test_disable_advanced_settings_feature(self, disable_advanced_settings): """ advanced_settings_link_html = f"Advanced Settings".encode('utf-8') - with override_settings(FEATURES={'DISABLE_ADVANCED_SETTINGS': disable_advanced_settings}): + with override_settings(FEATURES={ + 'DISABLE_ADVANCED_SETTINGS': disable_advanced_settings, + 'ENABLE_CATALOG_MICROFRONTEND': False, + }): for handler in ( 'import_handler', 'export_handler', @@ -219,6 +222,7 @@ def test_disable_advanced_settings_feature(self, disable_advanced_settings): @ddt.ddt +@patch.dict("django.conf.settings.FEATURES", {"ENABLE_CATALOG_MICROFRONTEND": False}) class CourseDetailsViewTest(CourseTestCase, MilestonesTestCaseMixin): """ Tests for modifying content on the first course settings page (course dates, overview, etc.). @@ -1923,6 +1927,7 @@ def test_add(self): self.assertEqual(len(self.starting_graders) + 1, len(current_graders)) +@patch.dict("django.conf.settings.FEATURES", {"ENABLE_CATALOG_MICROFRONTEND": False}) class CourseEnrollmentEndFieldTest(CourseTestCase): """ Base class to test the enrollment end fields in the course settings details view in Studio diff --git a/cms/djangoapps/contentstore/views/tests/test_credit_eligibility.py b/cms/djangoapps/contentstore/views/tests/test_credit_eligibility.py index 66e42598bee6..a16ccb0762be 100644 --- a/cms/djangoapps/contentstore/views/tests/test_credit_eligibility.py +++ b/cms/djangoapps/contentstore/views/tests/test_credit_eligibility.py @@ -15,6 +15,7 @@ from xmodule.modulestore.tests.factories import CourseFactory # lint-amnesty, pylint: disable=wrong-import-order +@mock.patch.dict("django.conf.settings.FEATURES", {"ENABLE_CATALOG_MICROFRONTEND": False}) class CreditEligibilityTest(CourseTestCase): """ Base class to test the course settings details view in Studio for credit diff --git a/cms/djangoapps/contentstore/views/tests/test_exam_settings_view.py b/cms/djangoapps/contentstore/views/tests/test_exam_settings_view.py index 9bad2c77fc1a..1684be98f5ff 100644 --- a/cms/djangoapps/contentstore/views/tests/test_exam_settings_view.py +++ b/cms/djangoapps/contentstore/views/tests/test_exam_settings_view.py @@ -30,6 +30,7 @@ @override_waffle_flag(toggles.LEGACY_STUDIO_CONFIGURATIONS, True) @override_waffle_flag(toggles.LEGACY_STUDIO_GRADING, True) @override_waffle_flag(toggles.LEGACY_STUDIO_ADVANCED_SETTINGS, True) +@patch.dict("django.conf.settings.FEATURES", {"ENABLE_CATALOG_MICROFRONTEND": False}) class TestExamSettingsView(CourseTestCase, UrlResetMixin): """ Unit tests for the exam settings view. diff --git a/common/djangoapps/student/tests/test_views.py b/common/djangoapps/student/tests/test_views.py index b63c522bbd0f..0fce8d0f032c 100644 --- a/common/djangoapps/student/tests/test_views.py +++ b/common/djangoapps/student/tests/test_views.py @@ -191,6 +191,7 @@ class StudentDashboardTests(SharedModuleStoreTestCase, MilestonesTestCaseMixin, 'DISABLE_START_DATES': False, 'ENABLE_MKTG_SITE': True, 'DISABLE_SET_JWT_COOKIES_FOR_TESTS': True, + 'ENABLE_CATALOG_MICROFRONTEND': False, }, 'SOCIAL_SHARING_SETTINGS': { 'CUSTOM_COURSE_URLS': True, diff --git a/common/djangoapps/util/course.py b/common/djangoapps/util/course.py index ebc5b587851e..0e20736eb0a1 100644 --- a/common/djangoapps/util/course.py +++ b/common/djangoapps/util/course.py @@ -9,7 +9,7 @@ from django.conf import settings from opaque_keys.edx.keys import CourseKey, UsageKey -from lms.djangoapps.branding.toggles import catalog_mfe_enabled, use_new_course_about_page +from lms.djangoapps.branding.toggles import use_catalog_mfe from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers from openedx_filters.learning.filters import CourseAboutPageURLRequested @@ -51,7 +51,7 @@ def get_link_for_about_page(course): 'SOCIAL_SHARING_SETTINGS', getattr(settings, 'SOCIAL_SHARING_SETTINGS', {}) ).get('CUSTOM_COURSE_URLS') - if catalog_mfe_enabled() and use_new_course_about_page(course.id): + if use_catalog_mfe(): course_about_url = f'{settings.CATALOG_MICROFRONTEND_URL}/courses/{course.id}/about' elif is_social_sharing_enabled and course.social_sharing_url: course_about_url = course.social_sharing_url diff --git a/common/djangoapps/util/tests/test_course.py b/common/djangoapps/util/tests/test_course.py index 75c700bbc4f6..fb3a61d966c9 100644 --- a/common/djangoapps/util/tests/test_course.py +++ b/common/djangoapps/util/tests/test_course.py @@ -6,9 +6,7 @@ import ddt from django.conf import settings from django.test import override_settings -from edx_toggles.toggles.testutils import override_waffle_flag -from lms.djangoapps.branding.toggles import ENABLE_NEW_COURSE_ABOUT_PAGE from openedx.core.djangoapps.content.course_overviews.models import CourseOverview from common.djangoapps.util.course import get_link_for_about_page from xmodule.modulestore import ModuleStoreEnum # lint-amnesty, pylint: disable=wrong-import-order @@ -54,7 +52,8 @@ def get_course_sharing_link(self, enable_social_sharing, enable_mktg_site, use_o """ mock_settings = { 'FEATURES': { - 'ENABLE_MKTG_SITE': enable_mktg_site + 'ENABLE_MKTG_SITE': enable_mktg_site, + 'ENABLE_CATALOG_MICROFRONTEND': False, }, 'SOCIAL_SHARING_SETTINGS': { 'CUSTOM_COURSE_URLS': enable_social_sharing @@ -132,36 +131,23 @@ def test_sharing_link_with_course_block(self, enable_social_sharing, expected_co @ddt.data( ( - True, True, f'{settings.CATALOG_MICROFRONTEND_URL}/courses/course-v1:test_org+test_number+test_run/about' ), ( - True, - False, - f'{settings.LMS_ROOT_URL}/courses/course-v1:test_org+test_number+test_run/about' - ), - ( - False, - True, - f'{settings.LMS_ROOT_URL}/courses/course-v1:test_org+test_number+test_run/about' - ), - ( - False, False, f'{settings.LMS_ROOT_URL}/courses/course-v1:test_org+test_number+test_run/about' ) ) @ddt.unpack def test_sharing_link_with_new_course_about_page( - self, catalog_mfe_enabled, use_new_course_about_page, expected_course_sharing_link + self, catalog_mfe_enabled, expected_course_sharing_link ): """ Verify the method gives correct course sharing url when new course about page is used. """ - with override_waffle_flag(ENABLE_NEW_COURSE_ABOUT_PAGE, active=use_new_course_about_page): - features = settings.FEATURES.copy() - features['ENABLE_CATALOG_MICROFRONTEND'] = catalog_mfe_enabled - with override_settings(FEATURES=features): - actual_course_sharing_link = get_link_for_about_page(self.course_overview) - assert actual_course_sharing_link == expected_course_sharing_link + features = settings.FEATURES.copy() + features['ENABLE_CATALOG_MICROFRONTEND'] = catalog_mfe_enabled + with override_settings(FEATURES=features): + actual_course_sharing_link = get_link_for_about_page(self.course_overview) + assert actual_course_sharing_link == expected_course_sharing_link diff --git a/lms/djangoapps/learner_home/test_views.py b/lms/djangoapps/learner_home/test_views.py index 427bc97d7d35..1c8d92a87d22 100644 --- a/lms/djangoapps/learner_home/test_views.py +++ b/lms/djangoapps/learner_home/test_views.py @@ -13,7 +13,6 @@ from django.urls import reverse from django.utils import timezone from django.test import TestCase, override_settings -from edx_toggles.toggles.testutils import override_waffle_flag from opaque_keys.edx.keys import CourseKey from rest_framework.test import APITestCase @@ -24,7 +23,6 @@ UserFactory, ) from common.djangoapps.util.course import get_encoded_course_sharing_utm_params -from lms.djangoapps.branding.toggles import ENABLE_NEW_CATALOG_PAGE from lms.djangoapps.bulk_email.models import Optout from lms.djangoapps.learner_home.test_utils import ( create_test_enrollment, @@ -102,12 +100,11 @@ def test_link_with_new_catalog_page(self, catalog_mfe_enabled, use_new_catalog_p """ Test that the catalog link is constructed correctly based on the MFE flags. """ - with override_waffle_flag(ENABLE_NEW_CATALOG_PAGE, active=use_new_catalog_page): - features = settings.FEATURES.copy() - features['ENABLE_CATALOG_MICROFRONTEND'] = catalog_mfe_enabled - with override_settings(FEATURES=features): - actual_course_sharing_link = get_platform_settings()["courseSearchUrl"] - assert actual_course_sharing_link == expected_catalog_link + features = settings.FEATURES.copy() + features['ENABLE_CATALOG_MICROFRONTEND'] = catalog_mfe_enabled + with override_settings(FEATURES=features): + actual_course_sharing_link = get_platform_settings()["courseSearchUrl"] + assert actual_course_sharing_link == expected_catalog_link @ddt.ddt diff --git a/lms/djangoapps/learner_home/views.py b/lms/djangoapps/learner_home/views.py index cfa66854c39d..40962721b339 100644 --- a/lms/djangoapps/learner_home/views.py +++ b/lms/djangoapps/learner_home/views.py @@ -73,7 +73,7 @@ def get_platform_settings(): """Get settings used for platform level connections: emails, url routes, etc.""" course_search_url = marketing_link("COURSES") - if toggles.catalog_mfe_enabled() and toggles.use_new_catalog_page(): + if toggles.use_catalog_mfe(): course_search_url = f"{settings.CATALOG_MICROFRONTEND_URL}/courses" return { From f85c86e6bdd13d0afc5bce1edbe0deb449efb8d2 Mon Sep 17 00:00:00 2001 From: PKulkoRaccoonGang Date: Wed, 30 Jul 2025 06:45:37 +0300 Subject: [PATCH 03/12] chore: updated settings for mfes --- lms/envs/devstack.py | 1 + 1 file changed, 1 insertion(+) diff --git a/lms/envs/devstack.py b/lms/envs/devstack.py index e2fc7fb6c281..05d135d38ca2 100644 --- a/lms/envs/devstack.py +++ b/lms/envs/devstack.py @@ -396,6 +396,7 @@ def should_show_debug_toolbar(request): # lint-amnesty, pylint: disable=missing AUTHN_MICROFRONTEND_URL = 'http://localhost:1999' AUTHN_MICROFRONTEND_DOMAIN = 'localhost:1999' EXAMS_DASHBOARD_MICROFRONTEND_URL = 'http://localhost:2020' +CATALOG_MICROFRONTEND_URL = 'http://localhost:1998' ################### FRONTEND APPLICATION DISCUSSIONS ################### DISCUSSIONS_MICROFRONTEND_URL = 'http://localhost:2002' From 18ec2a151702c7cb906ce79eb7eef558a18f7142 Mon Sep 17 00:00:00 2001 From: Serhii Nanai Date: Wed, 30 Jul 2025 09:56:42 +0300 Subject: [PATCH 04/12] fix: fix gettings ENABLE_CATALOG_MICROFRONTEND FEATURE --- lms/djangoapps/branding/toggles.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lms/djangoapps/branding/toggles.py b/lms/djangoapps/branding/toggles.py index ba7b3407d704..9612843f0e5d 100644 --- a/lms/djangoapps/branding/toggles.py +++ b/lms/djangoapps/branding/toggles.py @@ -8,8 +8,8 @@ def use_catalog_mfe(): """ - Determine if Catalog MFE is enabled, replacing student_dashboard + Returns a boolean = true if the Catalog MFE is enabled. """ return configuration_helpers.get_value( - 'ENABLE_CATALOG_MICROFRONTEND', settings.FEATURES['ENABLE_CATALOG_MICROFRONTEND'] + 'ENABLE_CATALOG_MICROFRONTEND', settings.FEATURES.get('ENABLE_CATALOG_MICROFRONTEND') ) From c64ec1f3ae6d5665f3a0dfe62f8765f1001f0889 Mon Sep 17 00:00:00 2001 From: Serhii Nanai Date: Tue, 23 Sep 2025 20:37:51 +0300 Subject: [PATCH 05/12] fix: append /catalog to CATALOG_MICROFRONTEND_URL --- lms/envs/devstack.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lms/envs/devstack.py b/lms/envs/devstack.py index 05d135d38ca2..b15533855c7b 100644 --- a/lms/envs/devstack.py +++ b/lms/envs/devstack.py @@ -396,7 +396,7 @@ def should_show_debug_toolbar(request): # lint-amnesty, pylint: disable=missing AUTHN_MICROFRONTEND_URL = 'http://localhost:1999' AUTHN_MICROFRONTEND_DOMAIN = 'localhost:1999' EXAMS_DASHBOARD_MICROFRONTEND_URL = 'http://localhost:2020' -CATALOG_MICROFRONTEND_URL = 'http://localhost:1998' +CATALOG_MICROFRONTEND_URL = 'http://localhost:1998/catalog' ################### FRONTEND APPLICATION DISCUSSIONS ################### DISCUSSIONS_MICROFRONTEND_URL = 'http://localhost:2002' From 47f5cb84bcca1aa162a55879e0ea675377ee1a17 Mon Sep 17 00:00:00 2001 From: Serhii Nanai Date: Wed, 24 Sep 2025 11:32:30 +0300 Subject: [PATCH 06/12] test: fix ddt in test_link_with_new_catalog_page --- lms/djangoapps/learner_home/test_views.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/lms/djangoapps/learner_home/test_views.py b/lms/djangoapps/learner_home/test_views.py index 1c8d92a87d22..ddb22a91daf0 100644 --- a/lms/djangoapps/learner_home/test_views.py +++ b/lms/djangoapps/learner_home/test_views.py @@ -90,13 +90,11 @@ def test_happy_path(self, mock_marketing_link): ) @ddt.data( - (True, True, f'{settings.CATALOG_MICROFRONTEND_URL}/courses'), - (True, False, '/courses'), - (False, True, '/courses'), - (False, False, '/courses') + (True, f'{settings.CATALOG_MICROFRONTEND_URL}/courses'), + (False, '/courses'), ) @ddt.unpack - def test_link_with_new_catalog_page(self, catalog_mfe_enabled, use_new_catalog_page, expected_catalog_link): + def test_link_with_new_catalog_page(self, catalog_mfe_enabled, expected_catalog_link): """ Test that the catalog link is constructed correctly based on the MFE flags. """ From 94c00afa65c003718282a62275e8cd9a39a4e1ae Mon Sep 17 00:00:00 2001 From: Serhii Nanai Date: Thu, 25 Sep 2025 12:12:46 +0300 Subject: [PATCH 07/12] fix: put CATALOG_MICROFRONTEND_URL with the other mfe urls --- lms/envs/test.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lms/envs/test.py b/lms/envs/test.py index 367714e04137..218a7e8461b8 100644 --- a/lms/envs/test.py +++ b/lms/envs/test.py @@ -577,6 +577,7 @@ LEARNER_HOME_MICROFRONTEND_URL = "http://learner-home-mfe" ORA_GRADING_MICROFRONTEND_URL = "http://ora-grading-mfe" ORA_MICROFRONTEND_URL = "http://ora-mfe" +CATALOG_MICROFRONTEND_URL = "http://catalog-mfe" ########################## limiting dashboard courses ###################### @@ -747,5 +748,3 @@ STATIC_URL_BASE = "/static/" ZENDESK_API_KEY = "" ZENDESK_USER = "" - -CATALOG_MICROFRONTEND_URL = "http://catalog-mfe" From b448b0fe69982e093f84b0d8af8c54718d963a08 Mon Sep 17 00:00:00 2001 From: Serhii Nanai Date: Mon, 29 Sep 2025 14:15:57 +0300 Subject: [PATCH 08/12] fix: look up ENABLE_CATALOG_MICROFRONTEND in settings directly, adjust tests --- .../contentstore/rest_api/v1/views/tests/test_settings.py | 1 - cms/djangoapps/contentstore/tests/test_contentstore.py | 2 -- cms/djangoapps/contentstore/tests/test_course_settings.py | 3 --- .../contentstore/views/tests/test_credit_eligibility.py | 1 - .../contentstore/views/tests/test_exam_settings_view.py | 1 - common/djangoapps/student/tests/test_views.py | 1 - common/djangoapps/util/tests/test_course.py | 4 +--- lms/djangoapps/branding/toggles.py | 2 +- lms/djangoapps/learner_home/test_views.py | 7 ++----- 9 files changed, 4 insertions(+), 18 deletions(-) diff --git a/cms/djangoapps/contentstore/rest_api/v1/views/tests/test_settings.py b/cms/djangoapps/contentstore/rest_api/v1/views/tests/test_settings.py index 81101e541bd5..15b0992fdf1a 100644 --- a/cms/djangoapps/contentstore/rest_api/v1/views/tests/test_settings.py +++ b/cms/djangoapps/contentstore/rest_api/v1/views/tests/test_settings.py @@ -17,7 +17,6 @@ @ddt.ddt -@patch.dict("django.conf.settings.FEATURES", {"ENABLE_CATALOG_MICROFRONTEND": False}) class CourseSettingsViewTest(CourseTestCase, PermissionAccessMixin): """ Tests for CourseSettingsView. diff --git a/cms/djangoapps/contentstore/tests/test_contentstore.py b/cms/djangoapps/contentstore/tests/test_contentstore.py index 4380c1e9383f..8b6aa6d2bba5 100644 --- a/cms/djangoapps/contentstore/tests/test_contentstore.py +++ b/cms/djangoapps/contentstore/tests/test_contentstore.py @@ -91,7 +91,6 @@ def decorated_func(*args, **kwargs): @override_settings(CONTENTSTORE=TEST_DATA_CONTENTSTORE) -@mock.patch.dict("django.conf.settings.FEATURES", {"ENABLE_CATALOG_MICROFRONTEND": False}) class ContentStoreTestCase(CourseTestCase): """ Base class for Content Store Test Cases @@ -1050,7 +1049,6 @@ def _check_verticals(self, locations): @ddt.ddt -@mock.patch.dict("django.conf.settings.FEATURES", {"ENABLE_CATALOG_MICROFRONTEND": False}) class ContentStoreTest(ContentStoreTestCase): """ Tests for the CMS ContentStore application. diff --git a/cms/djangoapps/contentstore/tests/test_course_settings.py b/cms/djangoapps/contentstore/tests/test_course_settings.py index 197e55a6da58..08d858c55062 100644 --- a/cms/djangoapps/contentstore/tests/test_course_settings.py +++ b/cms/djangoapps/contentstore/tests/test_course_settings.py @@ -182,7 +182,6 @@ def test_disable_advanced_settings_feature(self, disable_advanced_settings): with override_settings(FEATURES={ 'DISABLE_ADVANCED_SETTINGS': disable_advanced_settings, - 'ENABLE_CATALOG_MICROFRONTEND': False, }): for handler in ( 'import_handler', @@ -222,7 +221,6 @@ def test_disable_advanced_settings_feature(self, disable_advanced_settings): @ddt.ddt -@patch.dict("django.conf.settings.FEATURES", {"ENABLE_CATALOG_MICROFRONTEND": False}) class CourseDetailsViewTest(CourseTestCase, MilestonesTestCaseMixin): """ Tests for modifying content on the first course settings page (course dates, overview, etc.). @@ -1927,7 +1925,6 @@ def test_add(self): self.assertEqual(len(self.starting_graders) + 1, len(current_graders)) -@patch.dict("django.conf.settings.FEATURES", {"ENABLE_CATALOG_MICROFRONTEND": False}) class CourseEnrollmentEndFieldTest(CourseTestCase): """ Base class to test the enrollment end fields in the course settings details view in Studio diff --git a/cms/djangoapps/contentstore/views/tests/test_credit_eligibility.py b/cms/djangoapps/contentstore/views/tests/test_credit_eligibility.py index a16ccb0762be..66e42598bee6 100644 --- a/cms/djangoapps/contentstore/views/tests/test_credit_eligibility.py +++ b/cms/djangoapps/contentstore/views/tests/test_credit_eligibility.py @@ -15,7 +15,6 @@ from xmodule.modulestore.tests.factories import CourseFactory # lint-amnesty, pylint: disable=wrong-import-order -@mock.patch.dict("django.conf.settings.FEATURES", {"ENABLE_CATALOG_MICROFRONTEND": False}) class CreditEligibilityTest(CourseTestCase): """ Base class to test the course settings details view in Studio for credit diff --git a/cms/djangoapps/contentstore/views/tests/test_exam_settings_view.py b/cms/djangoapps/contentstore/views/tests/test_exam_settings_view.py index 1684be98f5ff..9bad2c77fc1a 100644 --- a/cms/djangoapps/contentstore/views/tests/test_exam_settings_view.py +++ b/cms/djangoapps/contentstore/views/tests/test_exam_settings_view.py @@ -30,7 +30,6 @@ @override_waffle_flag(toggles.LEGACY_STUDIO_CONFIGURATIONS, True) @override_waffle_flag(toggles.LEGACY_STUDIO_GRADING, True) @override_waffle_flag(toggles.LEGACY_STUDIO_ADVANCED_SETTINGS, True) -@patch.dict("django.conf.settings.FEATURES", {"ENABLE_CATALOG_MICROFRONTEND": False}) class TestExamSettingsView(CourseTestCase, UrlResetMixin): """ Unit tests for the exam settings view. diff --git a/common/djangoapps/student/tests/test_views.py b/common/djangoapps/student/tests/test_views.py index 0fce8d0f032c..b63c522bbd0f 100644 --- a/common/djangoapps/student/tests/test_views.py +++ b/common/djangoapps/student/tests/test_views.py @@ -191,7 +191,6 @@ class StudentDashboardTests(SharedModuleStoreTestCase, MilestonesTestCaseMixin, 'DISABLE_START_DATES': False, 'ENABLE_MKTG_SITE': True, 'DISABLE_SET_JWT_COOKIES_FOR_TESTS': True, - 'ENABLE_CATALOG_MICROFRONTEND': False, }, 'SOCIAL_SHARING_SETTINGS': { 'CUSTOM_COURSE_URLS': True, diff --git a/common/djangoapps/util/tests/test_course.py b/common/djangoapps/util/tests/test_course.py index fb3a61d966c9..a4fd4de595bf 100644 --- a/common/djangoapps/util/tests/test_course.py +++ b/common/djangoapps/util/tests/test_course.py @@ -146,8 +146,6 @@ def test_sharing_link_with_new_course_about_page( """ Verify the method gives correct course sharing url when new course about page is used. """ - features = settings.FEATURES.copy() - features['ENABLE_CATALOG_MICROFRONTEND'] = catalog_mfe_enabled - with override_settings(FEATURES=features): + with override_settings(ENABLE_CATALOG_MICROFRONTEND=catalog_mfe_enabled): actual_course_sharing_link = get_link_for_about_page(self.course_overview) assert actual_course_sharing_link == expected_course_sharing_link diff --git a/lms/djangoapps/branding/toggles.py b/lms/djangoapps/branding/toggles.py index 9612843f0e5d..a69afb9f1466 100644 --- a/lms/djangoapps/branding/toggles.py +++ b/lms/djangoapps/branding/toggles.py @@ -11,5 +11,5 @@ def use_catalog_mfe(): Returns a boolean = true if the Catalog MFE is enabled. """ return configuration_helpers.get_value( - 'ENABLE_CATALOG_MICROFRONTEND', settings.FEATURES.get('ENABLE_CATALOG_MICROFRONTEND') + 'ENABLE_CATALOG_MICROFRONTEND', settings.ENABLE_CATALOG_MICROFRONTEND ) diff --git a/lms/djangoapps/learner_home/test_views.py b/lms/djangoapps/learner_home/test_views.py index ddb22a91daf0..8722629371cc 100644 --- a/lms/djangoapps/learner_home/test_views.py +++ b/lms/djangoapps/learner_home/test_views.py @@ -98,11 +98,8 @@ def test_link_with_new_catalog_page(self, catalog_mfe_enabled, expected_catalog_ """ Test that the catalog link is constructed correctly based on the MFE flags. """ - features = settings.FEATURES.copy() - features['ENABLE_CATALOG_MICROFRONTEND'] = catalog_mfe_enabled - with override_settings(FEATURES=features): - actual_course_sharing_link = get_platform_settings()["courseSearchUrl"] - assert actual_course_sharing_link == expected_catalog_link + with override_settings(ENABLE_CATALOG_MICROFRONTEND=catalog_mfe_enabled): + assert get_platform_settings()["courseSearchUrl"] == expected_catalog_link @ddt.ddt From 02b87247a1cb2aae8b037604cf51dad15ff49dc6 Mon Sep 17 00:00:00 2001 From: Serhii Nanai Date: Mon, 29 Sep 2025 14:34:44 +0300 Subject: [PATCH 09/12] refactor: move filter out of if, extract about_base_url --- common/djangoapps/util/course.py | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/common/djangoapps/util/course.py b/common/djangoapps/util/course.py index 0e20736eb0a1..abef18a3263d 100644 --- a/common/djangoapps/util/course.py +++ b/common/djangoapps/util/course.py @@ -51,24 +51,25 @@ def get_link_for_about_page(course): 'SOCIAL_SHARING_SETTINGS', getattr(settings, 'SOCIAL_SHARING_SETTINGS', {}) ).get('CUSTOM_COURSE_URLS') + if use_catalog_mfe(): - course_about_url = f'{settings.CATALOG_MICROFRONTEND_URL}/courses/{course.id}/about' - elif is_social_sharing_enabled and course.social_sharing_url: + about_base_url = settings.CATALOG_MICROFRONTEND_URL + else: + about_base_url = configuration_helpers.get_value('LMS_ROOT_URL', settings.LMS_ROOT_URL) + + if is_social_sharing_enabled and course.social_sharing_url: course_about_url = course.social_sharing_url elif settings.FEATURES.get('ENABLE_MKTG_SITE') and getattr(course, 'marketing_url', None): course_about_url = course.marketing_url else: - course_about_url = '{about_base_url}/courses/{course_key}/about'.format( - about_base_url=configuration_helpers.get_value('LMS_ROOT_URL', settings.LMS_ROOT_URL), - course_key=str(course.id), - ) - - ## .. filter_implemented_name: CourseAboutPageURLRequested - ## .. filter_type: org.openedx.learning.course_about.page.url.requested.v1 - course_about_url, _ = CourseAboutPageURLRequested.run_filter( - url=course_about_url, - org=course.id.org, - ) + course_about_url = f'{about_base_url}/courses/{course.id}/about' + + ## .. filter_implemented_name: CourseAboutPageURLRequested + ## .. filter_type: org.openedx.learning.course_about.page.url.requested.v1 + course_about_url, _ = CourseAboutPageURLRequested.run_filter( + url=course_about_url, + org=course.id.org, + ) return course_about_url From e2d50f5b4d14d3768cd68468ef4e0ea17272e97d Mon Sep 17 00:00:00 2001 From: Serhii Nanai Date: Mon, 29 Sep 2025 14:47:22 +0300 Subject: [PATCH 10/12] test: fix ENABLE_CATALOG_MICROFRONTEND look up in tests --- common/djangoapps/util/tests/test_course.py | 2 +- lms/djangoapps/branding/test_toggles.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/common/djangoapps/util/tests/test_course.py b/common/djangoapps/util/tests/test_course.py index a4fd4de595bf..c527ffe886b7 100644 --- a/common/djangoapps/util/tests/test_course.py +++ b/common/djangoapps/util/tests/test_course.py @@ -53,11 +53,11 @@ def get_course_sharing_link(self, enable_social_sharing, enable_mktg_site, use_o mock_settings = { 'FEATURES': { 'ENABLE_MKTG_SITE': enable_mktg_site, - 'ENABLE_CATALOG_MICROFRONTEND': False, }, 'SOCIAL_SHARING_SETTINGS': { 'CUSTOM_COURSE_URLS': enable_social_sharing }, + 'ENABLE_CATALOG_MICROFRONTEND': False } with mock.patch.multiple('django.conf.settings', **mock_settings): diff --git a/lms/djangoapps/branding/test_toggles.py b/lms/djangoapps/branding/test_toggles.py index 92bde93a7108..a6797b80909b 100644 --- a/lms/djangoapps/branding/test_toggles.py +++ b/lms/djangoapps/branding/test_toggles.py @@ -19,5 +19,5 @@ def test_use_catalog_mfe(self, enabled): """ Test the use_catalog_mfe toggle. """ - with override_settings(FEATURES={'ENABLE_CATALOG_MICROFRONTEND': enabled}): + with override_settings(ENABLE_CATALOG_MICROFRONTEND=enabled): assert use_catalog_mfe() == enabled From 13f450ff29ac1c85dc0ffcea0eb19970b2aafc9b Mon Sep 17 00:00:00 2001 From: Serhii Nanai Date: Mon, 29 Sep 2025 15:03:41 +0300 Subject: [PATCH 11/12] fix: use getattr in use_catalog_mfe --- lms/djangoapps/branding/toggles.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lms/djangoapps/branding/toggles.py b/lms/djangoapps/branding/toggles.py index a69afb9f1466..c981bbe30b30 100644 --- a/lms/djangoapps/branding/toggles.py +++ b/lms/djangoapps/branding/toggles.py @@ -11,5 +11,5 @@ def use_catalog_mfe(): Returns a boolean = true if the Catalog MFE is enabled. """ return configuration_helpers.get_value( - 'ENABLE_CATALOG_MICROFRONTEND', settings.ENABLE_CATALOG_MICROFRONTEND + 'ENABLE_CATALOG_MICROFRONTEND', getattr(settings, 'ENABLE_CATALOG_MICROFRONTEND', False) ) From cb4dcb02bdd89b0ab4f1a5251b623b58dd37c94b Mon Sep 17 00:00:00 2001 From: Serhii Nanai Date: Mon, 29 Sep 2025 15:26:41 +0300 Subject: [PATCH 12/12] test: fix test overrides --- common/djangoapps/util/tests/test_course.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/common/djangoapps/util/tests/test_course.py b/common/djangoapps/util/tests/test_course.py index c527ffe886b7..f0baf5581479 100644 --- a/common/djangoapps/util/tests/test_course.py +++ b/common/djangoapps/util/tests/test_course.py @@ -56,14 +56,14 @@ def get_course_sharing_link(self, enable_social_sharing, enable_mktg_site, use_o }, 'SOCIAL_SHARING_SETTINGS': { 'CUSTOM_COURSE_URLS': enable_social_sharing - }, - 'ENABLE_CATALOG_MICROFRONTEND': False + } } - with mock.patch.multiple('django.conf.settings', **mock_settings): - course_sharing_link = get_link_for_about_page( - self.course_overview if use_overview else self.course - ) + with override_settings(ENABLE_CATALOG_MICROFRONTEND=False): + with mock.patch.multiple('django.conf.settings', **mock_settings): + course_sharing_link = get_link_for_about_page( + self.course_overview if use_overview else self.course + ) return course_sharing_link