@m4l/testing 0.0.15-beta.3 → 0.0.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/e2e/commands/components/DataGrid/export.d.ts +7 -0
- package/e2e/commands/components/DataGrid/types.d.ts +1 -9
- package/e2e/cypress.d.ts +1 -2
- package/index.d.ts +0 -1
- package/package.json +37 -26
- package/testComponents/DataGrid/helpers.js +29 -21
- package/testComponents/DataGrid/types.d.ts +9 -3
- package/e2e/cypress.d.js +0 -1
|
@@ -1,13 +1,5 @@
|
|
|
1
|
+
import { M4LGetCypressDataGridColumnsConfig } from './export';
|
|
1
2
|
declare global {
|
|
2
|
-
export type M4LDataGridCypressColumn = {
|
|
3
|
-
|
|
4
|
-
key: string;
|
|
5
|
-
value: any;
|
|
6
|
-
headerText: string;
|
|
7
|
-
visible: boolean;
|
|
8
|
-
}
|
|
9
|
-
export type M4LGetCypressDataGridColumnsConfig<T> = (data: T) => M4LDataGridCypressColumn[];
|
|
10
|
-
|
|
11
3
|
namespace Cypress {
|
|
12
4
|
interface Chainable {
|
|
13
5
|
/**
|
package/e2e/cypress.d.ts
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
/// <reference path="./commands/components/Tab/types.d.ts" />
|
|
9
9
|
/// <reference path="./commands/intercepts/noPrivileges/types.d.ts" />
|
|
10
10
|
|
|
11
|
+
export type { M4LGetCypressDataGridColumnsConfig , M4LDataGridCypressColumn } from './commands/components/DataGrid/export';
|
|
11
12
|
|
|
12
13
|
declare global {
|
|
13
14
|
namespace Cypress {
|
|
@@ -17,5 +18,3 @@ declare global {
|
|
|
17
18
|
}
|
|
18
19
|
}
|
|
19
20
|
}
|
|
20
|
-
|
|
21
|
-
export {};
|
package/index.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@m4l/testing",
|
|
3
3
|
"description": "Shared testing utilities for MFs",
|
|
4
|
-
"version": "0.0.15
|
|
4
|
+
"version": "0.0.15",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"author": "M4L Team",
|
|
7
7
|
"scripts": {
|
|
@@ -43,64 +43,75 @@
|
|
|
43
43
|
"@testing-library/react": "^16.0.0",
|
|
44
44
|
"@testing-library/react-hooks": "^8.0.1",
|
|
45
45
|
"@testing-library/user-event": "^14.5.2",
|
|
46
|
+
"@types/cypress": "^1.1.6",
|
|
46
47
|
"@types/jest": "^29.5.10",
|
|
47
48
|
"@vitejs/plugin-react": "^4.0.0",
|
|
48
49
|
"@vitest/coverage-istanbul": "^3.1.1",
|
|
49
50
|
"@vitest/coverage-v8": "^3.1.1",
|
|
50
51
|
"@vitest/ui": "^3.1.1",
|
|
51
52
|
"cypress": "^14.1.0",
|
|
52
|
-
"cypress-vite": "1.
|
|
53
|
+
"cypress-vite": "^1.5.0",
|
|
53
54
|
"happy-dom": "^17.1.9",
|
|
54
|
-
"jest-environment-jsdom": "29.7.0",
|
|
55
|
+
"jest-environment-jsdom": "^29.7.0",
|
|
55
56
|
"jsdom": "^25.0.1",
|
|
56
57
|
"storybook": "^8.3.4"
|
|
57
58
|
},
|
|
58
59
|
"peerDependencies": {
|
|
59
|
-
"@types/react": "18.
|
|
60
|
-
"react": "18.
|
|
61
|
-
"vitest": "3.1.1"
|
|
60
|
+
"@types/react": "^18.0.0",
|
|
61
|
+
"react": "^18.0.0",
|
|
62
|
+
"vitest": "^3.1.1"
|
|
62
63
|
},
|
|
63
64
|
"devDependencies": {
|
|
64
65
|
"@m4l/components": "^9.0.0",
|
|
65
66
|
"@m4l/config": "^1.1.2",
|
|
66
67
|
"@m4l/vite-plugins": "^1.1.5",
|
|
67
68
|
"@types/node": "^22.7.3",
|
|
68
|
-
"@types/react": "18.
|
|
69
|
-
"@types/react-dom": "18.
|
|
70
|
-
"eslint": "9.
|
|
71
|
-
"lefthook": "1.
|
|
72
|
-
"lint-staged": "15.
|
|
73
|
-
"react": "18.
|
|
74
|
-
"react-dom": "18.
|
|
69
|
+
"@types/react": "^18.0.0",
|
|
70
|
+
"@types/react-dom": "^18.0.0",
|
|
71
|
+
"eslint": "^9.0.0",
|
|
72
|
+
"lefthook": "^1.7.18",
|
|
73
|
+
"lint-staged": "^15.2.10",
|
|
74
|
+
"react": "^18.0.0",
|
|
75
|
+
"react-dom": "^18.0.0",
|
|
75
76
|
"typescript": "^5.4.5",
|
|
76
|
-
"vite": "6.3.5",
|
|
77
|
+
"vite": "^6.3.5",
|
|
77
78
|
"vite-plugin-dts": "^4.2.1",
|
|
78
|
-
"vitest": "3.1.1"
|
|
79
|
+
"vitest": "^3.1.1"
|
|
79
80
|
},
|
|
80
81
|
"resolutions": {
|
|
81
82
|
"glob": "^10.4.5",
|
|
82
|
-
"react": "18.
|
|
83
|
-
"@types/react": "18.
|
|
84
|
-
"@types/react-dom": "18.
|
|
85
|
-
"react-dom": "18.
|
|
83
|
+
"react": "^18.0.0",
|
|
84
|
+
"@types/react": "^18.0.0",
|
|
85
|
+
"@types/react-dom": "^18.0.0",
|
|
86
|
+
"react-dom": "^18.0.0",
|
|
86
87
|
"@vitejs/plugin-react": "^4.0.0"
|
|
87
88
|
},
|
|
88
89
|
"overrides": {
|
|
89
90
|
"glob": "^10.4.5",
|
|
90
|
-
"eslint": "9.
|
|
91
|
-
"react": "18.
|
|
92
|
-
"@types/react": "18.
|
|
93
|
-
"@types/react-dom": "18.
|
|
94
|
-
"react-dom": "18.
|
|
91
|
+
"eslint": "^9.0.0",
|
|
92
|
+
"react": "^18.0.0",
|
|
93
|
+
"@types/react": "^18.0.0",
|
|
94
|
+
"@types/react-dom": "^18.0.0",
|
|
95
|
+
"react-dom": "^18.0.0"
|
|
95
96
|
},
|
|
96
97
|
"files": [
|
|
97
98
|
"*"
|
|
98
99
|
],
|
|
99
|
-
"type": "module",
|
|
100
100
|
"source": "./index.js",
|
|
101
|
-
"main": "
|
|
101
|
+
"main": "src/index.ts",
|
|
102
102
|
"module": "./index.js",
|
|
103
|
+
"type": "module",
|
|
103
104
|
"types": "./index.d.ts",
|
|
105
|
+
"exports": {
|
|
106
|
+
".": {
|
|
107
|
+
"types": "./index.d.ts",
|
|
108
|
+
"import": "./index.js",
|
|
109
|
+
"require": null
|
|
110
|
+
},
|
|
111
|
+
"./cypress": {
|
|
112
|
+
"types": "./e2e/cypress.d.ts"
|
|
113
|
+
}
|
|
114
|
+
},
|
|
104
115
|
"sideEffects": false,
|
|
105
116
|
"publishConfig": {
|
|
106
117
|
"access": "public"
|
|
@@ -1,73 +1,81 @@
|
|
|
1
1
|
import { expect as t } from "vitest";
|
|
2
|
-
const n = (
|
|
3
|
-
t(
|
|
4
|
-
const
|
|
5
|
-
describe(`Column ${
|
|
2
|
+
const n = (l) => l?.type === "nested", h = (l) => l?.type === "date", k = (l) => l?.type === "boolean", d = (l) => l?.type === "setCheck", C = (l) => l?.type === "price", p = (l) => l?.type === "points", y = (l) => l?.type === "uncertainty", f = (l) => l?.type === "concatenated", m = (l) => l?.type === "chipStatus", V = (l) => l?.type === "tags", c = (l) => l?.type === "icon", P = (l, r) => {
|
|
3
|
+
t(l).toHaveLength(r.length), r.forEach((e, i) => {
|
|
4
|
+
const o = l[i], u = e.hookCall?.type ?? "none";
|
|
5
|
+
describe(`Column ${i + 1}: ${e.key} (${u})`, () => {
|
|
6
6
|
if (it("should have the correct basic properties", () => {
|
|
7
|
-
t(
|
|
7
|
+
t(o.key).toBe(e.key), t(o.name).toBe(e.name), t(o.type).toBe(e.type), t(o.align).toBe(e.align), t(o.width).toBe(e.width), t(o.visible).toBe(e.visible), e.fixed && t(o.fixed).toBe(e.fixed);
|
|
8
8
|
}), e.hookCall) {
|
|
9
|
-
let
|
|
9
|
+
let a = !0, s = !0;
|
|
10
10
|
it("should have the correct hook call properties", () => {
|
|
11
11
|
if (n(e.hookCall))
|
|
12
|
-
t(
|
|
12
|
+
t(o.testProps).toEqual({
|
|
13
13
|
fieldValue: e.hookCall.fieldValue
|
|
14
14
|
});
|
|
15
15
|
else if (h(e.hookCall))
|
|
16
|
-
t(
|
|
16
|
+
t(o.testProps).toEqual({
|
|
17
17
|
fieldValue: e.hookCall.fieldValue,
|
|
18
18
|
presentationType: e.hookCall.presentationType
|
|
19
19
|
});
|
|
20
|
-
else if (
|
|
21
|
-
t(
|
|
20
|
+
else if (k(e.hookCall))
|
|
21
|
+
t(o.testProps).toEqual({
|
|
22
22
|
fieldValue: e.hookCall.fieldValue,
|
|
23
23
|
presentationType: e.hookCall.presentationType
|
|
24
24
|
});
|
|
25
|
-
else if (
|
|
26
|
-
t(
|
|
25
|
+
else if (d(e.hookCall))
|
|
26
|
+
t(o.testProps).toEqual({
|
|
27
27
|
field: e.hookCall.field,
|
|
28
28
|
disabledGetter: t.any(Function),
|
|
29
29
|
rowKeyGetter: t.any(Function),
|
|
30
30
|
useHook: t.any(Function)
|
|
31
|
-
}),
|
|
31
|
+
}), a = !1, s = !1;
|
|
32
32
|
else if (C(e.hookCall))
|
|
33
|
-
t(
|
|
33
|
+
t(o.testProps).toEqual({
|
|
34
34
|
fieldValue: e.hookCall.fieldValue
|
|
35
35
|
});
|
|
36
36
|
else if (p(e.hookCall))
|
|
37
|
-
t(
|
|
37
|
+
t(o.testProps).toEqual({
|
|
38
38
|
fieldValue: e.hookCall.fieldValue,
|
|
39
39
|
fieldUnit: e.hookCall.fieldUnit
|
|
40
40
|
});
|
|
41
41
|
else if (y(e.hookCall))
|
|
42
|
-
t(
|
|
42
|
+
t(o.testProps).toEqual({
|
|
43
43
|
fieldValue: e.hookCall.fieldValue,
|
|
44
44
|
fieldUnit: e.hookCall.fieldUnit,
|
|
45
45
|
fieldSymbol: e.hookCall.fieldSymbol
|
|
46
46
|
});
|
|
47
47
|
else if (f(e.hookCall))
|
|
48
|
-
t(
|
|
48
|
+
t(o.testProps).toEqual({
|
|
49
49
|
fieldValue: e.hookCall.fieldValue,
|
|
50
50
|
fieldSeparator: e.hookCall.fieldSeparator
|
|
51
51
|
});
|
|
52
52
|
else if (m(e.hookCall))
|
|
53
|
-
t(
|
|
53
|
+
t(o.testProps).toEqual({
|
|
54
54
|
fieldLabel: typeof e.hookCall.fieldLabel == "function" ? t.any(Function) : e.hookCall.fieldLabel,
|
|
55
55
|
fieldStatus: e.hookCall.fieldStatus,
|
|
56
56
|
statusesColors: e.hookCall.statusesColors,
|
|
57
57
|
fallbackColor: e.hookCall.fallbackColor
|
|
58
58
|
});
|
|
59
|
+
else if (V(e.hookCall))
|
|
60
|
+
t(o.testProps).toEqual({
|
|
61
|
+
fieldValue: e.hookCall.fieldValue
|
|
62
|
+
});
|
|
63
|
+
else if (c(e.hookCall))
|
|
64
|
+
t(o.testProps).toEqual({
|
|
65
|
+
getIconProps: t.any(Function)
|
|
66
|
+
}), a = !1, s = !1;
|
|
59
67
|
else
|
|
60
68
|
throw new Error(`Unknown hook call type: ${e.hookCall?.type}`);
|
|
61
69
|
}), it("should have formatter, customFilter and customSort functions", () => {
|
|
62
|
-
t(
|
|
70
|
+
t(o.formatter).toBeDefined(), a && t(o.customFilter).toBeDefined(), s && t(o.customSort).toBeDefined();
|
|
63
71
|
});
|
|
64
72
|
} else
|
|
65
73
|
it("should not have formatter functions", () => {
|
|
66
|
-
t(
|
|
74
|
+
t(o.formatter).toBeUndefined(), t(o.customFilter).toBeUndefined(), t(o.customSort).toBeUndefined();
|
|
67
75
|
});
|
|
68
76
|
});
|
|
69
77
|
});
|
|
70
78
|
};
|
|
71
79
|
export {
|
|
72
|
-
|
|
80
|
+
P as t
|
|
73
81
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { ColumnNestedValueFormatterProps, ColumnDateFormatterProps, ColumnBooleanFormatterProps, ColumnPriceFormatterProps, ColumnPointsFormatterProps, ColumnSetCheckFormatterProps, ColumnUncertaintyFormatterProps, ColumnConcatenatedValuesFormatterProps, Column, ColumnInteractiveCheckFormatterProps, ColumnChipStatusFormatterProps } from '@m4l/components';
|
|
1
|
+
import { ColumnNestedValueFormatterProps, ColumnDateFormatterProps, ColumnBooleanFormatterProps, ColumnPriceFormatterProps, ColumnPointsFormatterProps, ColumnSetCheckFormatterProps, ColumnUncertaintyFormatterProps, ColumnConcatenatedValuesFormatterProps, Column, ColumnInteractiveCheckFormatterProps, ColumnChipStatusFormatterProps, ColumnTagsFormatterProps, ColumnIconFormatterProps } from '@m4l/components';
|
|
2
2
|
type BaseColumnConfig<T> = Column<T, unknown>;
|
|
3
3
|
type BaseHookCall = {
|
|
4
|
-
type: 'nested' | 'date' | 'boolean' | 'price' | 'points' | 'interactiveCheck' | 'setCheck' | 'uncertainty' | 'concatenated' | 'chipStatus';
|
|
4
|
+
type: 'nested' | 'date' | 'boolean' | 'price' | 'points' | 'interactiveCheck' | 'setCheck' | 'uncertainty' | 'concatenated' | 'chipStatus' | 'tags' | 'icon';
|
|
5
5
|
};
|
|
6
6
|
export type TestingNestedValueHookCall<T> = BaseHookCall & ColumnNestedValueFormatterProps<T> & {
|
|
7
7
|
type: 'nested';
|
|
@@ -33,8 +33,14 @@ export type TestingConcatenatedHookCall<T> = BaseHookCall & ColumnConcatenatedVa
|
|
|
33
33
|
export type TestingChipStatusHookCall<T> = BaseHookCall & ColumnChipStatusFormatterProps<T> & {
|
|
34
34
|
type: 'chipStatus';
|
|
35
35
|
};
|
|
36
|
+
export type TestingTagsHookCall<T> = BaseHookCall & ColumnTagsFormatterProps<T> & {
|
|
37
|
+
type: 'tags';
|
|
38
|
+
};
|
|
39
|
+
export type TestingIconHookCall<T> = BaseHookCall & ColumnIconFormatterProps<T> & {
|
|
40
|
+
type: 'icon';
|
|
41
|
+
};
|
|
36
42
|
export type TestingColumnConfig<T> = BaseColumnConfig<T> & {
|
|
37
|
-
hookCall?: TestingNestedValueHookCall<T> | TestingDateHookCall<T> | TestingBooleanHookCall<T> | TestingPriceHookCall<T> | TestingPointsHookCall<T> | TestingInteractiveCheckHookCall<T> | TestingSetCheckHookCall<T> | TestingUncertaintyHookCall<T> | TestingConcatenatedHookCall<T> | TestingChipStatusHookCall<T>;
|
|
43
|
+
hookCall?: TestingNestedValueHookCall<T> | TestingDateHookCall<T> | TestingBooleanHookCall<T> | TestingPriceHookCall<T> | TestingPointsHookCall<T> | TestingInteractiveCheckHookCall<T> | TestingSetCheckHookCall<T> | TestingUncertaintyHookCall<T> | TestingConcatenatedHookCall<T> | TestingChipStatusHookCall<T> | TestingTagsHookCall<T> | TestingIconHookCall<T>;
|
|
38
44
|
};
|
|
39
45
|
export type TestingColumn = Column<unknown, unknown> & {
|
|
40
46
|
testProps?: Record<string, unknown>;
|
package/e2e/cypress.d.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
|