@@ -297,6 +297,45 @@ def side_effect(key, default=None):
297297 # Value in original MFE_CONFIG not overridden by catalog config should be preserved
298298 self .assertEqual (data ["PRESERVED_SETTING" ], "preserved" ) # noqa: PT009
299299
300+ @patch ("lms.djangoapps.mfe_config_api.views.configuration_helpers" )
301+ def test_legacy_overrides_instructor_dashboard (self , configuration_helpers_mock ):
302+ """Legacy help-tokens SUPPORT_URL is included for instructor-dashboard when no explicit override is set."""
303+ def side_effect (key , default = None ):
304+ if key == "MFE_CONFIG" :
305+ return {"LMS_BASE_URL" : "https://courses.example.com" }
306+ if key == "MFE_CONFIG_OVERRIDES" :
307+ return {}
308+ return default
309+ configuration_helpers_mock .get_value .side_effect = side_effect
310+
311+ response = self .client .get (f"{ self .mfe_config_api_url } ?mfe=instructor-dashboard" )
312+ self .assertEqual (response .status_code , status .HTTP_200_OK ) # noqa: PT009
313+ data = response .json ()
314+ self .assertEqual ( # noqa: PT009
315+ data ["SUPPORT_URL" ],
316+ "https://docs.openedx.org/en/latest/educators/index.html" ,
317+ )
318+
319+ @patch ("lms.djangoapps.mfe_config_api.views.configuration_helpers" )
320+ def test_explicit_override_wins_over_legacy_overrides (self , configuration_helpers_mock ):
321+ """An explicit SUPPORT_URL in MFE_CONFIG_OVERRIDES wins over the help-tokens fallback."""
322+ def side_effect (key , default = None ):
323+ if key == "MFE_CONFIG" :
324+ return {"LMS_BASE_URL" : "https://courses.example.com" }
325+ if key == "MFE_CONFIG_OVERRIDES" :
326+ return {
327+ "instructor-dashboard" : {
328+ "SUPPORT_URL" : "https://help.example.com/instructor" ,
329+ },
330+ }
331+ return default
332+ configuration_helpers_mock .get_value .side_effect = side_effect
333+
334+ response = self .client .get (f"{ self .mfe_config_api_url } ?mfe=instructor-dashboard" )
335+ self .assertEqual (response .status_code , status .HTTP_200_OK ) # noqa: PT009
336+ data = response .json ()
337+ self .assertEqual (data ["SUPPORT_URL" ], "https://help.example.com/instructor" ) # noqa: PT009
338+
300339
301340class MfeNameToAppIdTests (SimpleTestCase ):
302341 """Tests for the mfe_name_to_app_id helper."""
@@ -317,6 +356,12 @@ def test_mapped_alias(self):
317356 "org.openedx.frontend.app.authoring" ,
318357 )
319358
359+ def test_instructor_dashboard (self ):
360+ self .assertEqual ( # noqa: PT009
361+ mfe_name_to_app_id ("instructor-dashboard" ),
362+ "org.openedx.frontend.app.instructorDashboard" ,
363+ )
364+
320365 def test_fallback_for_unknown_name (self ):
321366 """Unknown names fall back to programmatic kebab-to-camelCase conversion."""
322367 self .assertEqual ( # noqa: PT009
@@ -420,8 +465,9 @@ def side_effect(key, default=None):
420465 for legacy_key in default_legacy_config :
421466 self .assertIn (legacy_key , common ) # noqa: PT009
422467
468+ @patch ("lms.djangoapps.mfe_config_api.views.get_legacy_config_overrides" , return_value = {})
423469 @patch ("lms.djangoapps.mfe_config_api.views.configuration_helpers" )
424- def test_apps_from_overrides (self , configuration_helpers_mock ):
470+ def test_apps_from_overrides (self , configuration_helpers_mock , _legacy_overrides_mock ): # noqa: PT019
425471 """Each MFE_CONFIG_OVERRIDES entry becomes an app with shared base config + overrides."""
426472 mfe_config_overrides = {
427473 "authn" : {
@@ -521,9 +567,10 @@ def side_effect(key, default=None):
521567 self .assertNotIn ("BASE_URL" , data ["commonAppConfig" ]) # noqa: PT009
522568 self .assertNotIn ("LOGIN_URL" , data ["commonAppConfig" ]) # noqa: PT009
523569
570+ @patch ("lms.djangoapps.mfe_config_api.views.get_legacy_config_overrides" , return_value = {})
524571 @patch ("lms.djangoapps.mfe_config_api.views.configuration_helpers" )
525- def test_no_apps_when_no_overrides (self , configuration_helpers_mock ):
526- """The apps key is omitted when MFE_CONFIG_OVERRIDES is empty."""
572+ def test_no_apps_when_no_overrides (self , configuration_helpers_mock , _legacy_overrides_mock ): # noqa: PT019
573+ """The apps key is omitted when MFE_CONFIG_OVERRIDES is empty and no legacy overrides are present ."""
527574 def side_effect (key , default = None ):
528575 if key == "MFE_CONFIG" :
529576 return {"LMS_BASE_URL" : "https://courses.example.com" }
@@ -566,8 +613,9 @@ def side_effect(key, default=None):
566613 self .assertEqual (common ["CREDENTIALS_BASE_URL" ], "https://credentials.example.com" ) # noqa: PT009
567614 self .assertEqual (common ["STUDIO_BASE_URL" ], "https://studio.example.com" ) # noqa: PT009
568615
616+ @patch ("lms.djangoapps.mfe_config_api.views.get_legacy_config_overrides" , return_value = {})
569617 @patch ("lms.djangoapps.mfe_config_api.views.configuration_helpers" )
570- def test_invalid_override_entry_skipped (self , configuration_helpers_mock ):
618+ def test_invalid_override_entry_skipped (self , configuration_helpers_mock , _legacy_overrides_mock ): # noqa: PT019
571619 """Non-dict override entries are silently skipped."""
572620 mfe_config_overrides = {
573621 "authn" : {"SOME_KEY" : "value" },
@@ -720,3 +768,49 @@ def side_effect(key, default=None):
720768 # Brand new app from FRONTEND_SITE_CONFIG is appended
721769 brand_new = apps_by_id ["org.openedx.frontend.app.brand.new" ]["config" ]
722770 self .assertEqual (brand_new ["BRAND_NEW_KEY" ], "value" ) # noqa: PT009
771+
772+ @patch ("lms.djangoapps.mfe_config_api.views.configuration_helpers" )
773+ def test_legacy_overrides_instructor_dashboard_support_url (self , configuration_helpers_mock ):
774+ """Instructor dashboard gets SUPPORT_URL from help-tokens when no explicit override is set."""
775+ def side_effect (key , default = None ):
776+ if key == "MFE_CONFIG" :
777+ return {"LMS_BASE_URL" : "https://courses.example.com" }
778+ if key == "MFE_CONFIG_OVERRIDES" :
779+ return {}
780+ return default
781+ configuration_helpers_mock .get_value .side_effect = side_effect
782+
783+ response = self .client .get (self .url )
784+ data = response .json ()
785+
786+ apps_by_id = {app ["appId" ]: app for app in data ["apps" ]}
787+ instructor = apps_by_id ["org.openedx.frontend.app.instructorDashboard" ]
788+ self .assertEqual ( # noqa: PT009
789+ instructor ["config" ]["SUPPORT_URL" ],
790+ "https://docs.openedx.org/en/latest/educators/index.html" ,
791+ )
792+
793+ @patch ("lms.djangoapps.mfe_config_api.views.configuration_helpers" )
794+ def test_explicit_override_wins_over_legacy_overrides (self , configuration_helpers_mock ):
795+ """An explicit SUPPORT_URL in MFE_CONFIG_OVERRIDES wins over the help-tokens fallback."""
796+ def side_effect (key , default = None ):
797+ if key == "MFE_CONFIG" :
798+ return {"LMS_BASE_URL" : "https://courses.example.com" }
799+ if key == "MFE_CONFIG_OVERRIDES" :
800+ return {
801+ "instructor-dashboard" : {
802+ "SUPPORT_URL" : "https://help.example.com/instructor" ,
803+ },
804+ }
805+ return default
806+ configuration_helpers_mock .get_value .side_effect = side_effect
807+
808+ response = self .client .get (self .url )
809+ data = response .json ()
810+
811+ apps_by_id = {app ["appId" ]: app for app in data ["apps" ]}
812+ instructor = apps_by_id ["org.openedx.frontend.app.instructorDashboard" ]
813+ self .assertEqual ( # noqa: PT009
814+ instructor ["config" ]["SUPPORT_URL" ],
815+ "https://help.example.com/instructor" ,
816+ )
0 commit comments