-
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(UserLabel): add smoke visual tests (#1792)
- Loading branch information
1 parent
12e5d74
commit cc6b6dd
Showing
6 changed files
with
173 additions
and
0 deletions.
There are no files selected for viewing
Binary file added
BIN
+125 KB
...rLabel.visual.test.tsx-snapshots/UserLabel-smoke-email-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
+160 KB
...Label.visual.test.tsx-snapshots/UserLabel-smoke-person-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
+100 KB
...erLabel.visual.test.tsx-snapshots/UserLabel-smoke-user-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.
107 changes: 107 additions & 0 deletions
107
src/components/UserLabel/__tests__/UserLabel.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,107 @@ | ||
import {smokeTest, test} from '~playwright/core'; | ||
|
||
import {createSmokeScenarios} from '../../../stories/tests-factory/create-smoke-scenarios'; | ||
import type {UserLabelProps} from '../types'; | ||
|
||
import { | ||
childrenCases, | ||
onClickCases, | ||
onCloseClickCases, | ||
sizeCases, | ||
typeCases, | ||
viewCases, | ||
} from './cases'; | ||
import {TestUserLabel, TestUserLabelWithEmail, TestUserLabelWithPerson} from './helpers'; | ||
|
||
test.describe('UserLabel', {tag: '@UserLabel'}, () => { | ||
smokeTest('user', async ({mount, expectScreenshot}) => { | ||
const smokeScenarios = createSmokeScenarios<Partial<UserLabelProps>>( | ||
{}, | ||
{ | ||
size: sizeCases, | ||
view: viewCases, | ||
type: typeCases, | ||
children: childrenCases, | ||
onClick: onClickCases, | ||
onCloseClick: onCloseClickCases, | ||
}, | ||
); | ||
|
||
await mount( | ||
<div> | ||
{smokeScenarios.map(([title, props]) => ( | ||
<div key={title}> | ||
<h4>{title}</h4> | ||
<div> | ||
<TestUserLabel {...props} /> | ||
</div> | ||
</div> | ||
))} | ||
</div>, | ||
); | ||
|
||
await expectScreenshot({ | ||
themes: ['light'], | ||
}); | ||
}); | ||
|
||
smokeTest('person', async ({mount, expectScreenshot}) => { | ||
const smokeScenarios = createSmokeScenarios<Partial<UserLabelProps>>( | ||
{}, | ||
{ | ||
size: sizeCases, | ||
view: viewCases, | ||
children: childrenCases, | ||
onClick: onClickCases, | ||
onCloseClick: onCloseClickCases, | ||
}, | ||
); | ||
|
||
await mount( | ||
<div> | ||
{smokeScenarios.map(([title, props]) => ( | ||
<div key={title}> | ||
<h4>{title}</h4> | ||
<div> | ||
<TestUserLabelWithPerson {...props} /> | ||
</div> | ||
</div> | ||
))} | ||
</div>, | ||
); | ||
|
||
await expectScreenshot({ | ||
themes: ['light'], | ||
}); | ||
}); | ||
|
||
smokeTest('email', async ({mount, expectScreenshot}) => { | ||
const smokeScenarios = createSmokeScenarios<Partial<UserLabelProps>>( | ||
{}, | ||
{ | ||
size: sizeCases, | ||
view: viewCases, | ||
children: childrenCases, | ||
onClick: onClickCases, | ||
onCloseClick: onCloseClickCases, | ||
}, | ||
); | ||
|
||
await mount( | ||
<div> | ||
{smokeScenarios.map(([title, props]) => ( | ||
<div key={title}> | ||
<h4>{title}</h4> | ||
<div> | ||
<TestUserLabelWithEmail {...props} /> | ||
</div> | ||
</div> | ||
))} | ||
</div>, | ||
); | ||
|
||
await expectScreenshot({ | ||
themes: ['light'], | ||
}); | ||
}); | ||
}); |
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,21 @@ | ||
import type {Cases, CasesWithName} from '../../../stories/tests-factory/models'; | ||
import type {UserLabelProps} from '../types'; | ||
|
||
export const sizeCases: Cases<UserLabelProps['size']> = ['xs', 's', 'm', 'l', 'xl']; | ||
|
||
export const viewCases: Cases<UserLabelProps['view']> = ['outlined', 'clear']; | ||
|
||
export const typeCases: Cases<UserLabelProps['type']> = ['person', 'email', 'empty']; | ||
|
||
export const childrenCases: CasesWithName<UserLabelProps['children']> = [ | ||
[ | ||
'long label', | ||
'Charles DarwinCharles DarwinCharles DarwinCharles DarwinCharles DarwinCharles DarwinCharles DarwinCharles DarwinCharles DarwinCharles DarwinCharles DarwinCharles DarwinCharles DarwinCharles DarwinCharles DarwinCharles DarwinCharles DarwinCharles DarwinCharles DarwinCharles DarwinCharles DarwinCharles DarwinCharles DarwinCharles DarwinCharles DarwinCharles DarwinCharles DarwinCharles DarwinCharles DarwinCharles DarwinCharles DarwinCharles DarwinCharles DarwinCharles DarwinCharles DarwinCharles DarwinCharles DarwinCharles DarwinCharles DarwinCharles DarwinCharles DarwinCharles DarwinCharles DarwinCharles DarwinCharles DarwinCharles DarwinCharles DarwinCharles DarwinCharles DarwinCharles DarwinCharles DarwinCharles DarwinCharles DarwinCharles DarwinCharles DarwinCharles DarwinCharles DarwinCharles DarwinCharles DarwinCharles DarwinCharles DarwinCharles DarwinCharles DarwinCharles DarwinCharles DarwinCharles DarwinCharles DarwinCharles DarwinCharles DarwinCharles DarwinCharles DarwinCharles DarwinCharles DarwinCharles DarwinCharles DarwinCharles DarwinCharles DarwinCharles DarwinCharles DarwinCharles DarwinCharles DarwinCharles DarwinCharles DarwinCharles DarwinCharles DarwinCharles DarwinCharles DarwinCharles DarwinCharles DarwinCharles DarwinCharles DarwinCharles DarwinCharles DarwinCharles DarwinCharles DarwinCharles DarwinCharles DarwinCharles DarwinCharles DarwinCharles Darwin', | ||
], | ||
]; | ||
|
||
export const onCloseClickCases: CasesWithName<UserLabelProps['onCloseClick']> = [ | ||
['closable', () => {}], | ||
]; | ||
|
||
export const onClickCases: CasesWithName<UserLabelProps['onClick']> = [['clickable', () => {}]]; |
Large diffs are not rendered by default.
Oops, something went wrong.