-
Notifications
You must be signed in to change notification settings - Fork 163
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(fuselage): Avoid duplicated alert on ToastBar (#1324)
- Loading branch information
1 parent
9ccc4e7
commit 8f45029
Showing
4 changed files
with
206 additions
and
15 deletions.
There are no files selected for viewing
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 @@ | ||
--- | ||
"@rocket.chat/fuselage": patch | ||
--- | ||
|
||
fix(fuselage): Avoid duplicated alert on ToastBar |
33 changes: 23 additions & 10 deletions
33
packages/fuselage/src/components/ToastBar/ToastBar.spec.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 |
---|---|---|
@@ -1,18 +1,31 @@ | ||
import { composeStories } from '@storybook/testing-react'; | ||
import { render } from '@testing-library/react'; | ||
import { axe } from 'jest-axe'; | ||
import React from 'react'; | ||
|
||
import { ToastBar } from '.'; | ||
import * as stories from './ToastBar.stories'; | ||
|
||
describe('[ToastBar Component]', () => { | ||
it('renders without crashing', () => { | ||
render(<ToastBar />); | ||
}); | ||
const testCases = Object.values(composeStories(stories)).map((Story) => [ | ||
Story.storyName || 'Story', | ||
Story, | ||
]); | ||
|
||
it('should have no a11y violations', async () => { | ||
const { container } = render(<ToastBar />); | ||
describe('[ToastBar Rendering]', () => { | ||
test.each(testCases)( | ||
`renders %s without crashing`, | ||
async (_storyname, Story) => { | ||
const tree = render(<Story />); | ||
expect(tree.baseElement).toMatchSnapshot(); | ||
} | ||
); | ||
|
||
const results = await axe(container); | ||
expect(results).toHaveNoViolations(); | ||
}); | ||
test.each(testCases)( | ||
'%s should have no a11y violations', | ||
async (_storyname, Story) => { | ||
const { container } = render(<Story />); | ||
|
||
const results = await axe(container); | ||
expect(results).toHaveNoViolations(); | ||
} | ||
); | ||
}); |
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
175 changes: 175 additions & 0 deletions
175
packages/fuselage/src/components/ToastBar/__snapshots__/ToastBar.spec.tsx.snap
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,175 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`[ToastBar Rendering] renders Default without crashing 1`] = ` | ||
<body> | ||
<div> | ||
<div | ||
class="rcx-box rcx-box--full rcx-css-fnyeze rcx-toastbar rcx-toastbar--info rcx-css-n4l2cd" | ||
> | ||
<div | ||
class="rcx-toastbar_inner" | ||
> | ||
<i | ||
aria-hidden="true" | ||
class="rcx-box rcx-box--full rcx-icon--name-info rcx-icon rcx-toastbar_icon--info rcx-css-4pvxx3" | ||
> | ||
| ||
</i> | ||
<div | ||
class="rcx-toastbar_content" | ||
role="alert" | ||
> | ||
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod | ||
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, | ||
quis nostrud exercitation ullamco | ||
</div> | ||
</div> | ||
<div | ||
class="rcx-box rcx-box--full rcx-css-1rc3wl5 rcx-toastbar_progressbar" | ||
/> | ||
</div> | ||
</div> | ||
</body> | ||
`; | ||
|
||
exports[`[ToastBar Rendering] renders Error without crashing 1`] = ` | ||
<body> | ||
<div> | ||
<div | ||
class="rcx-box rcx-box--full rcx-css-fnyeze rcx-toastbar rcx-toastbar--error rcx-css-n4l2cd" | ||
> | ||
<div | ||
class="rcx-toastbar_inner" | ||
> | ||
<i | ||
aria-hidden="true" | ||
class="rcx-box rcx-box--full rcx-icon--name-ban rcx-icon rcx-toastbar_icon--error rcx-css-4pvxx3" | ||
> | ||
| ||
</i> | ||
<div | ||
class="rcx-toastbar_content" | ||
role="alert" | ||
> | ||
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod | ||
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, | ||
quis nostrud exercitation ullamco | ||
</div> | ||
</div> | ||
<div | ||
class="rcx-box rcx-box--full rcx-css-1rc3wl5 rcx-toastbar_progressbar" | ||
/> | ||
</div> | ||
</div> | ||
</body> | ||
`; | ||
|
||
exports[`[ToastBar Rendering] renders Success without crashing 1`] = ` | ||
<body> | ||
<div> | ||
<div | ||
class="rcx-box rcx-box--full rcx-css-fnyeze rcx-toastbar rcx-toastbar--success rcx-css-n4l2cd" | ||
> | ||
<div | ||
class="rcx-toastbar_inner" | ||
> | ||
<i | ||
aria-hidden="true" | ||
class="rcx-box rcx-box--full rcx-icon--name-circle-check rcx-icon rcx-toastbar_icon--success rcx-css-4pvxx3" | ||
> | ||
| ||
</i> | ||
<div | ||
class="rcx-toastbar_content" | ||
role="alert" | ||
> | ||
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod | ||
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, | ||
quis nostrud exercitation ullamco | ||
</div> | ||
</div> | ||
<div | ||
class="rcx-box rcx-box--full rcx-css-1rc3wl5 rcx-toastbar_progressbar" | ||
/> | ||
</div> | ||
</div> | ||
</body> | ||
`; | ||
|
||
exports[`[ToastBar Rendering] renders TinyText without crashing 1`] = ` | ||
<body> | ||
<div> | ||
<div | ||
class="rcx-box rcx-box--full rcx-css-fnyeze rcx-toastbar rcx-toastbar--info rcx-css-n4l2cd" | ||
> | ||
<div | ||
class="rcx-toastbar_inner" | ||
> | ||
<i | ||
aria-hidden="true" | ||
class="rcx-box rcx-box--full rcx-icon--name-info rcx-icon rcx-toastbar_icon--info rcx-css-4pvxx3" | ||
> | ||
| ||
</i> | ||
<div | ||
class="rcx-toastbar_content" | ||
role="alert" | ||
> | ||
Lorem ipsum dolor sit amet | ||
</div> | ||
</div> | ||
<div | ||
class="rcx-box rcx-box--full rcx-css-1rc3wl5 rcx-toastbar_progressbar" | ||
/> | ||
</div> | ||
</div> | ||
</body> | ||
`; | ||
|
||
exports[`[ToastBar Rendering] renders WithCloseButton without crashing 1`] = ` | ||
<body> | ||
<div> | ||
<div | ||
class="rcx-box rcx-box--full rcx-css-fnyeze rcx-toastbar rcx-toastbar--info rcx-css-n4l2cd" | ||
> | ||
<div | ||
class="rcx-toastbar_inner" | ||
> | ||
<i | ||
aria-hidden="true" | ||
class="rcx-box rcx-box--full rcx-icon--name-info rcx-icon rcx-toastbar_icon--info rcx-css-4pvxx3" | ||
> | ||
| ||
</i> | ||
<div | ||
class="rcx-toastbar_content" | ||
role="alert" | ||
> | ||
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod | ||
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, | ||
quis nostrud exercitation ullamco | ||
</div> | ||
<div | ||
class="rcx-toastbar-close" | ||
> | ||
<button | ||
aria-label="Dismiss alert" | ||
class="rcx-box rcx-box--full rcx-button--tiny-square rcx-button--square rcx-button--icon rcx-button" | ||
type="button" | ||
> | ||
<i | ||
aria-hidden="true" | ||
class="rcx-box rcx-box--full rcx-icon--name-cross rcx-icon rcx-css-1g87xs3" | ||
> | ||
| ||
</i> | ||
</button> | ||
</div> | ||
</div> | ||
<div | ||
class="rcx-box rcx-box--full rcx-css-1rc3wl5 rcx-toastbar_progressbar" | ||
/> | ||
</div> | ||
</div> | ||
</body> | ||
`; |