feat: [AXM-2056] add catalog MFE enabled waffle flag (#2639)
* feat: [AXM-2056] add catalog MFE enabled waffle flag * test: cover waffle with test * refactor: fix pylint error * refactor: redesign waffleflag & add new MFE toggle to FEATURES * test: update tests to new functionality * refactor: add toggle_use_cases to annotation * refactor: redesign again to use new approach * refactor: rename waffle flag variable & update description --------- Co-authored-by: Andrii <andrii.hantkovskyi@raccoongang.com>
This commit is contained in:
committed by
Sarina Canelake
parent
31218a5681
commit
19014463b1
30
lms/djangoapps/branding/test_toggles.py
Normal file
30
lms/djangoapps/branding/test_toggles.py
Normal file
@@ -0,0 +1,30 @@
|
||||
"""
|
||||
Tests for toggles, where there is logic beyond enable/disable.
|
||||
"""
|
||||
|
||||
from unittest.mock import patch
|
||||
import ddt
|
||||
from django.test import TestCase
|
||||
|
||||
from lms.djangoapps.branding.toggles import use_new_catalog_page
|
||||
|
||||
|
||||
@ddt.ddt
|
||||
class TestBrandingToggles(TestCase):
|
||||
"""
|
||||
Tests for toggles, where there is logic beyond enable/disable.
|
||||
"""
|
||||
|
||||
@ddt.data(True, False)
|
||||
@patch("lms.djangoapps.branding.toggles.ENABLE_NEW_CATALOG_PAGE")
|
||||
def test_use_new_catalog_page_enabled(
|
||||
self, is_waffle_enabled, mock_enable_new_catalog_page
|
||||
):
|
||||
# Given legacy catalog feature is / not enabled
|
||||
mock_enable_new_catalog_page.is_enabled.return_value = is_waffle_enabled
|
||||
|
||||
# When I check if the feature is enabled
|
||||
should_use_new_catalog_page = use_new_catalog_page()
|
||||
|
||||
# Then I respects waffle setting.
|
||||
self.assertEqual(should_use_new_catalog_page, is_waffle_enabled)
|
||||
36
lms/djangoapps/branding/toggles.py
Normal file
36
lms/djangoapps/branding/toggles.py
Normal file
@@ -0,0 +1,36 @@
|
||||
"""
|
||||
Configuration for features of Branding
|
||||
"""
|
||||
from django.conf import settings
|
||||
from edx_toggles.toggles import WaffleFlag
|
||||
|
||||
from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers
|
||||
|
||||
# Namespace for Waffle flags related to branding
|
||||
WAFFLE_FLAG_NAMESPACE = "new_catalog_mfe"
|
||||
|
||||
|
||||
def catalog_mfe_enabled():
|
||||
"""
|
||||
Determine if Catalog MFE is enabled, replacing student_dashboard
|
||||
"""
|
||||
return configuration_helpers.get_value(
|
||||
'ENABLE_CATALOG_MICROFRONTEND', settings.FEATURES.get('ENABLE_CATALOG_MICROFRONTEND')
|
||||
)
|
||||
|
||||
|
||||
# .. toggle_name: new_catalog_mfe.use_new_catalog_page
|
||||
# .. toggle_implementation: WaffleFlag
|
||||
# .. toggle_default: False
|
||||
# .. toggle_description: Set to True to enable the new catalog page.
|
||||
# .. toggle_creation_date: 2025-05-15
|
||||
# .. toggle_target_removal_date: None
|
||||
# .. toggle_use_cases: open_edx
|
||||
ENABLE_NEW_CATALOG_PAGE = WaffleFlag(f'{WAFFLE_FLAG_NAMESPACE}.use_new_catalog_page', __name__)
|
||||
|
||||
|
||||
def use_new_catalog_page():
|
||||
"""
|
||||
Returns a boolean if new catalog page should be used.
|
||||
"""
|
||||
return ENABLE_NEW_CATALOG_PAGE.is_enabled()
|
||||
@@ -881,6 +881,15 @@ FEATURES = {
|
||||
# toggle does not have a target removal date.
|
||||
'ENABLE_AUTHN_MICROFRONTEND': os.environ.get("EDXAPP_ENABLE_AUTHN_MFE", False),
|
||||
|
||||
# .. toggle_name: FEATURES['ENABLE_CATALOG_MICROFRONTEND']
|
||||
# .. toggle_implementation: DjangoSetting
|
||||
# .. toggle_default: False
|
||||
# .. toggle_description: Supports staged rollout of a new micro-frontend-based implementation of the catalog.
|
||||
# .. toggle_use_cases: temporary, open_edx
|
||||
# .. toggle_creation_date: 2025-05-15
|
||||
# .. toggle_target_removal_date: None
|
||||
'ENABLE_CATALOG_MICROFRONTEND': os.environ.get("EDXAPP_ENABLE_CATALOG_MFE", False),
|
||||
|
||||
### ORA Feature Flags ###
|
||||
# .. toggle_name: FEATURES['ENABLE_ORA_ALL_FILE_URLS']
|
||||
# .. toggle_implementation: DjangoSetting
|
||||
|
||||
@@ -552,6 +552,7 @@ FEATURES:
|
||||
ENABLE_API_DOCS: true
|
||||
ENABLE_ASYNC_ANSWER_DISTRIBUTION: true
|
||||
ENABLE_AUTHN_MICROFRONTEND: true
|
||||
ENABLE_CATALOG_MICROFRONTEND: true
|
||||
ENABLE_AUTO_GENERATED_USERNAME: true
|
||||
ENABLE_BULK_USER_RETIREMENT: true
|
||||
ENABLE_CERTIFICATES_IDV_REQUIREMENT: true
|
||||
|
||||
Reference in New Issue
Block a user