-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(RadioGroup): add smoke visual tests (#1806)
- Loading branch information
1 parent
35b6947
commit 336520d
Showing
7 changed files
with
76 additions
and
0 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
Binary file added
BIN
+56.7 KB
..._/RadioGroup.visual.test.tsx-snapshots/RadioGroup-smoke-dark-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+51.6 KB
...oup.visual.test.tsx-snapshots/RadioGroup-smoke-disabled-dark-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+49.4 KB
...up.visual.test.tsx-snapshots/RadioGroup-smoke-disabled-light-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+53.7 KB
.../RadioGroup.visual.test.tsx-snapshots/RadioGroup-smoke-light-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
70 changes: 70 additions & 0 deletions
70
src/components/RadioGroup/__tests__/RadioGroup.visual.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,70 @@ | ||
import {smokeTest, test} from '~playwright/core'; | ||
|
||
import {createSmokeScenarios} from '../../../stories/tests-factory/create-smoke-scenarios'; | ||
import type {RadioGroupOption, RadioGroupProps} from '../RadioGroup'; | ||
import {RadioGroup} from '../RadioGroup'; | ||
|
||
import {directionCases, sizeCases} from './cases'; | ||
|
||
test.describe('RadioGroup', {tag: '@RadioGroup'}, () => { | ||
const options: RadioGroupOption[] = [ | ||
{value: 'Value 1', content: 'Value 1'}, | ||
{value: 'Value 2', content: 'Value 2'}, | ||
{value: 'Value 3', content: 'Value 3', disabled: true}, | ||
]; | ||
|
||
const defaultProps: RadioGroupProps = { | ||
value: 'Value 1', | ||
options, | ||
}; | ||
|
||
smokeTest('', async ({mount, expectScreenshot}) => { | ||
const smokeScenarios = createSmokeScenarios<RadioGroupProps>(defaultProps, { | ||
size: sizeCases, | ||
direction: directionCases, | ||
}); | ||
|
||
await mount( | ||
<div> | ||
{smokeScenarios.map(([title, props]) => ( | ||
<div key={title}> | ||
<h4>{title}</h4> | ||
<div> | ||
<RadioGroup {...props} /> | ||
</div> | ||
</div> | ||
))} | ||
</div>, | ||
); | ||
|
||
await expectScreenshot({}); | ||
}); | ||
|
||
smokeTest('disabled', async ({mount, expectScreenshot}) => { | ||
const smokeScenarios = createSmokeScenarios<RadioGroupProps>( | ||
{ | ||
...defaultProps, | ||
disabled: true, | ||
}, | ||
{ | ||
size: sizeCases, | ||
direction: directionCases, | ||
}, | ||
); | ||
|
||
await mount( | ||
<div> | ||
{smokeScenarios.map(([title, props]) => ( | ||
<div key={title}> | ||
<h4>{title}</h4> | ||
<div> | ||
<RadioGroup {...props} /> | ||
</div> | ||
</div> | ||
))} | ||
</div>, | ||
); | ||
|
||
await expectScreenshot({}); | ||
}); | ||
}); |
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 @@ | ||
import type {Cases} from '../../../stories/tests-factory/models'; | ||
import type {RadioGroupProps} from '../RadioGroup'; | ||
|
||
export const sizeCases: Cases<RadioGroupProps['size']> = ['m', 'l']; | ||
export const directionCases: Cases<RadioGroupProps['direction']> = ['vertical', 'horizontal']; |