Skip to content

Commit

Permalink
test(ArrowToggle): add smoke visual tests (#1770)
Browse files Browse the repository at this point in the history
  • Loading branch information
itwillwork authored Dec 25, 2024
1 parent 652c2a7 commit 1d184c9
Show file tree
Hide file tree
Showing 3 changed files with 47 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.
37 changes: 37 additions & 0 deletions src/components/ArrowToggle/__tests__/ArrowToggle.visual.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import React from 'react';

import {smokeTest, test} from '~playwright/core';

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

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

test.describe('ArrowToggle', {tag: '@ArrowToggle'}, () => {
smokeTest('smoke', async ({mount, expectScreenshot}) => {
const defaultProps: ArrowToggleProps = {};

const smokeScenarios = createSmokeScenarios(defaultProps, {
size: sizeCases,
direction: directionCases,
});

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

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

export const sizeCases: Cases<ArrowToggleProps['size']> = [10, 20, 30, 40, 50, 100];
export const directionCases: Cases<ArrowToggleProps['direction']> = [
'top',
'left',
'bottom',
'right',
];

0 comments on commit 1d184c9

Please sign in to comment.