Skip to content

Commit aa0efb7

Browse files
committed
refactor(e2e): update Text e2e test
1 parent 288ec51 commit aa0efb7

File tree

7 files changed

+54
-143
lines changed

7 files changed

+54
-143
lines changed
7.03 KB
Loading
-351 Bytes
Loading
7.03 KB
Loading
7.03 KB
Loading
7.21 KB
Loading

e2e/components/Text.test.ts

Lines changed: 49 additions & 138 deletions
Original file line numberDiff line numberDiff line change
@@ -1,150 +1,61 @@
11
import {test, expect} from '@playwright/test'
22
import {visit} from '../test-helpers/storybook'
33

4+
const stories = [
5+
{
6+
title: 'Default',
7+
id: 'components-text--default',
8+
},
9+
{
10+
title: 'Small',
11+
id: 'components-text-features--size-small',
12+
},
13+
{
14+
title: 'Medium',
15+
id: 'components-text-features--size-medium',
16+
},
17+
{
18+
title: 'Large',
19+
id: 'components-text-features--size-large',
20+
},
21+
{
22+
title: 'LightWeight',
23+
id: 'components-text-features--light-weight',
24+
},
25+
{
26+
title: 'NormalWeight',
27+
id: 'components-text-features--normal-weight',
28+
},
29+
{
30+
title: 'MediumWeight',
31+
id: 'components-text-features--medium-weight',
32+
},
33+
{
34+
title: 'SemiboldWeight',
35+
id: 'components-text-features--semibold-weight',
36+
},
37+
] as const
38+
439
// only testing light theme because this component is only concerned with text size and weight
540

641
test.describe('Text', () => {
7-
test.describe('Default', () => {
8-
test('default @vrt', async ({page}) => {
9-
await visit(page, {
10-
id: 'components-text--default',
11-
})
12-
13-
// Default state
14-
expect(await page.screenshot()).toMatchSnapshot(`Text.Default.png`)
15-
})
16-
17-
test('axe @aat', async ({page}) => {
18-
await visit(page, {
19-
id: 'components-text--default',
20-
})
21-
await expect(page).toHaveNoViolations()
22-
})
23-
})
24-
25-
test.describe('Small', () => {
26-
test('default @vrt', async ({page}) => {
27-
await visit(page, {
28-
id: 'components-text-features--size-small',
29-
})
30-
31-
// Default state
32-
expect(await page.screenshot()).toMatchSnapshot(`Text.Small.png`)
33-
})
34-
35-
test('axe @aat', async ({page}) => {
36-
await visit(page, {
37-
id: 'components-text-features--size-small',
38-
})
39-
await expect(page).toHaveNoViolations()
40-
})
41-
})
42+
for (const story of stories) {
43+
test.describe(story.title, () => {
44+
test('default @vrt', async ({page}) => {
45+
await visit(page, {
46+
id: story.id,
47+
})
4248

43-
test.describe('Medium', () => {
44-
test('default @vrt', async ({page}) => {
45-
await visit(page, {
46-
id: 'components-text-features--size-medium',
49+
// Default state
50+
expect(await page.screenshot()).toMatchSnapshot(`Text.${story.title}.png`)
4751
})
4852

49-
// Default state
50-
expect(await page.screenshot()).toMatchSnapshot(`Text.Medium.png`)
51-
})
52-
53-
test('axe @aat', async ({page}) => {
54-
await visit(page, {
55-
id: 'components-text-features--size-medium',
56-
})
57-
await expect(page).toHaveNoViolations()
58-
})
59-
})
60-
61-
test.describe('Large', () => {
62-
test('default @vrt', async ({page}) => {
63-
await visit(page, {
64-
id: 'components-text-features--size-large',
65-
})
66-
67-
// Default state
68-
expect(await page.screenshot()).toMatchSnapshot(`Text.Large.png`)
69-
})
70-
71-
test('axe @aat', async ({page}) => {
72-
await visit(page, {
73-
id: 'components-text-features--size-large',
74-
})
75-
await expect(page).toHaveNoViolations()
76-
})
77-
})
78-
79-
test.describe('LightWeight', () => {
80-
test('default @vrt', async ({page}) => {
81-
await visit(page, {
82-
id: 'components-text-features--light-weight',
83-
})
84-
85-
// Default state
86-
expect(await page.screenshot()).toMatchSnapshot(`Text.Light.png`)
87-
})
88-
89-
test('axe @aat', async ({page}) => {
90-
await visit(page, {
91-
id: 'components-text-features--light-weight',
92-
})
93-
await expect(page).toHaveNoViolations()
94-
})
95-
})
96-
97-
test.describe('NormalWeight', () => {
98-
test('default @vrt', async ({page}) => {
99-
await visit(page, {
100-
id: 'components-text-features--normal-weight',
101-
})
102-
103-
// Default state
104-
expect(await page.screenshot()).toMatchSnapshot(`Text.Normal.png`)
105-
})
106-
107-
test('axe @aat', async ({page}) => {
108-
await visit(page, {
109-
id: 'components-text-features--normal-weight',
110-
})
111-
await expect(page).toHaveNoViolations()
112-
})
113-
})
114-
115-
test.describe('MediumWeight', () => {
116-
test('default @vrt', async ({page}) => {
117-
await visit(page, {
118-
id: 'components-text-features--medium-weight',
119-
})
120-
121-
// Default state
122-
expect(await page.screenshot()).toMatchSnapshot(`Text.Medium.png`)
123-
})
124-
125-
test('axe @aat', async ({page}) => {
126-
await visit(page, {
127-
id: 'components-text-features--medium-weight',
128-
})
129-
await expect(page).toHaveNoViolations()
130-
})
131-
})
132-
133-
test.describe('SemiboldWeight', () => {
134-
test('default @vrt', async ({page}) => {
135-
await visit(page, {
136-
id: 'components-text-features--semibold-weight',
137-
})
138-
139-
// Default state
140-
expect(await page.screenshot()).toMatchSnapshot(`Text.Semibold.png`)
141-
})
142-
143-
test('axe @aat', async ({page}) => {
144-
await visit(page, {
145-
id: 'components-text-features--semibold-weight',
53+
test('axe @aat', async ({page}) => {
54+
await visit(page, {
55+
id: story.id,
56+
})
57+
await expect(page).toHaveNoViolations()
14658
})
147-
await expect(page).toHaveNoViolations()
14859
})
149-
})
60+
}
15061
})

package-lock.json

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)