Skip to content

Commit

Permalink
test(Radio): add smoke visual tests (#1805)
Browse files Browse the repository at this point in the history
  • Loading branch information
itwillwork authored Dec 26, 2024
1 parent 8eefdd1 commit 35b6947
Show file tree
Hide file tree
Showing 8 changed files with 97 additions and 0 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
93 changes: 93 additions & 0 deletions src/components/Radio/__tests__/Radio.visual.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
import {smokeTest, test} from '~playwright/core';

import {createSmokeScenarios} from '../../../stories/tests-factory/create-smoke-scenarios';
import type {RadioProps} from '../Radio';
import {Radio} from '../Radio';

import {sizeCases} from './cases';

test.describe('Radio', {tag: '@Radio'}, () => {
const defaultProps: RadioProps = {
children: 'Test',
value: '1',
};

const commonPropsCases = {
size: sizeCases,
} as const;

smokeTest('', async ({mount, expectScreenshot}) => {
const smokeScenarios = createSmokeScenarios<RadioProps>(defaultProps, {
...commonPropsCases,
});

await mount(
<div>
{smokeScenarios.map(([title, props]) => (
<div key={title}>
<h4>{title}</h4>
<div>
<Radio {...props} />
</div>
</div>
))}
</div>,
);

await expectScreenshot({});
});

smokeTest('disabled', async ({mount, expectScreenshot}) => {
const smokeScenarios = createSmokeScenarios<RadioProps>(
{
...defaultProps,
disabled: true,
},
{
...commonPropsCases,
},
);

await mount(
<div>
{smokeScenarios.map(([title, props]) => (
<div key={title}>
<h4>{title}</h4>
<div>
<Radio {...props} />
</div>
</div>
))}
</div>,
);

await expectScreenshot({});
});

smokeTest('default checked', async ({mount, expectScreenshot}) => {
const smokeScenarios = createSmokeScenarios<RadioProps>(
{
...defaultProps,
defaultChecked: true,
},
{
...commonPropsCases,
},
);

await mount(
<div>
{smokeScenarios.map(([title, props]) => (
<div key={title}>
<h4>{title}</h4>
<div>
<Radio {...props} />
</div>
</div>
))}
</div>,
);

await expectScreenshot({});
});
});
4 changes: 4 additions & 0 deletions src/components/Radio/__tests__/cases.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import type {Cases} from '../../../stories/tests-factory/models';
import type {RadioProps} from '../Radio';

export const sizeCases: Cases<RadioProps['size']> = ['m', 'l'];

0 comments on commit 35b6947

Please sign in to comment.