Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(Radio): add smoke visual tests #1805

Merged
merged 11 commits into from
Dec 26, 2024
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'];
Loading