-
Notifications
You must be signed in to change notification settings - Fork 365
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: [M3-8059] - Clean up Main Content Banner (#10430)
* clean up main content banner * remove old tests and add changeset * fix test name --------- Co-authored-by: Banks Nussman <banks@nussman.us>
- Loading branch information
1 parent
8a37043
commit 020e084
Showing
5 changed files
with
230 additions
and
242 deletions.
There are no files selected for viewing
5 changes: 5 additions & 0 deletions
5
packages/manager/.changeset/pr-10430-tech-stories-1714594879053.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@linode/manager": Tech Stories | ||
--- | ||
|
||
Clean up Main Content Banner ([#10430](https://github.com/linode/manager/pull/10430)) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
82 changes: 82 additions & 0 deletions
82
packages/manager/src/components/MainContentBanner.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
import { waitFor } from '@testing-library/react'; | ||
import { userEvent } from '@testing-library/user-event'; | ||
import React from 'react'; | ||
|
||
import { HttpResponse, http, server } from 'src/mocks/testServer'; | ||
import { renderWithTheme } from 'src/utilities/testHelpers'; | ||
|
||
import { MainContentBanner } from './MainContentBanner'; | ||
|
||
import type { ManagerPreferences } from 'src/types/ManagerPreferences'; | ||
|
||
describe('MainContentBanner', () => { | ||
const mainContentBanner = { | ||
key: 'test-banner-1', | ||
link: { | ||
text: 'Learn more.', | ||
url: 'https://akamai.com', | ||
}, | ||
text: 'Linode is now Akamai 🤯', | ||
}; | ||
|
||
it('should render a banner from feature flags', () => { | ||
const { getByText } = renderWithTheme(<MainContentBanner />, { | ||
flags: { mainContentBanner }, | ||
}); | ||
|
||
expect(getByText('Linode is now Akamai 🤯')).toBeVisible(); | ||
}); | ||
|
||
it('should render a link from feature flags', () => { | ||
const { getByText } = renderWithTheme(<MainContentBanner />, { | ||
flags: { mainContentBanner }, | ||
}); | ||
|
||
const link = getByText('Learn more.'); | ||
|
||
expect(link).toBeVisible(); | ||
expect(link).toBeEnabled(); | ||
expect(link).toHaveRole('link'); | ||
expect(link).toHaveAttribute('href', 'https://akamai.com'); | ||
}); | ||
|
||
it('should be dismissable', async () => { | ||
const { container, getByLabelText } = renderWithTheme( | ||
<MainContentBanner />, | ||
{ | ||
flags: { mainContentBanner }, | ||
} | ||
); | ||
|
||
const closeButton = getByLabelText('Close'); | ||
|
||
expect(closeButton).toBeVisible(); | ||
expect(closeButton).toBeEnabled(); | ||
|
||
await userEvent.click(closeButton); | ||
|
||
expect(container).toBeEmptyDOMElement(); | ||
}); | ||
|
||
it('should not render if the user dismissed the banner', async () => { | ||
const preferences: ManagerPreferences = { | ||
main_content_banner_dismissal: { | ||
'test-banner-1': true, | ||
}, | ||
}; | ||
|
||
server.use( | ||
http.get('*/v4/profile/preferences', () => { | ||
return HttpResponse.json(preferences); | ||
}) | ||
); | ||
|
||
const { container } = renderWithTheme(<MainContentBanner />, { | ||
flags: { mainContentBanner }, | ||
}); | ||
|
||
await waitFor(() => { | ||
expect(container).toBeEmptyDOMElement(); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.