-
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(Switch): add smoke visual tests (#1799)
- Loading branch information
1 parent
336520d
commit 6a7b2f4
Showing
6 changed files
with
71 additions
and
0 deletions.
There are no files selected for viewing
Binary file added
BIN
+29.3 KB
..._/Switch.visual.test.tsx-snapshots/Switch-smoke-checked-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
+27.1 KB
.../Switch.visual.test.tsx-snapshots/Switch-smoke-checked-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
+28.2 KB
...apshots__/Switch.visual.test.tsx-snapshots/Switch-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
+26.5 KB
...pshots__/Switch.visual.test.tsx-snapshots/Switch-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.
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,65 @@ | ||
import {smokeTest, test} from '~playwright/core'; | ||
|
||
import {createSmokeScenarios} from '../../../stories/tests-factory/create-smoke-scenarios'; | ||
import type {SwitchProps} from '../Switch'; | ||
import {Switch} from '../Switch'; | ||
|
||
import {disabledCases, indeterminateCases, sizeCases} from './cases'; | ||
|
||
test.describe('Switch', {tag: '@Switch'}, () => { | ||
const defaultProps: SwitchProps = { | ||
content: 'label', | ||
}; | ||
|
||
smokeTest('', async ({mount, expectScreenshot}) => { | ||
const smokeScenarios = createSmokeScenarios(defaultProps, { | ||
size: sizeCases, | ||
disabled: disabledCases, | ||
indeterminate: indeterminateCases, | ||
}); | ||
|
||
await mount( | ||
<div> | ||
{smokeScenarios.map(([title, props]) => ( | ||
<div key={title}> | ||
<h4>{title}</h4> | ||
<div> | ||
<Switch {...props} /> | ||
</div> | ||
</div> | ||
))} | ||
</div>, | ||
); | ||
|
||
await expectScreenshot({}); | ||
}); | ||
|
||
smokeTest('checked', async ({mount, expectScreenshot}) => { | ||
const smokeScenarios = createSmokeScenarios( | ||
{ | ||
...defaultProps, | ||
checked: true, | ||
}, | ||
{ | ||
size: sizeCases, | ||
disabled: disabledCases, | ||
indeterminate: indeterminateCases, | ||
}, | ||
); | ||
|
||
await mount( | ||
<div> | ||
{smokeScenarios.map(([title, props]) => ( | ||
<div key={title}> | ||
<h4>{title}</h4> | ||
<div> | ||
<Switch {...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,6 @@ | ||
import type {Cases} from '../../../stories/tests-factory/models'; | ||
import type {SwitchProps} from '../Switch'; | ||
|
||
export const disabledCases: Cases<SwitchProps['disabled']> = [true]; | ||
export const indeterminateCases: Cases<SwitchProps['indeterminate']> = [true]; | ||
export const sizeCases: Cases<SwitchProps['size']> = ['m', 'l']; |