-
Notifications
You must be signed in to change notification settings - Fork 722
Fix single perspective icon and text in NavHeader #16663
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,9 +1,20 @@ | ||||||
| import { screen, waitForElementToBeRemoved } from '@testing-library/react'; | ||||||
| import userEvent from '@testing-library/user-event'; | ||||||
| import { renderWithProviders } from '@console/shared/src/test-utils/unit-test-utils'; | ||||||
| import type { Perspective } from '@console/shared/src/utils/override-perspectives'; | ||||||
| import { PerspectiveVisibilityState } from '@console/shared/src/utils/override-perspectives'; | ||||||
| import NavHeader from '../NavHeader'; | ||||||
| import { renderWithPerspective } from './navTestUtils'; | ||||||
|
|
||||||
| let mockOverridePerspectives: Perspective[]; | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win Correct the type of The variable is typed as 🔧 Proposed fix-let mockOverridePerspectives: Perspective[];
+let mockOverridePerspectives: Perspective[] | undefined;📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||
|
|
||||||
| jest.mock('@console/shared/src/utils/override-perspectives', () => ({ | ||||||
| ...jest.requireActual('@console/shared/src/utils/override-perspectives'), | ||||||
| get overridePerspectives() { | ||||||
| return mockOverridePerspectives; | ||||||
| }, | ||||||
| })); | ||||||
|
|
||||||
| jest.mock('@console/internal/components/utils/async', () => ({ | ||||||
| AsyncComponent: () => null, | ||||||
| })); | ||||||
|
|
@@ -89,14 +100,14 @@ describe('NavHeader', () => { | |||||
|
|
||||||
| describe('when only one perspective is available', () => { | ||||||
| beforeEach(() => { | ||||||
| window.SERVER_FLAGS.perspectives = JSON.stringify([ | ||||||
| { id: 'admin', visibility: { state: 'Enabled' } }, | ||||||
| { id: 'dev', visibility: { state: 'Disabled' } }, | ||||||
| ]); | ||||||
| mockOverridePerspectives = [ | ||||||
| { id: 'admin', visibility: { state: PerspectiveVisibilityState.Enabled } }, | ||||||
| { id: 'dev', visibility: { state: PerspectiveVisibilityState.Disabled } }, | ||||||
| ]; | ||||||
| }); | ||||||
|
|
||||||
| afterEach(() => { | ||||||
| delete window.SERVER_FLAGS.perspectives; | ||||||
| mockOverridePerspectives = undefined; | ||||||
| }); | ||||||
|
|
||||||
| it('should render static label instead of dropdown', () => { | ||||||
|
|
@@ -109,14 +120,14 @@ describe('NavHeader', () => { | |||||
|
|
||||||
| describe('when all perspectives are disabled', () => { | ||||||
| beforeEach(() => { | ||||||
| window.SERVER_FLAGS.perspectives = JSON.stringify([ | ||||||
| { id: 'admin', visibility: { state: 'Disabled' } }, | ||||||
| { id: 'dev', visibility: { state: 'Disabled' } }, | ||||||
| ]); | ||||||
| mockOverridePerspectives = [ | ||||||
| { id: 'admin', visibility: { state: PerspectiveVisibilityState.Disabled } }, | ||||||
| { id: 'dev', visibility: { state: PerspectiveVisibilityState.Disabled } }, | ||||||
| ]; | ||||||
| }); | ||||||
|
|
||||||
| afterEach(() => { | ||||||
| delete window.SERVER_FLAGS.perspectives; | ||||||
| mockOverridePerspectives = undefined; | ||||||
| }); | ||||||
|
|
||||||
| it('should fall back to static label for admin perspective', () => { | ||||||
|
|
||||||
Uh oh!
There was an error while loading. Please reload this page.