Skip to content

Commit deeddc1

Browse files
committed
fixup! fixup! fixup! Transform Action jest tests into playwright (#592)
1 parent 47fa3c2 commit deeddc1

File tree

265 files changed

+1403
-432
lines changed

Some content is hidden

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

265 files changed

+1403
-432
lines changed

src/components/Alert/__tests__/Alert.spec.tsx

+5
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ test.describe('Alert', () => {
2020
].forEach(({
2121
name,
2222
onBeforeTest,
23+
onBeforeSnapshot,
2324
props,
2425
}) => {
2526
test(name, async ({
@@ -36,6 +37,10 @@ test.describe('Alert', () => {
3637
/>,
3738
);
3839

40+
if (onBeforeSnapshot) {
41+
await onBeforeSnapshot(page, component);
42+
}
43+
3944
const screenshot = await component.screenshot();
4045
expect(screenshot).toMatchSnapshot();
4146
});

src/components/Button/__tests__/Button.spec.tsx

+5
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ test.describe('Button', () => {
3737
].forEach(({
3838
name,
3939
onBeforeTest,
40+
onBeforeSnapshot,
4041
props,
4142
}) => {
4243
test(name, async ({
@@ -53,6 +54,10 @@ test.describe('Button', () => {
5354
/>,
5455
);
5556

57+
if (onBeforeSnapshot) {
58+
await onBeforeSnapshot(page, component);
59+
}
60+
5661
const screenshot = await component.screenshot();
5762
expect(screenshot).toMatchSnapshot();
5863
});

src/components/CheckboxField/__tests__/CheckboxField.spec.tsx

+21
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ test.describe('CheckboxField', () => {
4646
].forEach(({
4747
name,
4848
onBeforeTest,
49+
onBeforeSnapshot,
4950
props,
5051
}) => {
5152
test(name, async ({
@@ -62,6 +63,10 @@ test.describe('CheckboxField', () => {
6263
/>,
6364
);
6465

66+
if (onBeforeSnapshot) {
67+
await onBeforeSnapshot(page, component);
68+
}
69+
6570
const screenshot = await component.screenshot();
6671
expect(screenshot).toMatchSnapshot();
6772
});
@@ -118,6 +123,17 @@ test.describe('CheckboxField', () => {
118123
await component.click({ force: true });
119124
expect(changeCalled).toBeTruthy();
120125
});
126+
127+
test('check on space press when focused', async ({ mount }) => {
128+
const component = await mount(
129+
<CheckboxFieldForTest />,
130+
);
131+
132+
const input = component.getByRole('checkbox');
133+
await input.focus();
134+
await input.press('Space');
135+
await expect(input).toBeChecked();
136+
});
121137
});
122138
});
123139

@@ -128,6 +144,7 @@ test.describe('CheckboxField', () => {
128144
].forEach(({
129145
name,
130146
onBeforeTest,
147+
onBeforeSnapshot,
131148
props,
132149
}) => {
133150
test(name, async ({
@@ -144,6 +161,10 @@ test.describe('CheckboxField', () => {
144161
/>,
145162
);
146163

164+
if (onBeforeSnapshot) {
165+
await onBeforeSnapshot(page, component);
166+
}
167+
147168
const screenshot = await component.screenshot();
148169
expect(screenshot).toMatchSnapshot();
149170
});

src/components/Radio/__tests__/Radio.spec.tsx

+23
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ test.describe('CheckboxField', () => {
5555
].forEach(({
5656
name,
5757
onBeforeTest,
58+
onBeforeSnapshot,
5859
props,
5960
}) => {
6061
test(name, async ({
@@ -71,6 +72,10 @@ test.describe('CheckboxField', () => {
7172
/>,
7273
);
7374

75+
if (onBeforeSnapshot) {
76+
await onBeforeSnapshot(page, component);
77+
}
78+
7479
const screenshot = await component.screenshot();
7580
expect(screenshot).toMatchSnapshot();
7681
});
@@ -121,5 +126,23 @@ test.describe('CheckboxField', () => {
121126
await component.getByText(options[1].label).click({ force: true });
122127
expect(changeCalled).toBeTruthy();
123128
});
129+
130+
test('check on space press when focused', async ({ mount }) => {
131+
let changeCalled = false;
132+
const testId = 'testId';
133+
134+
const component = await mount(
135+
<RadioForTest
136+
id={testId}
137+
onChange={() => { changeCalled = true; }}
138+
options={options}
139+
/>,
140+
);
141+
142+
const input = component.locator(`input[id=${testId}__item__${options[1].key}]`);
143+
await input.focus();
144+
await input.press('Space');
145+
expect(changeCalled).toBeTruthy();
146+
});
124147
});
125148
});

0 commit comments

Comments
 (0)