-
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(PlaceholderContainer): add smoke visual tests (#2029)
- Loading branch information
1 parent
04089c4
commit 232cd1f
Showing
14 changed files
with
139 additions
and
0 deletions.
There are no files selected for viewing
Binary file added
BIN
+107 KB
...tsx-snapshots/PlaceholderContainer-render-story-Actions-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
+104 KB
...sx-snapshots/PlaceholderContainer-render-story-Actions-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
+107 KB
...t.tsx-snapshots/PlaceholderContainer-render-story-Align-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
+104 KB
....tsx-snapshots/PlaceholderContainer-render-story-Align-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
+45.6 KB
...tsx-snapshots/PlaceholderContainer-render-story-Default-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
+44.1 KB
...sx-snapshots/PlaceholderContainer-render-story-Default-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
+90.5 KB
...x-snapshots/PlaceholderContainer-render-story-Direction-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
+86.7 KB
...-snapshots/PlaceholderContainer-render-story-Direction-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
+63.7 KB
...st.tsx-snapshots/PlaceholderContainer-render-story-Size-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
+61.5 KB
...t.tsx-snapshots/PlaceholderContainer-render-story-Size-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
+151 KB
...r.visual.test.tsx-snapshots/PlaceholderContainer-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.
88 changes: 88 additions & 0 deletions
88
src/components/PlaceholderContainer/__tests__/PlaceholderContainer.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,88 @@ | ||
import {smokeTest, test} from '~playwright/core'; | ||
|
||
import {createSmokeScenarios} from '../../../stories/tests-factory/create-smoke-scenarios'; | ||
|
||
import { | ||
actionsCases, | ||
alignCases, | ||
contentCases, | ||
descriptionCases, | ||
directionCases, | ||
sizeCases, | ||
titleCases, | ||
} from './cases'; | ||
import {PlaceholderContainerStories, TestPlaceholderContainerWithImage} from './helpersPlaywright'; | ||
import type {TestPlaceholderContainerProps} from './helpersPlaywright'; | ||
|
||
test.describe('PlaceholderContainer', {tag: '@PlaceholderContainer'}, () => { | ||
test('render story: <Default>', async ({mount, expectScreenshot}) => { | ||
await mount(<PlaceholderContainerStories.Default />); | ||
|
||
await expectScreenshot(); | ||
}); | ||
|
||
test('render story: <Direction>', async ({mount, expectScreenshot}) => { | ||
await mount(<PlaceholderContainerStories.Direction />); | ||
|
||
await expectScreenshot(); | ||
}); | ||
|
||
test('render story: <Align>', async ({mount, expectScreenshot}) => { | ||
await mount(<PlaceholderContainerStories.Align />); | ||
|
||
await expectScreenshot(); | ||
}); | ||
|
||
test('render story: <Size>', async ({mount, expectScreenshot}) => { | ||
await mount(<PlaceholderContainerStories.Size />); | ||
|
||
await expectScreenshot(); | ||
}); | ||
|
||
test('render story: <Actions>', async ({mount, expectScreenshot}) => { | ||
await mount(<PlaceholderContainerStories.Actions />); | ||
|
||
await expectScreenshot(); | ||
}); | ||
|
||
const commonPropsCases = { | ||
size: sizeCases, | ||
direction: directionCases, | ||
align: alignCases, | ||
title: titleCases, | ||
description: descriptionCases, | ||
content: contentCases, | ||
actions: actionsCases, | ||
} as const; | ||
|
||
smokeTest('', async ({mount, expectScreenshot}) => { | ||
const smokeScenarios = createSmokeScenarios<TestPlaceholderContainerProps>( | ||
{ | ||
title: 'Title', | ||
description: 'Description', | ||
}, | ||
commonPropsCases, | ||
); | ||
|
||
await mount( | ||
<div> | ||
{smokeScenarios.map(([title, props]) => { | ||
console.log('kekw', props); | ||
|
||
return ( | ||
<div key={title}> | ||
<h4>{title}</h4> | ||
<div> | ||
<TestPlaceholderContainerWithImage {...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,30 @@ | ||
import type {Cases, CasesWithName} from '../../../stories/tests-factory/models'; | ||
import type {PlaceholderContainerProps} from '../types'; | ||
|
||
export const sizeCases: Cases<PlaceholderContainerProps['size']> = ['s', 'm', 'l', 'promo']; | ||
export const directionCases: Cases<PlaceholderContainerProps['direction']> = ['row', 'column']; | ||
export const alignCases: Cases<PlaceholderContainerProps['align']> = ['left', 'center']; | ||
export const titleCases: CasesWithName<PlaceholderContainerProps['title']> = [['none', undefined]]; | ||
export const descriptionCases: CasesWithName<PlaceholderContainerProps['description']> = [ | ||
['none', undefined], | ||
]; | ||
export const contentCases: CasesWithName<PlaceholderContainerProps['content']> = [ | ||
['has', 'Content'], | ||
]; | ||
export const actionsCases: CasesWithName<PlaceholderContainerProps['actions']> = [ | ||
[ | ||
'has', | ||
[ | ||
{ | ||
text: 'Main button', | ||
view: 'normal', | ||
onClick: () => {}, | ||
}, | ||
{ | ||
text: 'Additional button', | ||
view: 'flat-secondary', | ||
onClick: () => {}, | ||
}, | ||
], | ||
], | ||
]; |
21 changes: 21 additions & 0 deletions
21
src/components/PlaceholderContainer/__tests__/helpersPlaywright.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,21 @@ | ||
import {composeStories} from '@storybook/react'; | ||
|
||
import {PlaceholderContainer} from '../PlaceholderContainer'; | ||
import * as stories from '../__stories__/PlaceholderContainer.stories'; | ||
import type {PlaceholderContainerProps} from '../types'; | ||
|
||
export const PlaceholderContainerStories = composeStories(stories); | ||
|
||
export type TestPlaceholderContainerProps = Omit<PlaceholderContainerProps, 'image'>; | ||
|
||
const TestImageComponent = () => { | ||
return ( | ||
<svg width="100" height="100" viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg"> | ||
<rect fill="#DDDDDD" height="100%" transform="matrix(1 0 0 1 0 0)" width="100%" /> | ||
</svg> | ||
); | ||
}; | ||
|
||
export const TestPlaceholderContainerWithImage = (props: TestPlaceholderContainerProps) => { | ||
return <PlaceholderContainer image={<TestImageComponent />} {...props} />; | ||
}; |