Skip to content

Commit

Permalink
chore(Sheet): add visual test for Default showcase (#1703)
Browse files Browse the repository at this point in the history
  • Loading branch information
mournfulCoroner authored Jul 17, 2024
1 parent 862f4fb commit 83e94b3
Show file tree
Hide file tree
Showing 8 changed files with 34 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.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {Button, Checkbox, TextInput} from '../../../';
import {cn} from '../../../utils/cn';
import {Sheet} from '../../Sheet';
import type {SheetProps} from '../../Sheet';
import {DEFAULT_SHEET_QA} from '../constants';

import './DefaultShowcase.scss';

Expand Down Expand Up @@ -71,6 +72,7 @@ export const Default: StoryFn<SheetProps> = ({
visible={visible}
onClose={() => setVisible(false)}
title={withTitle ? 'Sheet title' : undefined}
qa={DEFAULT_SHEET_QA}
>
<div className={b('content-item')}>
<TextInput />
Expand Down
1 change: 1 addition & 0 deletions src/components/Sheet/__stories__/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const DEFAULT_SHEET_QA = 'default-sheet-qa';
26 changes: 26 additions & 0 deletions src/components/Sheet/__tests__/Sheet.visual.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import React from 'react';

import {expect} from '@playwright/test';

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

import {DEFAULT_SHEET_QA} from '../__stories__/constants';

import {SheetStories} from './helpersPlaywright';

test.describe('Sheet', () => {
test('render story: <Default>', async ({page, mount, expectScreenshot}) => {
await mount(<SheetStories.Default />);

await page.getByRole('button').click();

const sheetLocator = page.locator(`[data-qa=${DEFAULT_SHEET_QA}]`);

await expect(sheetLocator).toBeVisible();

await expectScreenshot({
animations: 'disabled',
component: sheetLocator,
});
});
});
5 changes: 5 additions & 0 deletions src/components/Sheet/__tests__/helpersPlaywright.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import {composeStories} from '@storybook/react';

import * as stories from '../__stories__/DefaultShowcase/DefaultShowcase.stories';

export const SheetStories = composeStories(stories);

0 comments on commit 83e94b3

Please sign in to comment.