@sit-onyx/playwright-utils 1.2.2-dev-20260422105150 → 1.3.0-dev-20260429130251
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/dist/index.js
CHANGED
|
@@ -11,45 +11,66 @@ var o = Symbol("EMIT_SPY_SYMBOL"), s = () => {
|
|
|
11
11
|
await e(() => e(n[o], "Should have emitted at least n times.").toHaveLength(r)).toPass();
|
|
12
12
|
let t = n[o][r - 1];
|
|
13
13
|
return i && e(t, "Should match expected emit details.").toMatchObject(i), t;
|
|
14
|
-
}, { box: !0 }), l = (e) => e.replace(/\W/g, (e) => e.codePointAt(0)?.toString() || "-"), u = (e) =>
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
},
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
fontSize: "1.25rem",
|
|
24
|
-
lineHeight: "1.75rem",
|
|
25
|
-
margin: "0"
|
|
26
|
-
},
|
|
27
|
-
children: ["Screenshot test: ", e.name]
|
|
28
|
-
}), /* @__PURE__ */ a("div", { children: ["Browser: ", e.browserName] })]
|
|
29
|
-
}), /* @__PURE__ */ a("div", {
|
|
14
|
+
}, { box: !0 }), l = (e) => e.replace(/\W/g, (e) => e.codePointAt(0)?.toString() || "-"), u = (e) => {
|
|
15
|
+
let t = e.rows.map((e) => d({
|
|
16
|
+
name: e,
|
|
17
|
+
type: "row"
|
|
18
|
+
})), n = e.columns.map((e) => d({
|
|
19
|
+
name: e,
|
|
20
|
+
type: "column"
|
|
21
|
+
}));
|
|
22
|
+
return /* @__PURE__ */ a("div", {
|
|
30
23
|
style: {
|
|
31
|
-
display: "grid",
|
|
32
|
-
gap: "2rem",
|
|
33
|
-
gridTemplateRows: "auto",
|
|
34
24
|
width: "max-content",
|
|
35
|
-
|
|
36
|
-
justifyContent: "center",
|
|
37
|
-
gridTemplateColumns: `auto repeat(${e.columns.length}, 1fr)`,
|
|
38
|
-
gridTemplateAreas: (() => {
|
|
39
|
-
let t = [`"blank ${e.columns.map((e) => `column-${l(e)}`).join(" ")}"`];
|
|
40
|
-
return e.rows.forEach((n) => {
|
|
41
|
-
t.push(`"row-${l(n)} ${e.columns.map((e) => `${l(n)}-${l(e)}`).join(" ")}"`);
|
|
42
|
-
}), t.join("\n");
|
|
43
|
-
})()
|
|
25
|
+
fontFamily: "Arial, sans-serif"
|
|
44
26
|
},
|
|
45
|
-
children: [/* @__PURE__ */
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
27
|
+
children: [/* @__PURE__ */ a("div", {
|
|
28
|
+
style: { marginBottom: "2rem" },
|
|
29
|
+
children: [/* @__PURE__ */ a("h1", {
|
|
30
|
+
style: {
|
|
31
|
+
fontSize: "1.25rem",
|
|
32
|
+
lineHeight: "1.75rem",
|
|
33
|
+
margin: "0"
|
|
34
|
+
},
|
|
35
|
+
children: ["Screenshot test: ", e.name]
|
|
36
|
+
}), /* @__PURE__ */ a("div", { children: ["Browser: ", e.browserName] })]
|
|
37
|
+
}), /* @__PURE__ */ a("div", {
|
|
38
|
+
style: {
|
|
39
|
+
display: "grid",
|
|
40
|
+
gap: "2rem",
|
|
41
|
+
gridTemplateRows: "auto",
|
|
42
|
+
width: "max-content",
|
|
43
|
+
alignItems: "center",
|
|
44
|
+
justifyContent: "center",
|
|
45
|
+
gridTemplateColumns: `auto repeat(${e.columns.length}, 1fr)`,
|
|
46
|
+
gridTemplateAreas: (() => {
|
|
47
|
+
let t = [`"blank ${e.columns.map((e) => `column-${l(e)}`).join(" ")}"`];
|
|
48
|
+
return e.rows.forEach((n) => {
|
|
49
|
+
t.push(`"row-${l(n)} ${e.columns.map((e) => `${l(n)}-${l(e)}`).join(" ")}"`);
|
|
50
|
+
}), t.join("\n");
|
|
51
|
+
})()
|
|
52
|
+
},
|
|
53
|
+
children: [
|
|
54
|
+
/* @__PURE__ */ i("div", { style: { gridArea: "blank" } }),
|
|
55
|
+
e.children,
|
|
56
|
+
...t,
|
|
57
|
+
...n
|
|
58
|
+
]
|
|
59
|
+
})]
|
|
60
|
+
});
|
|
61
|
+
}, d = (e) => /* @__PURE__ */ i("div", {
|
|
62
|
+
style: {
|
|
63
|
+
textAlign: "center",
|
|
64
|
+
gridArea: `${e.type}-${l(e.name)}`
|
|
65
|
+
},
|
|
66
|
+
children: e.name
|
|
67
|
+
}), f = (e, t) => `${l(e)}-${l(t)}`, p = (e = {}) => {
|
|
68
|
+
let t = e.test ?? r, a = (e) => {
|
|
69
|
+
e.fastNoIsolation ? s(e) : o(e);
|
|
70
|
+
}, o = (r) => {
|
|
50
71
|
t(`${r.name}`, async ({ mount: a, page: o, browserName: s, context: c }) => {
|
|
51
72
|
t.setTimeout(r.columns.length * r.rows.length * (25 * 1e3));
|
|
52
|
-
let
|
|
73
|
+
let l = async (t, n, i) => {
|
|
53
74
|
await o.getByRole("document").focus(), await o.getByRole("document").hover({
|
|
54
75
|
position: {
|
|
55
76
|
x: 0,
|
|
@@ -63,15 +84,15 @@ var o = Symbol("EMIT_SPY_SYMBOL"), s = () => {
|
|
|
63
84
|
animations: "disabled",
|
|
64
85
|
...e.defaults?.screenshotOptions,
|
|
65
86
|
...r.screenshotOptions
|
|
66
|
-
}),
|
|
67
|
-
return await e.defaults?.hooks?.afterEach?.(s, o, n, i, r.context), await r.hooks?.afterEach?.(s, o, n, i, r.context), {
|
|
68
|
-
box:
|
|
69
|
-
id:
|
|
87
|
+
}), l = await s.boundingBox(), u = f(i, n);
|
|
88
|
+
return await e.defaults?.hooks?.afterEach?.(s, o, n, i, r.context), await r.hooks?.afterEach?.(s, o, n, i, r.context), await s.unmount(), {
|
|
89
|
+
box: l,
|
|
90
|
+
id: u,
|
|
70
91
|
screenshot: c
|
|
71
92
|
};
|
|
72
|
-
},
|
|
93
|
+
}, d = /* @__PURE__ */ new Map();
|
|
73
94
|
for (let t of r.rows) for (let n of r.columns) {
|
|
74
|
-
let a = r.component(n, t), o = await
|
|
95
|
+
let a = r.component(n, t), o = await l(/* @__PURE__ */ i("div", {
|
|
75
96
|
style: {
|
|
76
97
|
display: "grid",
|
|
77
98
|
width: "max-content",
|
|
@@ -79,58 +100,69 @@ var o = Symbol("EMIT_SPY_SYMBOL"), s = () => {
|
|
|
79
100
|
},
|
|
80
101
|
children: a
|
|
81
102
|
}), n, t);
|
|
82
|
-
|
|
103
|
+
d.set(o.id, o);
|
|
83
104
|
}
|
|
84
|
-
let
|
|
85
|
-
await c.route(`${
|
|
105
|
+
let p = "/_playwright-matrix-screenshot", m = (e) => `${p}?id=${e}`;
|
|
106
|
+
await c.route(`${p}*`, (e, t) => {
|
|
86
107
|
let n = new URL(t.url()).searchParams.get("id") ?? "";
|
|
87
108
|
return e.fulfill({
|
|
88
109
|
status: 200,
|
|
89
110
|
contentType: "image/png",
|
|
90
|
-
body:
|
|
111
|
+
body: d.get(n)?.screenshot
|
|
91
112
|
});
|
|
92
113
|
});
|
|
93
|
-
let
|
|
114
|
+
let h = Array.from(d.values()).map(({ box: e, id: t }) => {
|
|
94
115
|
let n = () => {};
|
|
95
116
|
return [new Promise((e) => n = e), /* @__PURE__ */ i("img", {
|
|
96
117
|
width: e?.width,
|
|
97
118
|
height: e?.height,
|
|
98
119
|
style: { gridArea: t },
|
|
99
|
-
src:
|
|
120
|
+
src: m(t),
|
|
100
121
|
alt: t,
|
|
101
122
|
onLoad: n
|
|
102
123
|
})];
|
|
103
|
-
}),
|
|
104
|
-
name: e,
|
|
105
|
-
type: "row"
|
|
106
|
-
})), b = r.columns.map((e) => p({
|
|
107
|
-
name: e,
|
|
108
|
-
type: "column"
|
|
109
|
-
})), x = await a(u({
|
|
124
|
+
}), g = h.map(([, e]) => e), _ = h.map(([e]) => e), v = await a(u({
|
|
110
125
|
columns: r.columns,
|
|
111
126
|
rows: r.rows,
|
|
112
127
|
name: r.name,
|
|
113
128
|
browserName: s,
|
|
114
|
-
children:
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
129
|
+
children: g
|
|
130
|
+
}));
|
|
131
|
+
await Promise.all(_), await n(() => n(v).toHaveScreenshot(`${r.name}.png`)).toPass();
|
|
132
|
+
let y = o.unroute(`${p}*`), b = v.unmount();
|
|
133
|
+
await Promise.all([b, y]);
|
|
134
|
+
});
|
|
135
|
+
}, s = (r) => {
|
|
136
|
+
t(`${r.name}`, async ({ mount: t, browserName: a }) => {
|
|
137
|
+
let o = [];
|
|
138
|
+
for (let t of r.rows) for (let n of r.columns) {
|
|
139
|
+
let a = r.component(n, t), s = r.removePadding ?? e.defaults?.removePadding;
|
|
140
|
+
o.push(/* @__PURE__ */ i("div", {
|
|
141
|
+
style: {
|
|
142
|
+
display: "grid",
|
|
143
|
+
gridArea: f(t, n),
|
|
144
|
+
width: "max-content",
|
|
145
|
+
padding: s ? void 0 : "1rem"
|
|
146
|
+
},
|
|
147
|
+
children: a
|
|
148
|
+
}));
|
|
149
|
+
}
|
|
150
|
+
let s = await t(u({
|
|
151
|
+
columns: r.columns,
|
|
152
|
+
rows: r.rows,
|
|
153
|
+
name: r.name,
|
|
154
|
+
browserName: a,
|
|
155
|
+
children: o
|
|
119
156
|
}));
|
|
120
|
-
await
|
|
157
|
+
await n(() => n(s).toHaveScreenshot(`${r.name}.png`)).toPass();
|
|
121
158
|
});
|
|
122
|
-
}
|
|
123
|
-
|
|
159
|
+
};
|
|
160
|
+
return { executeMatrixScreenshotTest: a };
|
|
161
|
+
}, m = async (e) => {
|
|
124
162
|
await n(e).toBeVisible(), await e.evaluate((e) => {
|
|
125
163
|
e.style.height = `${e.scrollHeight}px`, e.style.width = `${e.scrollWidth}px`;
|
|
126
164
|
});
|
|
127
|
-
},
|
|
128
|
-
style: {
|
|
129
|
-
textAlign: "center",
|
|
130
|
-
gridArea: `${e.type}-${l(e.name)}`
|
|
131
|
-
},
|
|
132
|
-
children: e.name
|
|
133
|
-
}), m = async ({ component: e, page: t, state: n }) => {
|
|
165
|
+
}, h = async ({ component: e, page: t, state: n }) => {
|
|
134
166
|
if (n === "hover" && await e.hover(), n === "focus-visible" && await t.keyboard.press("Tab"), n === "active") {
|
|
135
167
|
let n = await e.boundingBox(), r = {
|
|
136
168
|
x: n.x + n.width / 2,
|
|
@@ -140,4 +172,4 @@ var o = Symbol("EMIT_SPY_SYMBOL"), s = () => {
|
|
|
140
172
|
}
|
|
141
173
|
};
|
|
142
174
|
//#endregion
|
|
143
|
-
export { o as EMIT_SPY_SYMBOL,
|
|
175
|
+
export { o as EMIT_SPY_SYMBOL, m as adjustSizeToAbsolutePosition, s as createEmitSpy, c as expectEmit, h as useFocusStateHooks, p as useMatrixScreenshotTest };
|
|
@@ -21,3 +21,8 @@ export type ScreenshotMatrixProps = {
|
|
|
21
21
|
children: unknown[];
|
|
22
22
|
};
|
|
23
23
|
export declare const ScreenshotMatrix: (props: ScreenshotMatrixProps) => import("vue/jsx-runtime").JSX.Element;
|
|
24
|
+
export declare const GridLabel: (props: {
|
|
25
|
+
type: "column" | "row";
|
|
26
|
+
name: string;
|
|
27
|
+
}) => import("vue/jsx-runtime").JSX.Element;
|
|
28
|
+
export declare const getCellId: (row: string, column: string) => string;
|
|
@@ -6,7 +6,9 @@ import type { HookContext, MatrixScreenshotTestOptions, UseMatrixScreenshotTestO
|
|
|
6
6
|
*/
|
|
7
7
|
export declare const useMatrixScreenshotTest: <TContext extends HookContext = HookContext>(globalOptions?: UseMatrixScreenshotTestOptions<TContext>) => {
|
|
8
8
|
/**
|
|
9
|
-
* Creates a
|
|
9
|
+
* Creates a combined matrix screenshot that includes the screenshots for every column-row combination.
|
|
10
|
+
* Every combination is mounted individually, which allows to perform pointer or keyboard interactions before taking a screenshot.
|
|
11
|
+
* If the isolation is not necessary, consider enabling `fastNoIsolation` which is way faster.
|
|
10
12
|
*/
|
|
11
13
|
executeMatrixScreenshotTest: <TColumn extends string, TRow extends string>(options: MatrixScreenshotTestOptions<TColumn, TRow, TContext>) => void;
|
|
12
14
|
};
|
|
@@ -6,13 +6,13 @@ export type UseMatrixScreenshotTestOptions<TContext extends HookContext = HookCo
|
|
|
6
6
|
* Global default options for the matrix screenshot tests.
|
|
7
7
|
* Will be merged with the options passed to a single screenshot test.
|
|
8
8
|
*/
|
|
9
|
-
defaults?: Partial<Pick<MatrixScreenshotTestOptions<string, string, TContext>, "removePadding" | "hooks" | "screenshotOptions">>;
|
|
9
|
+
defaults?: Partial<Pick<MatrixScreenshotTestOptions<string, string, TContext, boolean>, "removePadding" | "hooks" | "screenshotOptions">>;
|
|
10
10
|
/**
|
|
11
11
|
* Optional custom `test` function to use. Useful when using [fixtures](https://playwright.dev/docs/test-fixtures#creating-a-fixture).
|
|
12
12
|
*/
|
|
13
13
|
test?: typeof test;
|
|
14
14
|
};
|
|
15
|
-
export type MatrixScreenshotTestOptions<TColumn extends string = string, TRow extends string = string, TContext extends HookContext = HookContext> = {
|
|
15
|
+
export type MatrixScreenshotTestOptions<TColumn extends string = string, TRow extends string = string, TContext extends HookContext = HookContext, TIsolation extends boolean = boolean> = {
|
|
16
16
|
/**
|
|
17
17
|
* Test name. Will be displayed above the matrix screenshot and be used as filename.
|
|
18
18
|
*/
|
|
@@ -29,6 +29,14 @@ export type MatrixScreenshotTestOptions<TColumn extends string = string, TRow ex
|
|
|
29
29
|
* Function that returns the component for the given column and row.
|
|
30
30
|
*/
|
|
31
31
|
component: (column: TColumn, row: TRow) => JSX.Element;
|
|
32
|
+
/**
|
|
33
|
+
* By default a combined matrix screenshot is created that includes the screenshots for every column-row combination.
|
|
34
|
+
* Every combination is mounted individually, which allows to perform pointer or keyboard interactions before taking a screenshot.
|
|
35
|
+
*
|
|
36
|
+
* If the isolation is not necessary, consider enabling this option which is way faster, as it mounts all combinations together.
|
|
37
|
+
* On the downside the hooks will not be executed.
|
|
38
|
+
*/
|
|
39
|
+
fastNoIsolation?: boolean;
|
|
32
40
|
/**
|
|
33
41
|
* Custom hooks/callbacks that can be executed at specific points in time during the matrix screenshot.
|
|
34
42
|
*/
|
|
@@ -48,7 +56,12 @@ export type MatrixScreenshotTestOptions<TColumn extends string = string, TRow ex
|
|
|
48
56
|
* Per default `animations` are `disabled`.
|
|
49
57
|
*/
|
|
50
58
|
screenshotOptions?: LocatorScreenshotOptions;
|
|
51
|
-
}
|
|
59
|
+
} & (TIsolation extends true ? {
|
|
60
|
+
fastNoIsolation: true;
|
|
61
|
+
hooks?: never;
|
|
62
|
+
} : {
|
|
63
|
+
fastNoIsolation?: false;
|
|
64
|
+
});
|
|
52
65
|
export type ScreenshotTestHooks<TColumn extends string, TRow extends string, TContext extends HookContext = HookContext> = Partial<{
|
|
53
66
|
/**
|
|
54
67
|
* Optional callback to be executed before capturing each individual screenshot (column + row combination).
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sit-onyx/playwright-utils",
|
|
3
3
|
"description": "Utilities for Vue component testing with Playwright",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.3.0-dev-20260429130251",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": "Schwarz IT KG",
|
|
7
7
|
"license": "Apache-2.0",
|