Merge pull request #27518 from eduNEXT/eric/enable_account_mfe_globally
refactor: Using Waffle flag to enable Account MFE globally.
This commit is contained in:
@@ -241,20 +241,31 @@ class AccountSettingsViewTest(ThirdPartyAuthTestMixin, SiteMixin, ProgramsApiCon
|
||||
assert len(order_detail) == 1
|
||||
|
||||
def test_redirect_view(self):
|
||||
old_url_path = reverse('account_settings')
|
||||
with override_waffle_flag(REDIRECT_TO_ACCOUNT_MICROFRONTEND, active=True):
|
||||
old_url_path = reverse('account_settings')
|
||||
|
||||
# Test with waffle flag active and site setting disabled, does not redirect
|
||||
response = self.client.get(path=old_url_path)
|
||||
for attribute in self.FIELDS:
|
||||
self.assertContains(response, attribute)
|
||||
|
||||
# Test with waffle flag active and site setting enabled, redirects to microfrontend
|
||||
site_domain = 'othersite.example.com'
|
||||
self.set_up_site(site_domain, {
|
||||
'SITE_NAME': site_domain,
|
||||
'ENABLE_ACCOUNT_MICROFRONTEND': True
|
||||
})
|
||||
self.client.login(username=self.USERNAME, password=self.PASSWORD)
|
||||
# Test with waffle flag active and none site setting, redirects to microfrontend
|
||||
response = self.client.get(path=old_url_path)
|
||||
self.assertRedirects(response, settings.ACCOUNT_MICROFRONTEND_URL, fetch_redirect_response=False)
|
||||
|
||||
# Test with waffle flag disabled and site setting disabled, does not redirect
|
||||
response = self.client.get(path=old_url_path)
|
||||
for attribute in self.FIELDS:
|
||||
self.assertContains(response, attribute)
|
||||
|
||||
# Test with site setting disabled, does not redirect
|
||||
site_domain = 'othersite.example.com'
|
||||
site = self.set_up_site(site_domain, {
|
||||
'SITE_NAME': site_domain,
|
||||
'ENABLE_ACCOUNT_MICROFRONTEND': False
|
||||
})
|
||||
self.client.login(username=self.USERNAME, password=self.PASSWORD)
|
||||
response = self.client.get(path=old_url_path)
|
||||
for attribute in self.FIELDS:
|
||||
self.assertContains(response, attribute)
|
||||
|
||||
# Test with site setting enabled, redirects to microfrontend
|
||||
site.configuration.site_values['ENABLE_ACCOUNT_MICROFRONTEND'] = True
|
||||
site.configuration.save()
|
||||
site.__class__.objects.clear_cache()
|
||||
response = self.client.get(path=old_url_path)
|
||||
self.assertRedirects(response, settings.ACCOUNT_MICROFRONTEND_URL, fetch_redirect_response=False)
|
||||
|
||||
@@ -29,16 +29,15 @@ def should_redirect_to_order_history_microfrontend():
|
||||
# .. toggle_implementation: WaffleFlag
|
||||
# .. toggle_default: False
|
||||
# .. toggle_description: Supports staged rollout of a new micro-frontend-based implementation of the account page.
|
||||
# Its action can be overridden using site's ENABLE_ACCOUNT_MICROFRONTEND setting.
|
||||
# .. toggle_use_cases: temporary, open_edx
|
||||
# .. toggle_creation_date: 2019-04-30
|
||||
# .. toggle_target_removal_date: 2020-12-31
|
||||
# .. toggle_warnings: Also set settings.ACCOUNT_MICROFRONTEND_URL and site's ENABLE_ACCOUNT_MICROFRONTEND.
|
||||
# .. toggle_target_removal_date: 2021-12-31
|
||||
# .. toggle_warnings: Also set settings.ACCOUNT_MICROFRONTEND_URL.
|
||||
# .. toggle_tickets: DEPR-17
|
||||
REDIRECT_TO_ACCOUNT_MICROFRONTEND = LegacyWaffleFlag('account', 'redirect_to_microfrontend', __name__)
|
||||
|
||||
|
||||
def should_redirect_to_account_microfrontend():
|
||||
return (
|
||||
configuration_helpers.get_value('ENABLE_ACCOUNT_MICROFRONTEND') and
|
||||
REDIRECT_TO_ACCOUNT_MICROFRONTEND.is_enabled()
|
||||
)
|
||||
return configuration_helpers.get_value('ENABLE_ACCOUNT_MICROFRONTEND',
|
||||
REDIRECT_TO_ACCOUNT_MICROFRONTEND.is_enabled())
|
||||
|
||||
Reference in New Issue
Block a user