-
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(TextArea): add smoke visual tests (#1779)
- Loading branch information
1 parent
58b5337
commit f4166c0
Showing
5 changed files
with
157 additions
and
0 deletions.
There are no files selected for viewing
Binary file added
BIN
+172 KB
...extArea.visual.test.tsx-snapshots/TextArea-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
+84.8 KB
...ea.visual.test.tsx-snapshots/TextArea-smoke-with-error-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
+1.15 MB
...ea.visual.test.tsx-snapshots/TextArea-smoke-with-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.
117 changes: 117 additions & 0 deletions
117
src/components/controls/TextArea/__tests__/TextArea.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,117 @@ | ||
import {smokeTest, test} from '~playwright/core'; | ||
|
||
import {createSmokeScenarios} from '../../../../stories/tests-factory/create-smoke-scenarios'; | ||
import type {TextAreaProps} from '../TextArea'; | ||
import {TextArea} from '../TextArea'; | ||
|
||
import { | ||
disabledCases, | ||
hasClearCases, | ||
maxRowsCases, | ||
minRowsCases, | ||
noteCases, | ||
pinCases, | ||
rowsCases, | ||
sizeCases, | ||
testValue, | ||
validationStateCases, | ||
valueCases, | ||
viewCases, | ||
} from './cases'; | ||
|
||
test.describe('TextArea', {tag: '@TextArea'}, () => { | ||
const defaultProps: TextAreaProps = { | ||
placeholder: 'Placeholder', | ||
}; | ||
|
||
const commonPropCases = { | ||
pin: pinCases, | ||
size: sizeCases, | ||
view: viewCases, | ||
rows: rowsCases, | ||
minRows: minRowsCases, | ||
maxRows: maxRowsCases, | ||
note: noteCases, | ||
hasClear: hasClearCases, | ||
disabled: disabledCases, | ||
validationState: validationStateCases, | ||
} as const; | ||
|
||
smokeTest('empty', async ({mount, expectScreenshot}) => { | ||
const smokeScenarios = createSmokeScenarios(defaultProps, commonPropCases); | ||
|
||
await mount( | ||
<div> | ||
{smokeScenarios.map(([title, props]) => ( | ||
<div key={title}> | ||
<h4>{title}</h4> | ||
<div> | ||
<TextArea {...props} /> | ||
</div> | ||
</div> | ||
))} | ||
</div>, | ||
); | ||
|
||
await expectScreenshot({ | ||
themes: ['light'], | ||
}); | ||
}); | ||
|
||
smokeTest('with value', async ({mount, expectScreenshot}) => { | ||
const smokeScenarios = createSmokeScenarios( | ||
{ | ||
...defaultProps, | ||
value: testValue, | ||
}, | ||
commonPropCases, | ||
); | ||
|
||
await mount( | ||
<div> | ||
{smokeScenarios.map(([title, props]) => ( | ||
<div key={title}> | ||
<h4>{title}</h4> | ||
<div> | ||
<TextArea {...props} /> | ||
</div> | ||
</div> | ||
))} | ||
</div>, | ||
); | ||
|
||
await expectScreenshot({ | ||
themes: ['light'], | ||
}); | ||
}); | ||
|
||
smokeTest('with error', async ({mount, expectScreenshot}) => { | ||
const smokeScenarios = createSmokeScenarios( | ||
{ | ||
...defaultProps, | ||
validationState: 'invalid', | ||
errorMessage: 'Test error message', | ||
} as const, | ||
{ | ||
value: valueCases, | ||
}, | ||
); | ||
|
||
await mount( | ||
<div> | ||
{smokeScenarios.map(([title, props]) => ( | ||
<div key={title}> | ||
<h4>{title}</h4> | ||
<div> | ||
<TextArea {...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,40 @@ | ||
import type {Cases, CasesWithName} from '../../../../stories/tests-factory/models'; | ||
import type {TextAreaProps} from '../TextArea'; | ||
|
||
/* eslint-disable react/jsx-key */ | ||
|
||
export const testValue = | ||
"Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book."; | ||
export const valueCases: Array<TextAreaProps['value']> = [testValue]; | ||
|
||
export const disabledCases: Array<TextAreaProps['disabled']> = [true]; | ||
|
||
export const hasClearCases: Array<TextAreaProps['hasClear']> = [true]; | ||
|
||
export const validationStateCases: Array<TextAreaProps['validationState']> = ['invalid']; | ||
|
||
export const pinCases: Cases<TextAreaProps['pin']> = [ | ||
'round-round', | ||
'brick-brick', | ||
'clear-clear', | ||
'round-brick', | ||
'brick-round', | ||
'round-clear', | ||
'clear-round', | ||
'brick-clear', | ||
'clear-brick', | ||
]; | ||
|
||
export const sizeCases: Cases<TextAreaProps['size']> = ['s', 'm', 'l', 'xl']; | ||
|
||
export const viewCases: Cases<TextAreaProps['view']> = ['normal', 'clear']; | ||
|
||
export const noteCases: CasesWithName<TextAreaProps['note']> = [['', <div>note</div>]]; | ||
|
||
export const minRowsCases: Cases<TextAreaProps['minRows']> = [1, 3]; | ||
|
||
export const maxRowsCases: Cases<TextAreaProps['maxRows']> = [1, 3]; | ||
|
||
export const rowsCases: Cases<TextAreaProps['rows']> = [1, 3]; | ||
|
||
/* eslint-enable react/jsx-key */ |