-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(PinInput): add smoke visual tests (#1814)
- Loading branch information
1 parent
1d63b35
commit f8dfee1
Showing
5 changed files
with
123 additions
and
0 deletions.
There are no files selected for viewing
Binary file added
BIN
+91.9 KB
...ut.visual.test.tsx-snapshots/PinInput-smoke-alphabetic-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
+70.2 KB
...inInput.visual.test.tsx-snapshots/PinInput-smoke-empty-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
+89 KB
...nInput.visual.test.tsx-snapshots/PinInput-smoke-number-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.
112 changes: 112 additions & 0 deletions
112
src/components/PinInput/__tests__/PinInput.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,112 @@ | ||
import {smokeTest, test} from '~playwright/core'; | ||
|
||
import {createSmokeScenarios} from '../../../stories/tests-factory/create-smoke-scenarios'; | ||
import type {PinInputProps} from '../PinInput'; | ||
import {PinInput} from '../PinInput'; | ||
|
||
import { | ||
disabledCases, | ||
lengthCases, | ||
maskCases, | ||
noteCases, | ||
placeholderCases, | ||
responsiveCases, | ||
sizeCases, | ||
validationStateCases, | ||
} from './cases'; | ||
|
||
test.describe('PinInput', {tag: '@PinInput'}, () => { | ||
const commonPropsCases = { | ||
placeholder: placeholderCases, | ||
length: lengthCases, | ||
disabled: disabledCases, | ||
responsive: responsiveCases, | ||
note: noteCases, | ||
mask: maskCases, | ||
size: sizeCases, | ||
validationState: validationStateCases, | ||
} as const; | ||
|
||
smokeTest('empty', async ({mount, expectScreenshot}) => { | ||
const smokeScenarios = createSmokeScenarios<PinInputProps>( | ||
{ | ||
type: 'numeric', | ||
errorMessage: 'Test error message', | ||
}, | ||
commonPropsCases, | ||
); | ||
|
||
await mount( | ||
<div> | ||
{smokeScenarios.map(([title, props]) => ( | ||
<div key={title}> | ||
<h4>{title}</h4> | ||
<div> | ||
<PinInput {...props} /> | ||
</div> | ||
</div> | ||
))} | ||
</div>, | ||
); | ||
|
||
await expectScreenshot({ | ||
themes: ['light'], | ||
}); | ||
}); | ||
|
||
smokeTest('number', async ({mount, expectScreenshot}) => { | ||
const smokeScenarios = createSmokeScenarios<PinInputProps>( | ||
{ | ||
type: 'numeric', | ||
errorMessage: 'Test error message', | ||
value: ['1', '2', '3', '4'], | ||
}, | ||
commonPropsCases, | ||
); | ||
|
||
await mount( | ||
<div> | ||
{smokeScenarios.map(([title, props]) => ( | ||
<div key={title}> | ||
<h4>{title}</h4> | ||
<div> | ||
<PinInput {...props} /> | ||
</div> | ||
</div> | ||
))} | ||
</div>, | ||
); | ||
|
||
await expectScreenshot({ | ||
themes: ['light'], | ||
}); | ||
}); | ||
|
||
smokeTest('alphabetic', async ({mount, expectScreenshot}) => { | ||
const smokeScenarios = createSmokeScenarios<PinInputProps>( | ||
{ | ||
type: 'alphanumeric', | ||
errorMessage: 'Test error message', | ||
value: ['a', 'b', 'c', 'd'], | ||
}, | ||
commonPropsCases, | ||
); | ||
|
||
await mount( | ||
<div> | ||
{smokeScenarios.map(([title, props]) => ( | ||
<div key={title}> | ||
<h4>{title}</h4> | ||
<div> | ||
<PinInput {...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,11 @@ | ||
import type {Cases} from '../../../stories/tests-factory/models'; | ||
import type {PinInputProps} from '../PinInput'; | ||
|
||
export const sizeCases: Cases<PinInputProps['size']> = ['s', 'm', 'l', 'xl']; | ||
export const maskCases: Cases<PinInputProps['mask']> = [true]; | ||
export const placeholderCases: Cases<PinInputProps['placeholder']> = ['*']; | ||
export const validationStateCases: Cases<PinInputProps['validationState']> = ['invalid']; | ||
export const lengthCases: Cases<PinInputProps['length']> = [4, 6]; | ||
export const disabledCases: Cases<PinInputProps['disabled']> = [true]; | ||
export const responsiveCases: Cases<PinInputProps['responsive']> = [true]; | ||
export const noteCases: Cases<PinInputProps['note']> = ['note']; |