Skip to content

Commit 18509e2

Browse files
cpathipamjac0bs
andauthored
upcoming: [M3-10423], [M3-10412] - IAM: Added a new feature flag and Administration section in the Primary Nav (linode#12633)
* Added new feature flag to support PrimaryNav changes * Add Administration section to the primary Nav * Update PrimaryNav.tsx * Added changeset: Added a new feature flag and Administration section in the Primary Nav * Test coverage * disable the flag in cypress tests * Update packages/manager/.changeset/pr-12633-upcoming-features-1754346094060.md Co-authored-by: Mariah Jacobs <[email protected]> * Mock the iamRbacPrimaryNavChanges feature flag to be disabled in Cypress tests * upadate primarynav --------- Co-authored-by: Mariah Jacobs <[email protected]>
1 parent 249a860 commit 18509e2

File tree

12 files changed

+358
-146
lines changed

12 files changed

+358
-146
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@linode/manager": Upcoming Features
3+
---
4+
5+
Add a new feature flag and Administration section in the Primary Nav ([#12633](https://github.com/linode/manager/pull/12633))

packages/manager/cypress/e2e/core/account/account-maintenance.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ describe('Maintenance', () => {
2626

2727
// TODO When the Host & VM Maintenance feature rolls out, we want to enable the feature flag and update the test.
2828
mockAppendFeatureFlags({
29+
iamRbacPrimaryNavChanges: false,
2930
vmHostMaintenance: {
3031
enabled: false,
3132
},

packages/manager/cypress/e2e/core/account/service-transfer.spec.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
mockInitiateEntityTransferError,
1515
mockReceiveEntityTransfer,
1616
} from 'support/intercepts/account';
17+
import { mockAppendFeatureFlags } from 'support/intercepts/feature-flags';
1718
import { mockGetLinodes } from 'support/intercepts/linodes';
1819
import { ui } from 'support/ui';
1920
import { cleanUp } from 'support/util/cleanup';
@@ -126,6 +127,13 @@ describe('Account service transfers', () => {
126127
cleanUp(['service-transfers', 'linodes', 'lke-clusters']);
127128
});
128129

130+
beforeEach(() => {
131+
// Mock the iamRbacPrimaryNavChanges feature flag to be disabled.
132+
mockAppendFeatureFlags({
133+
iamRbacPrimaryNavChanges: false,
134+
}).as('getFeatureFlags');
135+
});
136+
129137
/*
130138
* - Confirms user can navigate to service transfer page via user menu.
131139
*/

packages/manager/cypress/e2e/core/general/smoke-deep-link.spec.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { mockAppendFeatureFlags } from 'support/intercepts/feature-flags';
12
import { pages } from 'support/ui/constants';
23

34
import type { Page } from 'support/ui/constants';
@@ -8,6 +9,10 @@ beforeEach(() => {
89
describe('smoke - deep links', () => {
910
beforeEach(() => {
1011
cy.visitWithLogin('/null');
12+
// Mock the iamRbacPrimaryNavChanges feature flag to be disabled.
13+
mockAppendFeatureFlags({
14+
iamRbacPrimaryNavChanges: false,
15+
}).as('getFeatureFlags');
1116
});
1217

1318
it('Go to each route and validate deep links', () => {

packages/manager/cypress/e2e/core/linodes/smoke-delete-linode.spec.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { createLinodeRequestFactory } from '@linode/utilities';
22
import { accountSettingsFactory } from '@src/factories/accountSettings';
33
import { authenticate } from 'support/api/authentication';
44
import { mockGetAccountSettings } from 'support/intercepts/account';
5+
import { mockAppendFeatureFlags } from 'support/intercepts/feature-flags';
56
import { interceptDeleteLinode } from 'support/intercepts/linodes';
67
import { ui } from 'support/ui';
78
import { cleanUp } from 'support/util/cleanup';
@@ -65,6 +66,9 @@ describe('delete linode', () => {
6566
});
6667
beforeEach(() => {
6768
cy.tag('method:e2e');
69+
mockAppendFeatureFlags({
70+
iamRbacPrimaryNavChanges: false,
71+
}).as('getFeatureFlags');
6872
});
6973

7074
it('deletes linode from linode details page', () => {

packages/manager/cypress/e2e/core/linodes/smoke-linode-landing-table.spec.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,10 @@ const preferenceOverrides = {
6969
authenticate();
7070
describe('linode landing checks', () => {
7171
beforeEach(() => {
72+
// Mock the iamRbacPrimaryNavChanges feature flag to be disabled.
73+
mockAppendFeatureFlags({
74+
iamRbacPrimaryNavChanges: false,
75+
});
7276
const mockAccountSettings = accountSettingsFactory.build({
7377
managed: false,
7478
});
@@ -470,6 +474,10 @@ describe('linode landing checks', () => {
470474

471475
describe('linode landing checks for empty state', () => {
472476
beforeEach(() => {
477+
// Mock the iamRbacPrimaryNavChanges feature flag to be disabled.
478+
mockAppendFeatureFlags({
479+
iamRbacPrimaryNavChanges: false,
480+
});
473481
// Mock setup to display the Linode landing page in an empty state
474482
mockGetLinodes([]).as('getLinodes');
475483
});
@@ -572,6 +580,10 @@ describe('linode landing checks for empty state', () => {
572580

573581
describe('linode landing checks for non-empty state with restricted user', () => {
574582
beforeEach(() => {
583+
// Mock the iamRbacPrimaryNavChanges feature flag to be disabled.
584+
mockAppendFeatureFlags({
585+
iamRbacPrimaryNavChanges: false,
586+
});
575587
// Mock setup to display the Linode landing page in an non-empty state
576588
const mockLinodes: Linode[] = new Array(1)
577589
.fill(null)

packages/manager/cypress/e2e/core/notificationsAndEvents/qemu-reboot-upgrade-notice.spec.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { notificationFactory } from '@src/factories/notification';
88
import { mockGetAccount, mockGetMaintenance } from 'support/intercepts/account';
99
import { mockGetLinodeConfigs } from 'support/intercepts/configs';
1010
import { mockGetNotifications } from 'support/intercepts/events';
11+
import { mockAppendFeatureFlags } from 'support/intercepts/feature-flags';
1112
import {
1213
mockGetLinodeDetails,
1314
mockGetLinodes,
@@ -30,6 +31,11 @@ import { formatDate } from 'src/utilities/formatDate';
3031
import type { Notification } from '@linode/api-v4';
3132

3233
describe('QEMU reboot upgrade notification', () => {
34+
beforeEach(() => {
35+
mockAppendFeatureFlags({
36+
iamRbacPrimaryNavChanges: false,
37+
}).as('getFeatureFlags');
38+
});
3339
const NOTIFICATION_BANNER_TEXT = 'critical platform maintenance';
3440
const noticeMessageShort =
3541
'One or more Linodes need to be rebooted for critical platform maintenance.';
Lines changed: 4 additions & 0 deletions
Loading

packages/manager/src/components/PrimaryNav/PrimaryNav.test.tsx

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { queryClientFactory } from '@linode/queries';
2+
import { screen, waitFor } from '@testing-library/react';
23
import * as React from 'react';
34

45
import { accountFactory } from 'src/factories';
@@ -331,4 +332,115 @@ describe('PrimaryNav', () => {
331332
expect(monitorAlertsDisplayItem).toBeNull();
332333
expect(betaChip).toBeVisible();
333334
});
335+
336+
it('should show Administration links if iamRbacPrimaryNavChanges flag is enabled', async () => {
337+
const flags: Partial<Flags> = {
338+
iamRbacPrimaryNavChanges: true,
339+
iam: {
340+
beta: true,
341+
enabled: true,
342+
},
343+
};
344+
345+
queryMocks.useIsIAMEnabled.mockReturnValue({
346+
isIAMBeta: true,
347+
isIAMEnabled: true,
348+
});
349+
350+
renderWithTheme(<PrimaryNav {...props} />, {
351+
flags,
352+
});
353+
354+
const adminLink = screen.getByRole('button', { name: 'Administration' });
355+
expect(adminLink).toBeInTheDocument();
356+
357+
await waitFor(() => {
358+
expect(screen.getByRole('link', { name: 'Billing' })).toBeInTheDocument();
359+
expect(
360+
screen.getByRole('link', { name: 'Identity & Access' })
361+
).toBeInTheDocument();
362+
expect(screen.getByRole('link', { name: 'Quotas' })).toBeInTheDocument();
363+
expect(
364+
screen.getByRole('link', { name: 'Login History' })
365+
).toBeInTheDocument();
366+
expect(
367+
screen.getByRole('link', { name: 'Service Transfers' })
368+
).toBeInTheDocument();
369+
expect(
370+
screen.getByRole('link', { name: 'Maintenance' })
371+
).toBeInTheDocument();
372+
expect(
373+
screen.getByRole('link', { name: 'Settings' })
374+
).toBeInTheDocument();
375+
expect(screen.queryByRole('link', { name: 'Account' })).toBeNull();
376+
});
377+
});
378+
379+
it('should hide Identity & Access link for non beta users', async () => {
380+
const flags: Partial<Flags> = {
381+
iamRbacPrimaryNavChanges: true,
382+
iam: {
383+
beta: true,
384+
enabled: false,
385+
},
386+
};
387+
388+
queryMocks.useIsIAMEnabled.mockReturnValue({
389+
isIAMBeta: true,
390+
isIAMEnabled: false,
391+
});
392+
393+
renderWithTheme(<PrimaryNav {...props} />, {
394+
flags,
395+
});
396+
397+
const adminLink = screen.getByRole('button', { name: 'Administration' });
398+
expect(adminLink).toBeInTheDocument();
399+
400+
await waitFor(() => {
401+
expect(
402+
screen.queryByRole('link', { name: 'Identity & Access' })
403+
).toBeNull();
404+
});
405+
});
406+
407+
it('should show Account link and hide Administration if iamRbacPrimaryNavChanges flag is disabled', async () => {
408+
const flags: Partial<Flags> = {
409+
iamRbacPrimaryNavChanges: false,
410+
iam: {
411+
beta: true,
412+
enabled: true,
413+
},
414+
};
415+
416+
queryMocks.useIsIAMEnabled.mockReturnValue({
417+
isIAMBeta: true,
418+
isIAMEnabled: true,
419+
});
420+
421+
renderWithTheme(<PrimaryNav {...props} />, {
422+
flags,
423+
});
424+
425+
const adminLink = screen.queryByRole('button', { name: 'Administration' });
426+
expect(adminLink).toBeNull();
427+
428+
await waitFor(() => {
429+
expect(screen.queryByRole('link', { name: 'Billing' })).toBeNull();
430+
expect(screen.queryByRole('link', { name: 'Quotas' })).toBeNull();
431+
expect(screen.queryByRole('link', { name: 'Login History' })).toBeNull();
432+
expect(
433+
screen.queryByRole('link', { name: 'Service Transfers' })
434+
).toBeNull();
435+
expect(screen.queryByRole('link', { name: 'Maintenance' })).toBeNull();
436+
expect(screen.queryByRole('link', { name: 'Settings' })).toBeNull();
437+
expect(
438+
screen.queryByRole('link', { name: 'Account' })
439+
).toBeInTheDocument();
440+
expect(
441+
screen.queryByRole('link', { name: 'Identity & Access' })
442+
).toBeInTheDocument();
443+
expect(screen.queryByRole('link', { name: 'Settings' })).toBeNull();
444+
});
445+
});
334446
});

0 commit comments

Comments
 (0)