Skip to content

Commit

Permalink
test(DefinitionList): add smoke visual tests
Browse files Browse the repository at this point in the history
  • Loading branch information
itwillwork committed Dec 28, 2024
1 parent f8dfee1 commit 3118174
Show file tree
Hide file tree
Showing 10 changed files with 74 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.
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.
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import {smokeTest, test} from '~playwright/core';

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

import {DefinitionListStories} from './stories';

test.describe('DefinitionList', {tag: '@DefinitionList'}, () => {
test('render story <Default>', async ({mount, expectScreenshot}) => {
await mount(<DefinitionListStories.Default />);

await expectScreenshot();
});

createSmokeScenarios<Omit<DefinitionListProps, 'children'>>(
{},
{
direction: ['vertical', 'horizontal'],
},
).forEach(([title, props]) => {
smokeTest(title, async ({mount, expectScreenshot}) => {
await mount(
<div>
<h4>{title}</h4>
<DefinitionListStories.Default {...props} />
</div>,
);

await expectScreenshot({
themes: ['light'],
});
});
});

createSmokeScenarios<Omit<DefinitionListProps, 'children'>>(
{
responsive: true,
},
{
nameMaxWidth: [100],
contentMaxWidth: [100],
},
{
scenarioName: 'responsive',
},
).forEach(([title, props]) => {
smokeTest(title, async ({mount, page, expectScreenshot}) => {
const size = page.viewportSize();
if (size) {
await page.setViewportSize({
width: 1000,
height: size.height,
});
}

await mount(
<div>
<h4>{title}</h4>
<DefinitionListStories.Default {...props} />
</div>,
{width: 'auto'},
);

await expectScreenshot({
themes: ['light'],
});
});
});
});
5 changes: 5 additions & 0 deletions src/components/DefinitionList/__tests__/stories.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import {composeStories} from '@storybook/react';

import * as CSFStories from '../__stories__/DefinitionList.stories';

export const DefinitionListStories = composeStories(CSFStories);

0 comments on commit 3118174

Please sign in to comment.