-
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.
Merge branch 'main' into add-smoke-tests/Modal
- Loading branch information
Showing
37 changed files
with
340 additions
and
5 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
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
+20.4 KB
....visual.test.tsx-snapshots/ActionTooltip-smoke-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
+23 KB
...t.tsx-snapshots/ActionTooltip-smoke-placement-auto-end-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
+22.4 KB
....test.tsx-snapshots/ActionTooltip-smoke-placement-auto-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
+23.4 KB
...tsx-snapshots/ActionTooltip-smoke-placement-auto-start-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
+23.8 KB
...tsx-snapshots/ActionTooltip-smoke-placement-bottom-end-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
+22.9 KB
...est.tsx-snapshots/ActionTooltip-smoke-placement-bottom-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
+24.4 KB
...x-snapshots/ActionTooltip-smoke-placement-bottom-start-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
+22.5 KB
...t.tsx-snapshots/ActionTooltip-smoke-placement-left-end-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
+21.6 KB
....test.tsx-snapshots/ActionTooltip-smoke-placement-left-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
+23.1 KB
...tsx-snapshots/ActionTooltip-smoke-placement-left-start-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
+23.5 KB
....tsx-snapshots/ActionTooltip-smoke-placement-right-end-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
+22.4 KB
...test.tsx-snapshots/ActionTooltip-smoke-placement-right-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
+23.3 KB
...sx-snapshots/ActionTooltip-smoke-placement-right-start-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
+22.6 KB
...st.tsx-snapshots/ActionTooltip-smoke-placement-top-end-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
+22.1 KB
...l.test.tsx-snapshots/ActionTooltip-smoke-placement-top-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
+23.5 KB
....tsx-snapshots/ActionTooltip-smoke-placement-top-start-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.
66 changes: 66 additions & 0 deletions
66
src/components/ActionTooltip/__tests__/ActionTooltip.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,66 @@ | ||
import {expect} from '@playwright/experimental-ct-react'; | ||
|
||
import {smokeTest, test} from '~playwright/core'; | ||
|
||
import {createSmokeScenarios} from '../../../stories/tests-factory/create-smoke-scenarios'; | ||
import type {ActionTooltipProps} from '../ActionTooltip'; | ||
import {ActionTooltip} from '../ActionTooltip'; | ||
|
||
import {placementCases} from './cases'; | ||
|
||
test.describe('ActionTooltip', {tag: '@ActionTooltip'}, () => { | ||
const defaultProps: ActionTooltipProps = { | ||
title: 'Title', | ||
hotkey: 'mod+a', | ||
description: 'Description', | ||
children: <div>trigger</div>, | ||
}; | ||
|
||
const smokeScenarios = createSmokeScenarios<ActionTooltipProps>(defaultProps, { | ||
placement: placementCases, | ||
}); | ||
|
||
smokeScenarios.forEach(([title, props]) => { | ||
smokeTest(title, async ({mount, page, expectScreenshot}) => { | ||
const root = await mount( | ||
<div> | ||
<h4>{title}</h4> | ||
<div | ||
style={{ | ||
width: '400px', | ||
height: '400px', | ||
display: 'flex', | ||
justifyContent: 'center', | ||
alignItems: 'center', | ||
}} | ||
> | ||
<div> | ||
<ActionTooltip {...props}> | ||
<div | ||
data-qa="trigger" | ||
style={{ | ||
width: '200px', | ||
height: '200px', | ||
display: 'flex', | ||
justifyContent: 'center', | ||
alignItems: 'center', | ||
border: '1px tomato dotted', | ||
}} | ||
> | ||
trigger block | ||
</div> | ||
</ActionTooltip> | ||
</div> | ||
</div> | ||
</div>, | ||
); | ||
|
||
await root.getByTestId('trigger').hover(); | ||
await expect(page.locator("[role='tooltip']")).toBeVisible({timeout: 1000}); | ||
|
||
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,20 @@ | ||
import type {Cases} from '../../../stories/tests-factory/models'; | ||
import type {ActionTooltipProps} from '../ActionTooltip'; | ||
|
||
export const placementCases: Cases<ActionTooltipProps['placement']> = [ | ||
'auto', | ||
'auto-start', | ||
'auto-end', | ||
'top', | ||
'bottom', | ||
'right', | ||
'left', | ||
'top-start', | ||
'top-end', | ||
'bottom-start', | ||
'bottom-end', | ||
'right-start', | ||
'right-end', | ||
'left-start', | ||
'left-end', | ||
]; |
Binary file modified
BIN
-6.25 KB
(87%)
...et.visual.test.tsx-snapshots/Sheet-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 removed
BIN
-37.5 KB
...heet.visual.test.tsx-snapshots/Sheet-render-story-Default-dark-webkit-linux.png
Binary file not shown.
Binary file modified
BIN
-6.85 KB
(86%)
...t.visual.test.tsx-snapshots/Sheet-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 removed
BIN
-37.9 KB
...eet.visual.test.tsx-snapshots/Sheet-render-story-Default-light-webkit-linux.png
Binary file not shown.
Binary file added
BIN
+12.7 KB
...__/Sheet.visual.test.tsx-snapshots/Sheet-smoke-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
+12.3 KB
....visual.test.tsx-snapshots/Sheet-smoke-hideTopBar-true-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
+13.8 KB
...heet.visual.test.tsx-snapshots/Sheet-smoke-title-Title-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
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 {SheetProps} from '../Sheet'; | ||
|
||
export const hideTopBarCases: Cases<SheetProps['hideTopBar']> = [true]; | ||
export const titleCases: Cases<SheetProps['title']> = ['Title']; |
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,3 @@ | ||
export const QASheet = { | ||
content: 'content', | ||
}; |
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,34 @@ | ||
import * as React from 'react'; | ||
|
||
import type {SheetProps} from '../Sheet'; | ||
import {Sheet} from '../Sheet'; | ||
|
||
import {QASheet} from './constants'; | ||
|
||
export const TestSheet = (props: Partial<Omit<SheetProps, 'visible' | 'onClose'>>) => { | ||
const [visible, setVisible] = React.useState(false); | ||
|
||
return ( | ||
<div> | ||
<button onClick={() => setVisible(true)}>Show modal</button> | ||
<Sheet | ||
{...props} | ||
visible={visible} | ||
onClose={() => setVisible(false)} | ||
qa={QASheet.content} | ||
> | ||
<div | ||
style={{ | ||
minHeight: 100, | ||
border: '1px solid tomato', | ||
display: 'flex', | ||
justifyContent: 'center', | ||
alignItems: 'center', | ||
}} | ||
> | ||
Sheet content | ||
</div> | ||
</Sheet> | ||
</div> | ||
); | ||
}; |
Binary file added
BIN
+78.7 KB
...pshots__/Slider.visual.test.tsx-snapshots/Slider-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.
Binary file added
BIN
+81.5 KB
...der.visual.test.tsx-snapshots/Slider-smoke-range-value-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
+44.2 KB
...test.tsx-snapshots/Slider-smoke-range-value-with-error-light-chromium-linux.png
Oops, something went wrong.
Binary file added
BIN
+42.8 KB
...ider.visual.test.tsx-snapshots/Slider-smoke-with-error-light-chromium-linux.png
Oops, something went wrong.
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,161 @@ | ||
import type * as React from 'react'; | ||
|
||
import {smokeTest, test} from '~playwright/core'; | ||
|
||
import {createSmokeScenarios} from '../../../stories/tests-factory/create-smoke-scenarios'; | ||
import {Slider} from '../Slider'; | ||
import type {SliderProps} from '../types'; | ||
|
||
import { | ||
availableValuesCases, | ||
disabledCases, | ||
hasTooltipCases, | ||
marksCountCases, | ||
sizeCases, | ||
stepCases, | ||
validationStateCases, | ||
} from './cases'; | ||
|
||
test.describe('Slider', {tag: '@Slider'}, () => { | ||
const defaultWrapStyle: React.CSSProperties = { | ||
width: 300, | ||
height: 50, | ||
paddingBottom: 20, | ||
}; | ||
|
||
const defaultProps: SliderProps = { | ||
value: 40, | ||
min: 0, | ||
max: 100, | ||
onUpdate: () => {}, | ||
}; | ||
|
||
smokeTest('', async ({mount, expectScreenshot}) => { | ||
const smokeScenarios = createSmokeScenarios(defaultProps, { | ||
size: sizeCases, | ||
disabled: disabledCases, | ||
validationState: validationStateCases, | ||
hasTooltip: hasTooltipCases, | ||
marksCount: marksCountCases, | ||
step: stepCases, | ||
availableValues: availableValuesCases, | ||
}); | ||
|
||
await mount( | ||
<div> | ||
{smokeScenarios.map(([title, props]) => ( | ||
<div key={title}> | ||
<h4>{title}</h4> | ||
<div style={defaultWrapStyle}> | ||
<Slider {...props} /> | ||
</div> | ||
</div> | ||
))} | ||
</div>, | ||
); | ||
|
||
await expectScreenshot({ | ||
themes: ['light'], | ||
}); | ||
}); | ||
|
||
smokeTest('with error', async ({mount, expectScreenshot}) => { | ||
const smokeScenarios = createSmokeScenarios<SliderProps>( | ||
{ | ||
...defaultProps, | ||
validationState: 'invalid', | ||
errorMessage: 'Error message', | ||
}, | ||
{ | ||
hasTooltip: hasTooltipCases, | ||
marksCount: marksCountCases, | ||
step: stepCases, | ||
}, | ||
); | ||
|
||
await mount( | ||
<div> | ||
{smokeScenarios.map(([title, props]) => ( | ||
<div key={title}> | ||
<h4>{title}</h4> | ||
<div style={defaultWrapStyle}> | ||
<Slider {...props} /> | ||
</div> | ||
</div> | ||
))} | ||
</div>, | ||
); | ||
|
||
await expectScreenshot({ | ||
themes: ['light'], | ||
}); | ||
}); | ||
|
||
const defaultRangeProps: SliderProps = { | ||
value: [20, 40], | ||
min: 0, | ||
max: 100, | ||
onUpdate: () => {}, | ||
}; | ||
|
||
smokeTest('range value', async ({mount, expectScreenshot}) => { | ||
const smokeScenarios = createSmokeScenarios<SliderProps>(defaultRangeProps, { | ||
size: sizeCases, | ||
disabled: disabledCases, | ||
validationState: validationStateCases, | ||
hasTooltip: hasTooltipCases, | ||
marksCount: marksCountCases, | ||
step: stepCases, | ||
availableValues: availableValuesCases, | ||
}); | ||
|
||
await mount( | ||
<div> | ||
{smokeScenarios.map(([title, props]) => ( | ||
<div key={title}> | ||
<h4>{title}</h4> | ||
<div style={defaultWrapStyle}> | ||
<Slider {...props} /> | ||
</div> | ||
</div> | ||
))} | ||
</div>, | ||
); | ||
|
||
await expectScreenshot({ | ||
themes: ['light'], | ||
}); | ||
}); | ||
|
||
smokeTest('range value with error', async ({mount, expectScreenshot}) => { | ||
const smokeScenarios = createSmokeScenarios<SliderProps>( | ||
{ | ||
...defaultRangeProps, | ||
validationState: 'invalid', | ||
errorMessage: 'Error message', | ||
}, | ||
{ | ||
hasTooltip: hasTooltipCases, | ||
marksCount: marksCountCases, | ||
step: stepCases, | ||
}, | ||
); | ||
|
||
await mount( | ||
<div> | ||
{smokeScenarios.map(([title, props]) => ( | ||
<div key={title}> | ||
<h4>{title}</h4> | ||
<div style={defaultWrapStyle}> | ||
<Slider {...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,12 @@ | ||
import type {Cases, CasesWithName} from '../../../stories/tests-factory/models'; | ||
import type {SliderProps} from '../types'; | ||
|
||
export const sizeCases: Cases<SliderProps['size']> = ['s', 'm', 'l', 'xl']; | ||
export const disabledCases: Cases<SliderProps['disabled']> = [true]; | ||
export const validationStateCases: Cases<SliderProps['validationState']> = ['invalid']; | ||
export const hasTooltipCases: Cases<SliderProps['hasTooltip']> = [true]; | ||
export const marksCountCases: Cases<SliderProps['marksCount']> = [4]; | ||
export const stepCases: Cases<SliderProps['step']> = [5]; | ||
export const availableValuesCases: CasesWithName<SliderProps['availableValues']> = [ | ||
['10-20-50-55-65-80', [10, 20, 50, 55, 65, 80]], | ||
]; |