feat: update the flag SUBSCRIPTIONS_ORDERS_MENU_ITEM_ENABLED

This commit is contained in:
Raza Dar
2023-06-16 15:35:19 +05:00
parent 322a79afaa
commit 59ab63807f
8 changed files with 13 additions and 9 deletions

1
.env
View File

@@ -40,4 +40,3 @@ ACCOUNT_SETTINGS_URL=''
ACCOUNT_PROFILE_URL=''
ENABLE_NOTICES=''
CAREER_LINK_URL=''
ENABLE_B2C_SUBSCRIPTIONS=false

View File

@@ -47,4 +47,3 @@ ACCOUNT_SETTINGS_URL='http://localhost:1997'
ACCOUNT_PROFILE_URL='http://localhost:1995'
ENABLE_NOTICES=''
CAREER_LINK_URL=''
ENABLE_B2C_SUBSCRIPTIONS=false

View File

@@ -46,4 +46,3 @@ ACCOUNT_SETTINGS_URL='http://account-settings-url.test'
ACCOUNT_PROFILE_URL='http://account-profile-url.test'
ENABLE_NOTICES=''
CAREER_LINK_URL=''
ENABLE_B2C_SUBSCRIPTIONS=false

View File

@@ -16,7 +16,6 @@ const configuration = {
SUPPORT_URL: process.env.SUPPORT_URL || null,
ENABLE_NOTICES: process.env.ENABLE_NOTICES || null,
CAREER_LINK_URL: process.env.CAREER_LINK_URL || null,
ENABLE_B2C_SUBSCRIPTIONS: process.env.ENABLE_B2C_SUBSCRIPTIONS || null,
};
const features = {};

View File

@@ -54,6 +54,13 @@ exports[`CollapseMenuBody render 1`] = `
>
Account
</Button>
<Button
as="a"
href="http://localhost:1996/orders"
variant="inverse-primary"
>
Order History
</Button>
<Button
as="a"
href="http://localhost:18000/logout"

View File

@@ -46,6 +46,7 @@ const config = {
SUPPORT_URL: 'http://localhost:18000/support',
CAREER_LINK_URL: 'http://localhost:18000/career',
LMS_BASE_URL: 'http:/localhost:18000',
SUBSCRIPTIONS_ORDERS_MENU_ITEM_ENABLED: 'false',
};
getConfig.mockReturnValue(config);

View File

@@ -8,6 +8,6 @@ export const isEnterpriseUser = () => {
return userRoleNames.includes('enterprise_learner');
};
export const showOrdersAndSubscriptionsMenuItem = () => (getConfig().ENABLE_B2C_SUBSCRIPTIONS?.toLowerCase() === 'true' && !isEnterpriseUser());
export const showOrdersAndSubscriptionsMenuItem = () => (getConfig().SUBSCRIPTIONS_ORDERS_MENU_ITEM_ENABLED?.toLowerCase() === 'true' && !isEnterpriseUser());
export default isEnterpriseUser;

View File

@@ -44,17 +44,17 @@ describe('showOrdersAndSubscriptionsMenuItem', () => {
getAuthenticatedUser.mockReset();
});
test('should return true when ENABLE_B2C_SUBSCRIPTIONS is true and isEnterpriseUser returns false', () => {
test('should return true when SUBSCRIPTIONS_ORDERS_MENU_ITEM_ENABLED is true and isEnterpriseUser returns false', () => {
getConfig.mockReturnValueOnce({
ENABLE_B2C_SUBSCRIPTIONS: 'true',
SUBSCRIPTIONS_ORDERS_MENU_ITEM_ENABLED: 'true',
});
getAuthenticatedUser.mockReturnValueOnce({ roles: [] });
expect(showOrdersAndSubscriptionsMenuItem()).toBe(true);
});
test('should return false when ENABLE_B2C_SUBSCRIPTIONS is false and isEnterpriseUser returns false', () => {
test('should return false when SUBSCRIPTIONS_ORDERS_MENU_ITEM_ENABLED is false and isEnterpriseUser returns false', () => {
getConfig.mockReturnValueOnce({
ENABLE_B2C_SUBSCRIPTIONS: 'false',
SUBSCRIPTIONS_ORDERS_MENU_ITEM_ENABLED: 'false',
});
getAuthenticatedUser.mockReturnValueOnce({ roles: ['role1', 'role2', 'role3'] });
expect(showOrdersAndSubscriptionsMenuItem()).toBe(false);