Skip to content

Commit 47fa3c2

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

File tree

47 files changed

+90
-130
lines changed

Some content is hidden

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

47 files changed

+90
-130
lines changed

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

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { AlertForTest } from './Alert.story';
99
test.describe('Alert', () => {
1010
test.describe('visual', () => {
1111
[
12+
...propTests.defaultComponentPropTest,
1213
...propTests.feedbackColorPropTest,
1314
...propTests.neutralColorPropTest,
1415
...propTests.iconPropTest,

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

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {
1515
test.describe('Button', () => {
1616
test.describe('visual', () => {
1717
[
18+
...propTests.defaultComponentPropTest,
1819
...propTests.afterLabelPropTest,
1920
...propTests.beforeLabelPropTest,
2021
...propTests.blockPropTest,

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

+12-10
Original file line numberDiff line numberDiff line change
@@ -10,36 +10,38 @@ import {
1010
import {
1111
CheckboxFieldForTest,
1212
CheckboxFieldForRefTest,
13-
CheckboxWForFormLayoutTests,
13+
CheckboxForFormLayoutTests,
1414
} from './CheckboxField.story';
15+
import type { CheckboxForFormLayoutTestsProps } from './CheckboxField.story';
1516
import { checkedPropTest } from './_propTests/checkedPropTest';
1617

1718
test.describe('CheckboxField', () => {
1819
test.describe('base', () => {
1920
test.describe('visual', () => {
2021
[
22+
...propTests.defaultComponentPropTest,
2123
...propTests.labelPropTest,
2224
...propTests.renderAsRequiredPropTest,
2325
...propTests.isLabelVisiblePropTest,
24-
...propTests.labelPositionPropTest(),
26+
...propTests.labelPositionPropTest,
2527
...mixPropTests([
2628
checkedPropTest,
2729
propTests.disabledPropTest,
28-
propTests.validationStatePropTest(true),
30+
propTests.validationStatePropTest,
2931
]),
3032
...mixPropTests([
3133
checkedPropTest,
3234
propTests.requiredPropTest,
3335
]),
3436
...mixPropTests([
3537
checkedPropTest,
36-
propTests.validationTextPropTest(true),
37-
propTests.validationStatePropTest(true),
38+
propTests.validationTextPropTest,
39+
propTests.validationStatePropTest,
3840
]),
3941
...mixPropTests([
4042
checkedPropTest,
41-
propTests.validationTextPropTest(true),
42-
propTests.helpTextPropTest(true),
43+
propTests.validationTextPropTest,
44+
propTests.helpTextPropTest,
4345
]),
4446
].forEach(({
4547
name,
@@ -122,7 +124,7 @@ test.describe('CheckboxField', () => {
122124
test.describe('formLayout', () => {
123125
test.describe('visual', () => {
124126
[
125-
...propTests.layoutPropTest(true),
127+
...propTests.layoutPropTest,
126128
].forEach(({
127129
name,
128130
onBeforeTest,
@@ -137,8 +139,8 @@ test.describe('CheckboxField', () => {
137139
}
138140

139141
const component = await mount(
140-
<CheckboxWForFormLayoutTests
141-
{...props}
142+
<CheckboxForFormLayoutTests
143+
{...props as unknown as CheckboxForFormLayoutTestsProps}
142144
/>,
143145
);
144146

src/components/CheckboxField/__tests__/CheckboxField.story.tsx

+5-5
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ type CheckboxFieldForRefTestProps = CheckboxFieldForTestProps & {
1313
testRefAttrName: string;
1414
testRefAttrValue: string;
1515
};
16-
type CheckboxWForFormLayoutTestsProps = CheckboxFieldForTestProps & {
17-
layout: 'vertical' | 'horizontal' | undefined
16+
export type CheckboxForFormLayoutTestsProps = CheckboxFieldForTestProps & {
17+
layout: 'vertical' | 'horizontal'
1818
};
1919

2020
const defaultLabel = 'test-label';
@@ -48,10 +48,10 @@ export const CheckboxFieldForRefTest = ({
4848
);
4949
};
5050

51-
export const CheckboxWForFormLayoutTests = ({
52-
layout = undefined,
51+
export const CheckboxForFormLayoutTests = ({
52+
layout,
5353
...props
54-
} : CheckboxWForFormLayoutTestsProps) => {
54+
} : CheckboxForFormLayoutTestsProps) => {
5555
const values = useMemo(() => ({ layout }), [layout]);
5656

5757
return (

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

+7-6
Original file line numberDiff line numberDiff line change
@@ -33,23 +33,24 @@ const options = [
3333
test.describe('CheckboxField', () => {
3434
test.describe('visual', () => {
3535
[
36+
...propTests.defaultComponentPropTest,
3637
...propTests.requiredPropTest,
3738
...propTests.labelPropTest,
3839
...propTests.isLabelVisiblePropTest,
3940
...propTests.renderAsRequiredPropTest,
40-
...propTests.layoutPropTest(true),
41+
...propTests.layoutPropTest,
4142
...mixPropTests([
42-
propTests.validationStatePropTest(true),
43-
propTests.validationTextPropTest(true),
43+
propTests.validationStatePropTest,
44+
propTests.validationTextPropTest,
4445
propTests.disabledPropTest,
4546
]),
4647
...mixPropTests([
47-
propTests.validationStatePropTest(true),
48-
propTests.helpTextPropTest(true),
48+
propTests.validationStatePropTest,
49+
propTests.helpTextPropTest,
4950
]),
5051
...mixPropTests([
5152
partialDisabledOptionsPropTest,
52-
propTests.validationStatePropTest(),
53+
propTests.validationStatePropTest,
5354
]),
5455
].forEach(({
5556
name,

tests/playwright/index.ts

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { actionColorPropTest } from './propTests/actionColorPropTest';
22
import { afterLabelPropTest } from './propTests/afterLabelPropTest';
33
import { beforeLabelPropTest } from './propTests/beforeLabelPropTest';
44
import { blockPropTest } from './propTests/blockPropTest';
5+
import { defaultComponentPropTest } from './propTests/defaultComponentPropTest';
56
import { disabledPropTest } from './propTests/disabledPropTest';
67
import { endCornerPropTest } from './propTests/endCornerPropTest';
78
import { feedbackColorPropTest } from './propTests/feedbackColorPropTest';
@@ -31,6 +32,7 @@ export const propTests = {
3132
afterLabelPropTest,
3233
beforeLabelPropTest,
3334
blockPropTest,
35+
defaultComponentPropTest,
3436
disabledPropTest,
3537
endCornerPropTest,
3638
feedbackColorPropTest,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import type { PropTests } from '../types';
2+
3+
export const defaultComponentPropTest: PropTests = [
4+
{
5+
name: 'defaultComponentProps',
6+
props: {},
7+
},
8+
];
+10-21
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,12 @@
11
import type { PropTests } from '../types';
22

3-
export const helpTextPropTest = (useUndefined: boolean = false): PropTests => {
4-
const propTests = [
5-
{
6-
name: 'helpText=long',
7-
props: { helpText: 'Extra long helpText that exceeds regular length that anyone would expect to input in this property.' },
8-
},
9-
{
10-
name: 'helpText=normal',
11-
props: { helpText: 'Some normal helpText.' },
12-
},
13-
];
14-
15-
if (useUndefined === true) {
16-
propTests.push({
17-
name: 'helpText=undefined',
18-
props: { helpText: undefined },
19-
});
20-
}
21-
22-
return propTests;
23-
};
3+
export const helpTextPropTest: PropTests = [
4+
{
5+
name: 'helpText=long',
6+
props: { helpText: 'Extra long helpText that exceeds regular length that anyone would expect to input in this property.' },
7+
},
8+
{
9+
name: 'helpText=normal',
10+
props: { helpText: 'Some normal helpText.' },
11+
},
12+
];
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,12 @@
11
import type { PropTests } from '../types';
22

3-
export const labelPositionPropTest = (useUndefined: boolean = false): PropTests => {
4-
const propTests = [
5-
{
6-
name: 'labelPosition=before',
7-
props: { labelPosition: 'before' },
8-
},
9-
{
10-
name: 'labelPosition=after',
11-
props: { labelPosition: 'after' },
12-
},
13-
];
14-
15-
if (useUndefined === true) {
16-
propTests.push({
17-
name: 'labelPosition=undefined',
18-
props: { labelPosition: undefined },
19-
});
20-
}
21-
22-
return propTests;
23-
};
3+
export const labelPositionPropTest: PropTests = [
4+
{
5+
name: 'labelPosition=before',
6+
props: { labelPosition: 'before' },
7+
},
8+
{
9+
name: 'labelPosition=after',
10+
props: { labelPosition: 'after' },
11+
},
12+
];
+10-21
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,12 @@
11
import type { PropTests } from '../types';
22

3-
export const layoutPropTest = (useUndefined: boolean = false): PropTests => {
4-
const propTests = [
5-
{
6-
name: 'layout=vertical',
7-
props: { layout: 'vertical' },
8-
},
9-
{
10-
name: 'layout=horizontal',
11-
props: { layout: 'horizontal' },
12-
},
13-
];
14-
15-
if (useUndefined === true) {
16-
propTests.push({
17-
name: 'layout=undefined',
18-
props: { layout: undefined },
19-
});
20-
}
21-
22-
return propTests;
23-
};
3+
export const layoutPropTest: PropTests = [
4+
{
5+
name: 'layout=vertical',
6+
props: { layout: 'vertical' },
7+
},
8+
{
9+
name: 'layout=horizontal',
10+
props: { layout: 'horizontal' },
11+
},
12+
];
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,16 @@
11
import type { PropTests } from '../types';
22

3-
export const validationStatePropTest = (useUndefined: boolean = false): PropTests => {
4-
const propTests = [
5-
{
6-
name: 'validationState=valid',
7-
props: { validationState: 'valid' },
8-
},
9-
{
10-
name: 'validationState=warning',
11-
props: { validationState: 'warning' },
12-
},
13-
{
14-
name: 'validationState=invalid',
15-
props: { validationState: 'invalid' },
16-
},
17-
];
18-
19-
if (useUndefined === true) {
20-
propTests.push({
21-
name: 'validationState=undefined',
22-
props: { validationState: undefined },
23-
});
24-
}
25-
26-
return propTests;
27-
};
3+
export const validationStatePropTest: PropTests = [
4+
{
5+
name: 'validationState=valid',
6+
props: { validationState: 'valid' },
7+
},
8+
{
9+
name: 'validationState=warning',
10+
props: { validationState: 'warning' },
11+
},
12+
{
13+
name: 'validationState=invalid',
14+
props: { validationState: 'invalid' },
15+
},
16+
];
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,12 @@
11
import type { PropTests } from '../types';
22

3-
export const validationTextPropTest = (useUndefined: boolean = false): PropTests => {
4-
const propTests = [
5-
{
6-
name: 'validationText=long',
7-
props: { validationText: 'Extra long validationText that exceeds regular length that anyone would expect to input in this property.' },
8-
},
9-
{
10-
name: 'validationText=normal',
11-
props: { validationText: 'Some normal validationText.' },
12-
},
13-
];
14-
15-
if (useUndefined === true) {
16-
propTests.push({
17-
name: 'validationText=undefined',
18-
props: { validationText: undefined },
19-
});
20-
}
21-
22-
return propTests;
23-
};
3+
export const validationTextPropTest: PropTests = [
4+
{
5+
name: 'validationText=long',
6+
props: { validationText: 'Extra long validationText that exceeds regular length that anyone would expect to input in this property.' },
7+
},
8+
{
9+
name: 'validationText=normal',
10+
props: { validationText: 'Some normal validationText.' },
11+
},
12+
];

0 commit comments

Comments
 (0)