Skip to content

Commit

Permalink
test(HelpMark): add visual test (#2025)
Browse files Browse the repository at this point in the history
  • Loading branch information
itwillwork authored Dec 28, 2024
1 parent f8dfee1 commit b190203
Show file tree
Hide file tree
Showing 21 changed files with 77 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.
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.
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.
52 changes: 52 additions & 0 deletions src/components/HelpMark/__tests__/HelpMark.visual.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import {expect} from '@playwright/experimental-ct-react';

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

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

import {placementCases} from './cases';
import {HelpMarkStories} from './stories';

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

await expectScreenshot();
});

createSmokeScenarios<HelpMarkProps>(
{},
{
placement: placementCases,
},
).forEach(([title, props]) => {
smokeTest(title, async ({mount, page, expectScreenshot}) => {
const root = await mount(
<div>
<h4>{title}</h4>
<div style={{padding: 100}}>
<HelpMark
qa="popover"
buttonProps={{
// @ts-expect-error Object literal may only specify known properties, and ''data-qa'' does not exist in type 'ButtonHTMLAttributes<HTMLButtonElement>'
'data-qa': 'trigger',
}}
{...props}
>
Test content
</HelpMark>
</div>
</div>,
);

await root.getByTestId('trigger').hover();
await expect(page.getByTestId('popover-tooltip')).toBeVisible();

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

export const placementCases: Cases<HelpMarkProps['placement']> = [
'auto',
'auto-start',
'auto-end',
'top',
'bottom',
'right',
'left',
'top-start',
'top-end',
'bottom-start',
'bottom-end',
'right-start',
'right-end',
'left-start',
'left-end',
];
5 changes: 5 additions & 0 deletions src/components/HelpMark/__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__/HelpMark.stories';

export const HelpMarkStories = composeStories(CSFStories);

0 comments on commit b190203

Please sign in to comment.