Skip to content

Commit 29c3f83

Browse files
committed
fixup! fixup! fixup! fixup! fixup! Transform Action jest tests into playwright (#592)
1 parent 152a97c commit 29c3f83

File tree

562 files changed

+182
-173
lines changed

Some content is hidden

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

562 files changed

+182
-173
lines changed

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

+8-8
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import {
1313
CheckboxForFormLayoutTests,
1414
} from './CheckboxField.story';
1515
import type { CheckboxForFormLayoutTestsProps } from './CheckboxField.story';
16-
import { checkedPropTest } from './_propTests/checkedPropTest';
1716

1817
test.describe('CheckboxField', () => {
1918
test.describe('base', () => {
@@ -24,24 +23,25 @@ test.describe('CheckboxField', () => {
2423
...propTests.renderAsRequiredPropTest,
2524
...propTests.isLabelVisiblePropTest,
2625
...propTests.labelPositionPropTest,
26+
...propTests.helperTextAndValidationTextPropType,
2727
...mixPropTests([
28-
checkedPropTest,
28+
propTests.checkedPropTest,
2929
propTests.disabledPropTest,
3030
propTests.validationStatePropTest,
3131
]),
3232
...mixPropTests([
33-
checkedPropTest,
33+
propTests.checkedPropTest,
34+
propTests.validationStatePropTest,
3435
propTests.requiredPropTest,
3536
]),
3637
...mixPropTests([
37-
checkedPropTest,
38-
propTests.validationTextPropTest,
38+
propTests.checkedPropTest,
3939
propTests.validationStatePropTest,
40+
propTests.renderAsRequiredPropTest,
4041
]),
4142
...mixPropTests([
42-
checkedPropTest,
43-
propTests.validationTextPropTest,
44-
propTests.helpTextPropTest,
43+
propTests.checkedPropTest,
44+
propTests.requiredPropTest,
4545
]),
4646
].forEach(({
4747
name,

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

+6-1
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,19 @@ test.describe('Radio', () => {
4444
...propTests.isLabelVisiblePropTest,
4545
...propTests.renderAsRequiredPropTest,
4646
...propTests.layoutPropTest,
47+
...propTests.helperTextAndValidationTextPropType,
4748
...mixPropTests([
4849
propTests.validationStatePropTest,
4950
propTests.validationTextPropTest,
5051
propTests.disabledPropTest,
5152
]),
5253
...mixPropTests([
5354
propTests.validationStatePropTest,
54-
propTests.helpTextPropTest,
55+
propTests.requiredPropTest,
56+
]),
57+
...mixPropTests([
58+
propTests.validationStatePropTest,
59+
propTests.renderAsRequiredPropTest,
5560
]),
5661
...mixPropTests([
5762
partialDisabledOptionsPropTest,

src/components/Radio/__tests__/Radio.story.tsx

-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ export const RadioForTest = ({
3434
options={defaultOptions}
3535
value={defaultOptions[0].value}
3636
{...props}
37-
3837
/>
3938
);
4039

src/components/Radio/__tests__/_propTests/partialDisabledOptionsPropTest.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@ const options = [
1717

1818
export const partialDisabledOptionsPropTest: PropTests = [
1919
{
20-
name: 'partialDisabledWithDisabledValue',
20+
name: 'options:shape[basePartialDisabledWithDisabledValue]',
2121
props: {
2222
options,
2323
value: 'value1',
2424
},
2525
},
2626
{
27-
name: 'partialDisabledWithoutDisabledValue',
27+
name: 'options:shape[basePartialDisabledWithoutDisabledValue]',
2828
props: {
2929
options,
3030
value: 'value2',

src/components/SelectField/__tests__/SelectField.spec.tsx

+55-37
Original file line numberDiff line numberDiff line change
@@ -57,23 +57,24 @@ test.describe('SelectField', () => {
5757
...propTests.renderAsRequiredPropTest,
5858
...propTests.isLabelVisiblePropTest,
5959
...propTests.requiredPropTest,
60+
...propTests.helperTextAndValidationTextPropType,
6061
...propTests.sizePropTest,
6162
...mixPropTests([
6263
propTests.layoutPropTest,
6364
propTests.fullWidthPropTest,
6465
]),
6566
...mixPropTests([
66-
propTests.disabledPropTest,
67-
propTests.variantPropTest,
6867
propTests.validationStatePropTest,
68+
propTests.requiredPropTest,
6969
]),
7070
...mixPropTests([
71-
propTests.validationTextPropTest,
7271
propTests.validationStatePropTest,
72+
propTests.renderAsRequiredPropTest,
7373
]),
7474
...mixPropTests([
75-
propTests.validationTextPropTest,
76-
propTests.helpTextPropTest,
75+
propTests.disabledPropTest,
76+
propTests.variantPropTest,
77+
propTests.validationStatePropTest,
7778
]),
7879
].forEach(({
7980
name,
@@ -99,44 +100,45 @@ test.describe('SelectField', () => {
99100
await onBeforeSnapshot(page, component);
100101
}
101102

102-
const screenshot = await component.screenshot();
103+
const screenshot = await component.screenshot({ animations: 'disabled' });
103104
expect(screenshot).toMatchSnapshot();
104105
});
105106
});
106-
});
107107

108-
/**
109-
* Full page screenshot is required for option tests because native select options are rendered outside of the DOM.
110-
*/
111-
test.describe('visual-fullPage', () => {
112-
[
113-
...openSelectFieldOptionsTest,
114-
].forEach(({
115-
name,
116-
onBeforeTest,
117-
onBeforeSnapshot,
118-
props,
119-
}) => {
120-
test(name, async ({
121-
mount,
122-
page,
108+
/**
109+
* Full page screenshot is required for option tests
110+
* because native select options are rendered outside of the DOM.
111+
*/
112+
test.describe('fullPage', () => {
113+
[
114+
...openSelectFieldOptionsTest,
115+
].forEach(({
116+
name,
117+
onBeforeTest,
118+
onBeforeSnapshot,
119+
props,
123120
}) => {
124-
if (onBeforeTest) {
125-
await onBeforeTest(page);
126-
}
121+
test(name, async ({
122+
mount,
123+
page,
124+
}) => {
125+
if (onBeforeTest) {
126+
await onBeforeTest(page);
127+
}
127128

128-
const component = await mount(
129-
<SelectFieldForTest
130-
{...props}
131-
/>,
132-
);
129+
const component = await mount(
130+
<SelectFieldForTest
131+
{...props}
132+
/>,
133+
);
133134

134-
if (onBeforeSnapshot) {
135-
await onBeforeSnapshot(page, component);
136-
}
135+
if (onBeforeSnapshot) {
136+
await onBeforeSnapshot(page, component);
137+
}
137138

138-
const screenshot = await page.screenshot();
139-
expect(screenshot).toMatchSnapshot();
139+
const screenshot = await page.screenshot({ animations: 'disabled' });
140+
expect(screenshot).toMatchSnapshot({ maxDiffPixelRatio: 0.001 });
141+
});
140142
});
141143
});
142144
});
@@ -227,7 +229,7 @@ test.describe('SelectField', () => {
227229
expect(changeCalled).toBeTruthy();
228230
});
229231

230-
test('change options on up and down key press', async ({ mount }) => {
232+
test('change options on down key press', async ({ mount }) => {
231233
let changeCalled = false;
232234

233235
const component = await mount(
@@ -243,6 +245,22 @@ test.describe('SelectField', () => {
243245
await select.press('ArrowDown');
244246
expect(changeCalled).toBeTruthy();
245247
});
248+
test('change options on up key press', async ({ mount }) => {
249+
let changeCalled = false;
250+
251+
const component = await mount(
252+
<SelectFieldForTest
253+
onChange={() => { changeCalled = true; }}
254+
options={baseOptions}
255+
value={baseOptions[1].value}
256+
/>,
257+
);
258+
259+
const select = component.getByRole('combobox');
260+
await select.focus();
261+
await select.press('ArrowUp');
262+
expect(changeCalled).toBeTruthy();
263+
});
246264
});
247265
});
248266

@@ -274,7 +292,7 @@ test.describe('SelectField', () => {
274292
await onBeforeSnapshot(page, component);
275293
}
276294

277-
const screenshot = await component.screenshot();
295+
const screenshot = await component.screenshot({ animations: 'disabled' });
278296
expect(screenshot).toMatchSnapshot();
279297
});
280298
});

0 commit comments

Comments
 (0)