diff --git a/src/components/Text/__snapshots__/Text.visual.test.tsx-snapshots/Text-smoke-long-text-light-chromium-linux.png b/src/components/Text/__snapshots__/Text.visual.test.tsx-snapshots/Text-smoke-long-text-light-chromium-linux.png new file mode 100644 index 000000000..9d545fa3a Binary files /dev/null and b/src/components/Text/__snapshots__/Text.visual.test.tsx-snapshots/Text-smoke-long-text-light-chromium-linux.png differ diff --git a/src/components/Text/__snapshots__/Text.visual.test.tsx-snapshots/Text-smoke-regular-light-chromium-linux.png b/src/components/Text/__snapshots__/Text.visual.test.tsx-snapshots/Text-smoke-regular-light-chromium-linux.png new file mode 100644 index 000000000..fa21611aa Binary files /dev/null and b/src/components/Text/__snapshots__/Text.visual.test.tsx-snapshots/Text-smoke-regular-light-chromium-linux.png differ diff --git a/src/components/Text/__snapshots__/Text.visual.test.tsx-snapshots/Text-smoke-render-story-Ellipsis-light-chromium-linux.png b/src/components/Text/__snapshots__/Text.visual.test.tsx-snapshots/Text-smoke-render-story-Ellipsis-light-chromium-linux.png new file mode 100644 index 000000000..75cdda93c Binary files /dev/null and b/src/components/Text/__snapshots__/Text.visual.test.tsx-snapshots/Text-smoke-render-story-Ellipsis-light-chromium-linux.png differ diff --git a/src/components/Text/__snapshots__/Text.visual.test.tsx-snapshots/Text-smoke-render-story-WordBreak-light-chromium-linux.png b/src/components/Text/__snapshots__/Text.visual.test.tsx-snapshots/Text-smoke-render-story-WordBreak-light-chromium-linux.png new file mode 100644 index 000000000..a66ea5204 Binary files /dev/null and b/src/components/Text/__snapshots__/Text.visual.test.tsx-snapshots/Text-smoke-render-story-WordBreak-light-chromium-linux.png differ diff --git a/src/components/Text/__tests__/Text.visual.test.tsx b/src/components/Text/__tests__/Text.visual.test.tsx new file mode 100644 index 000000000..8c92d016c --- /dev/null +++ b/src/components/Text/__tests__/Text.visual.test.tsx @@ -0,0 +1,86 @@ +import React from 'react'; + +import {smokeTest, test} from '~playwright/core'; + +import {createSmokeScenarios} from '../../../stories/tests-factory/create-smoke-scenarios'; +import type {TextProps} from '../Text'; + +import {colorCases, ellipsisCases, variantCases, whiteSpaceCases, wordBreakCases} from './cases'; +import {TestText} from './helpersPlaywright'; +import {TextStories} from './stories'; + +const longText = + 'Lorem ipsum dolor sit, amet consectetur adipisicing elit. Voluptates asperiores accusamus est, ab rerum harum hic delectus fuga veniam! Hic, atque, quia sunt consectetur eius corrupti, expedita sapiente exercitationem aperiam quibusdam libero ipsa veritatis quisquam! Debitis eos unde, blanditiis ipsam adipisci, soluta incidunt architecto quidem, repellat commodi tempore! Enim assumenda nam esse laudantium sequi quaerat maiores, voluptatum quibusdam temporibus nulla perspiciatis! Corrupti error aliquid iure asperiores voluptate. Nisi temporibus nesciunt quasi animi, accusamus officia debitis voluptatum ratione ullam delectus, adipisci, repellendus vitae in amet sit magni iste impedit? Exercitationem rerum impedit sed earum iusto modi et officia aspernatur quibusdam? Fugit.'; + +test.describe('Text', {tag: '@Text'}, () => { + smokeTest('regular', async ({mount, expectScreenshot}) => { + const smokeScenarios = createSmokeScenarios( + {}, + { + color: colorCases, + variant: variantCases, + }, + ); + + await mount( +
+ {smokeScenarios.map(([title, props]) => ( +
+

{title}

+
+ Text +
+
+ ))} +
, + ); + + await expectScreenshot({ + themes: ['light'], + }); + }); + + smokeTest('long text', async ({mount, expectScreenshot}) => { + const smokeScenarios = createSmokeScenarios( + {}, + { + ellipsis: ellipsisCases, + whiteSpace: whiteSpaceCases, + wordBreak: wordBreakCases, + }, + ); + + await mount( +
+ {smokeScenarios.map(([title, props]) => ( +
+

{title}

+
+ {longText} +
+
+ ))} +
, + ); + + await expectScreenshot({ + themes: ['light'], + }); + }); + + smokeTest('render story ', async ({mount, expectScreenshot}) => { + await mount(); + + await expectScreenshot({ + themes: ['light'], + }); + }); + + smokeTest('render story ', async ({mount, expectScreenshot}) => { + await mount(); + + await expectScreenshot({ + themes: ['light'], + }); + }); +}); diff --git a/src/components/Text/__tests__/cases.tsx b/src/components/Text/__tests__/cases.tsx new file mode 100644 index 000000000..9fc367f00 --- /dev/null +++ b/src/components/Text/__tests__/cases.tsx @@ -0,0 +1,63 @@ +import type {Cases} from '../../../stories/tests-factory/models'; +import type {TextProps} from '../Text'; + +export const colorCases: Cases = [ + 'primary', + 'complementary', + 'secondary', + 'hint', + 'info', + 'info-heavy', + 'positive', + 'positive-heavy', + 'warning', + 'warning-heavy', + 'danger', + 'danger-heavy', + 'utility', + 'utility-heavy', + 'misc', + 'misc-heavy', + 'brand', + 'link', + 'link-hover', + 'link-visited', + 'link-visited-hover', + 'dark-primary', + 'dark-complementary', + 'dark-secondary', + 'light-primary', + 'light-complementary', + 'light-secondary', + 'light-hint', + 'inverted-primary', + 'inverted-complementary', + 'inverted-secondary', + 'inverted-hint', +]; +export const variantCases: Cases = [ + 'display-4', + 'display-3', + 'display-2', + 'display-1', + 'header-2', + 'header-1', + 'subheader-3', + 'subheader-2', + 'subheader-1', + 'body-3', + 'body-2', + 'body-1', + 'body-short', + 'caption-2', + 'caption-1', + 'code-3', + 'code-inline-3', + 'code-2', + 'code-inline-2', + 'code-1', + 'code-inline-1', +]; +export const ellipsisCases: Cases = [true]; +export const whiteSpaceCases: Cases = ['nowrap', 'break-spaces']; +export const wordBreakCases: Cases = ['break-all', 'break-word']; diff --git a/src/components/Text/__tests__/helpersPlaywright.tsx b/src/components/Text/__tests__/helpersPlaywright.tsx new file mode 100644 index 000000000..a6b435014 --- /dev/null +++ b/src/components/Text/__tests__/helpersPlaywright.tsx @@ -0,0 +1,14 @@ +import React from 'react'; + +import type {TextProps} from '../Text'; +import {Text} from '../Text'; + +export const TestText = (props: Partial) => { + return ( + Text} + {...props} + /> + ); +}; diff --git a/src/components/Text/__tests__/stories.ts b/src/components/Text/__tests__/stories.ts new file mode 100644 index 000000000..58c882259 --- /dev/null +++ b/src/components/Text/__tests__/stories.ts @@ -0,0 +1,5 @@ +import {composeStories} from '@storybook/react'; + +import * as CSFStories from '../__stories__/Text.stories'; + +export const TextStories = composeStories(CSFStories);