Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -241,20 +241,31 @@ def test_order_history_with_no_product(self):
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)
11 changes: 5 additions & 6 deletions openedx/core/djangoapps/user_api/accounts/toggles.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())