Skip to content

Commit

Permalink
test(RadioGroup): add smoke visual tests (#1806)
Browse files Browse the repository at this point in the history
  • Loading branch information
itwillwork authored Dec 26, 2024
1 parent 35b6947 commit 336520d
Show file tree
Hide file tree
Showing 7 changed files with 76 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/components/RadioGroup/RadioGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export const RadioGroup = React.forwardRef<HTMLDivElement, RadioGroupProps>(
value: props.value,
content: props.content || props.children,
disabled: props.disabled,
qa: props.qa,
}));
}

Expand Down
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.
70 changes: 70 additions & 0 deletions src/components/RadioGroup/__tests__/RadioGroup.visual.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import {smokeTest, test} from '~playwright/core';

import {createSmokeScenarios} from '../../../stories/tests-factory/create-smoke-scenarios';
import type {RadioGroupOption, RadioGroupProps} from '../RadioGroup';
import {RadioGroup} from '../RadioGroup';

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

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

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

smokeTest('', async ({mount, expectScreenshot}) => {
const smokeScenarios = createSmokeScenarios<RadioGroupProps>(defaultProps, {
size: sizeCases,
direction: directionCases,
});

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

await expectScreenshot({});
});

smokeTest('disabled', async ({mount, expectScreenshot}) => {
const smokeScenarios = createSmokeScenarios<RadioGroupProps>(
{
...defaultProps,
disabled: true,
},
{
size: sizeCases,
direction: directionCases,
},
);

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

await expectScreenshot({});
});
});
5 changes: 5 additions & 0 deletions src/components/RadioGroup/__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 {RadioGroupProps} from '../RadioGroup';

export const sizeCases: Cases<RadioGroupProps['size']> = ['m', 'l'];
export const directionCases: Cases<RadioGroupProps['direction']> = ['vertical', 'horizontal'];

0 comments on commit 336520d

Please sign in to comment.