Skip to content

Commit

Permalink
test(RadioButton): add smoke visual tests (#1807)
Browse files Browse the repository at this point in the history
  • Loading branch information
itwillwork authored Dec 27, 2024
1 parent 26cec9a commit 00943a1
Show file tree
Hide file tree
Showing 6 changed files with 72 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.
67 changes: 67 additions & 0 deletions src/components/RadioButton/__tests__/RadioButton.visual.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import {smokeTest, test} from '~playwright/core';

import {createSmokeScenarios} from '../../../stories/tests-factory/create-smoke-scenarios';
import type {RadioButtonOption, RadioButtonProps} from '../RadioButton';
import {RadioButton} from '../RadioButton';

import {sizeCases, widthCases} from './cases';

test.describe('RadioButton', {tag: '@RadioButton'}, () => {
const options: RadioButtonOption[] = [
{value: 'Value 1', content: 'Value 1'},
{value: 'Value 2', content: 'Value 2'},
{value: 'Value 3', content: 'Value 3', disabled: true},
];

const defaultProps: RadioButtonProps = {
value: 'Value 1',
options,
};

smokeTest('', async ({mount, expectScreenshot}) => {
const smokeScenarios = createSmokeScenarios(defaultProps, {
size: sizeCases,
width: widthCases,
});

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

await expectScreenshot({});
});

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

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

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

export const sizeCases: Cases<RadioButtonProps['size']> = ['s', 'm', 'l', 'xl'];
export const widthCases: Cases<RadioButtonProps['width']> = ['auto', 'max'];

0 comments on commit 00943a1

Please sign in to comment.