Skip to content

Commit 6ddc1df

Browse files
lukasbrizabedrich-schindler
authored andcommitted
Transform miscellaneous section form jest to playwright (#595)
1 parent b5ca4ad commit 6ddc1df

File tree

97 files changed

+1303
-529
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

97 files changed

+1303
-529
lines changed
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
import React from 'react';
2+
import {
3+
expect,
4+
test,
5+
} from '@playwright/experimental-ct-react';
6+
import {
7+
mixPropTests,
8+
propTests,
9+
} from '../../../../tests/playwright';
10+
import { BadgeForTest } from './Badge.story';
11+
import { labelPropTest } from './_propTests/labelPropTest';
12+
import { priorityPropTest } from './_propTests/priorityPropTest';
13+
14+
test.describe('Badge', () => {
15+
test.describe('visual', () => {
16+
[
17+
...propTests.defaultComponentPropTest,
18+
...labelPropTest,
19+
...mixPropTests([
20+
[
21+
...propTests.feedbackColorPropTest,
22+
...propTests.neutralColorPropTest,
23+
],
24+
priorityPropTest,
25+
]),
26+
].forEach(({
27+
name,
28+
onBeforeTest,
29+
onBeforeSnapshot,
30+
props,
31+
}) => {
32+
test(name, async ({
33+
mount,
34+
page,
35+
}) => {
36+
if (onBeforeTest) {
37+
await onBeforeTest(page);
38+
}
39+
40+
const component = await mount(
41+
<BadgeForTest
42+
{...props}
43+
/>,
44+
);
45+
46+
if (onBeforeSnapshot) {
47+
await onBeforeSnapshot(page, component);
48+
}
49+
50+
const screenshot = await component.screenshot();
51+
expect(screenshot).toMatchSnapshot();
52+
});
53+
});
54+
});
55+
56+
test.describe('non-visual', () => {
57+
test('id', async ({ mount }) => {
58+
const component = await mount(
59+
<BadgeForTest
60+
id="test-id"
61+
/>,
62+
);
63+
64+
await expect(component).toHaveAttribute('id', 'test-id');
65+
});
66+
});
67+
});

0 commit comments

Comments
 (0)