Skip to content

Commit

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

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

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

import {underlineCases, viewCases, visitableCases} from './cases';

test.describe('Link', {tag: '@Link'}, () => {
smokeTest('', async ({mount, expectScreenshot}) => {
const defaultProps: LinkProps = {
href: '#',
target: '_blank',
children: 'Link',
};

const viewSmokeScenarios = createSmokeScenarios<LinkProps>(
defaultProps,
{
view: viewCases,
},
{},
);

await mount(
<div>
{viewSmokeScenarios.map(([title, viewCaseProps]) => {
const fullSmokeScenarios = createSmokeScenarios<LinkProps>(viewCaseProps, {
underline: underlineCases,
visitable: visitableCases,
});

return (
<div key={title}>
<h2>{title}</h2>
{fullSmokeScenarios.map(([fullTitle, props]) => {
return (
<div key={fullTitle}>
<h4>{fullTitle}</h4>
<div>
<Link {...props} />
</div>
</div>
);
})}
</div>
);
})}
</div>,
);

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

export const underlineCases: Cases<LinkProps['underline']> = [true];
export const visitableCases: Cases<LinkProps['visitable']> = [true];
export const viewCases: Cases<LinkProps['view']> = ['normal', 'primary', 'secondary'];

0 comments on commit aa6251c

Please sign in to comment.