@sit-onyx/playwright-utils 1.2.1-dev-20260316114803 → 1.2.2-dev-20260420124344
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/emits/index.d.ts +1 -1
- package/dist/index.js +142 -161
- package/dist/screenshots/index.d.ts +1 -1
- package/package.json +2 -2
package/dist/emits/index.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ export declare const EMIT_SPY_SYMBOL: unique symbol;
|
|
|
11
11
|
* // add spy
|
|
12
12
|
* const component = await mount(<OnyxColorSchemeDialog onUpdate:open={onUpdateOpen} />);
|
|
13
13
|
* // check spy
|
|
14
|
-
* expectEmit(onUpdateOpen, 1, [false]);
|
|
14
|
+
* await expectEmit(onUpdateOpen, 1, [false]);
|
|
15
15
|
* ```
|
|
16
16
|
*/
|
|
17
17
|
export declare const createEmitSpy: <C extends Component, Key extends keyof Emits | keyof Events | string, Emits = ComponentEmitProps<C>, Handler = Key extends keyof Emits ? NonNullable<Emits[Key]> : Key extends keyof Events ? (arg: Events[Key]) => void : unknown, Args extends unknown[] = Handler extends (...args: infer _Args) => unknown ? _Args : unknown[]>() => {
|
package/dist/index.js
CHANGED
|
@@ -1,162 +1,143 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
a.style.height = `${a.scrollHeight}px`, a.style.width = `${a.scrollWidth}px`;
|
|
142
|
-
});
|
|
143
|
-
}, g = (t) => /* @__PURE__ */ u(
|
|
144
|
-
"div",
|
|
145
|
-
{
|
|
146
|
-
style: { textAlign: "center", gridArea: `${t.type}-${d(t.name)}` },
|
|
147
|
-
children: t.name
|
|
148
|
-
}
|
|
149
|
-
), p = async ({ component: t, page: a, state: r }) => {
|
|
150
|
-
if (r === "hover" && await t.hover(), r === "focus-visible" && await a.keyboard.press("Tab"), r === "active") {
|
|
151
|
-
const e = await t.boundingBox(), c = { x: e.x + e.width / 2, y: e.y + e.height / 2 };
|
|
152
|
-
await a.mouse.move(c.x, c.y), await a.mouse.down();
|
|
153
|
-
}
|
|
154
|
-
};
|
|
155
|
-
export {
|
|
156
|
-
S as EMIT_SPY_SYMBOL,
|
|
157
|
-
O as adjustSizeToAbsolutePosition,
|
|
158
|
-
Y as createEmitSpy,
|
|
159
|
-
G as expectEmit,
|
|
160
|
-
p as useFocusStateHooks,
|
|
161
|
-
N as useMatrixScreenshotTest
|
|
1
|
+
import { expect as e, test as t } from "@playwright/test";
|
|
2
|
+
import { expect as n, test as r } from "@playwright/experimental-ct-vue";
|
|
3
|
+
import { jsx as i, jsxs as a } from "playwright/jsx-runtime";
|
|
4
|
+
//#region src/emits/index.ts
|
|
5
|
+
var o = Symbol("EMIT_SPY_SYMBOL"), s = () => {
|
|
6
|
+
let e = [], t = (...t) => {
|
|
7
|
+
e.push(t);
|
|
8
|
+
};
|
|
9
|
+
return t[o] = e, t;
|
|
10
|
+
}, c = (n, r, i) => t.step("check emitted events", async () => {
|
|
11
|
+
await e(() => e(n[o], "Should have emitted at least n times.").toHaveLength(r)).toPass();
|
|
12
|
+
let t = n[o][r - 1];
|
|
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) => /* @__PURE__ */ a("div", {
|
|
15
|
+
style: {
|
|
16
|
+
width: "max-content",
|
|
17
|
+
fontFamily: "Arial, sans-serif"
|
|
18
|
+
},
|
|
19
|
+
children: [/* @__PURE__ */ a("div", {
|
|
20
|
+
style: { marginBottom: "2rem" },
|
|
21
|
+
children: [/* @__PURE__ */ a("h1", {
|
|
22
|
+
style: {
|
|
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", {
|
|
30
|
+
style: {
|
|
31
|
+
display: "grid",
|
|
32
|
+
gap: "2rem",
|
|
33
|
+
gridTemplateRows: "auto",
|
|
34
|
+
width: "max-content",
|
|
35
|
+
alignItems: "center",
|
|
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
|
+
})()
|
|
44
|
+
},
|
|
45
|
+
children: [/* @__PURE__ */ i("div", { style: { gridArea: "blank" } }), e.children]
|
|
46
|
+
})]
|
|
47
|
+
}), d = (e = {}) => {
|
|
48
|
+
let t = e.test ?? r;
|
|
49
|
+
return { executeMatrixScreenshotTest: (r) => {
|
|
50
|
+
t(`${r.name}`, async ({ mount: a, page: o, browserName: s, context: c }) => {
|
|
51
|
+
t.setTimeout(r.columns.length * r.rows.length * (25 * 1e3));
|
|
52
|
+
let d = async (t, n, i) => {
|
|
53
|
+
await o.getByRole("document").focus(), await o.getByRole("document").hover({
|
|
54
|
+
position: {
|
|
55
|
+
x: 0,
|
|
56
|
+
y: 0
|
|
57
|
+
},
|
|
58
|
+
force: !0
|
|
59
|
+
}), await o.mouse.up();
|
|
60
|
+
let s = await a(t);
|
|
61
|
+
await e.defaults?.hooks?.beforeEach?.(s, o, n, i, r.context), await r.hooks?.beforeEach?.(s, o, n, i, r.context);
|
|
62
|
+
let c = await s.screenshot({
|
|
63
|
+
animations: "disabled",
|
|
64
|
+
...e.defaults?.screenshotOptions,
|
|
65
|
+
...r.screenshotOptions
|
|
66
|
+
}), u = await s.boundingBox(), d = `${l(i)}-${l(n)}`;
|
|
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: u,
|
|
69
|
+
id: d,
|
|
70
|
+
screenshot: c
|
|
71
|
+
};
|
|
72
|
+
}, f = /* @__PURE__ */ new Map();
|
|
73
|
+
for (let t of r.rows) for (let n of r.columns) {
|
|
74
|
+
let a = r.component(n, t), o = await d(/* @__PURE__ */ i("div", {
|
|
75
|
+
style: {
|
|
76
|
+
display: "grid",
|
|
77
|
+
width: "max-content",
|
|
78
|
+
padding: r.removePadding ?? e.defaults?.removePadding ? void 0 : "1rem"
|
|
79
|
+
},
|
|
80
|
+
children: a
|
|
81
|
+
}), n, t);
|
|
82
|
+
f.set(o.id, o);
|
|
83
|
+
}
|
|
84
|
+
let m = "/_playwright-matrix-screenshot", h = (e) => `${m}?id=${e}`;
|
|
85
|
+
await c.route(`${m}*`, (e, t) => {
|
|
86
|
+
let n = new URL(t.url()).searchParams.get("id") ?? "";
|
|
87
|
+
return e.fulfill({
|
|
88
|
+
status: 200,
|
|
89
|
+
contentType: "image/png",
|
|
90
|
+
body: f.get(n)?.screenshot
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
let g = Array.from(f.values()).map(({ box: e, id: t }) => {
|
|
94
|
+
let n = () => {};
|
|
95
|
+
return [new Promise((e) => n = e), /* @__PURE__ */ i("img", {
|
|
96
|
+
width: e?.width,
|
|
97
|
+
height: e?.height,
|
|
98
|
+
style: { gridArea: t },
|
|
99
|
+
src: h(t),
|
|
100
|
+
alt: t,
|
|
101
|
+
onLoad: n
|
|
102
|
+
})];
|
|
103
|
+
}), _ = g.map(([, e]) => e), v = g.map(([e]) => e), y = r.rows.map((e) => p({
|
|
104
|
+
name: e,
|
|
105
|
+
type: "row"
|
|
106
|
+
})), b = r.columns.map((e) => p({
|
|
107
|
+
name: e,
|
|
108
|
+
type: "column"
|
|
109
|
+
})), x = await a(u({
|
|
110
|
+
columns: r.columns,
|
|
111
|
+
rows: r.rows,
|
|
112
|
+
name: r.name,
|
|
113
|
+
browserName: s,
|
|
114
|
+
children: [
|
|
115
|
+
..._,
|
|
116
|
+
...y,
|
|
117
|
+
...b
|
|
118
|
+
]
|
|
119
|
+
}));
|
|
120
|
+
await Promise.all(v), await n(x).toHaveScreenshot(`${r.name}.png`), await o.unroute(`${m}*`);
|
|
121
|
+
});
|
|
122
|
+
} };
|
|
123
|
+
}, f = async (e) => {
|
|
124
|
+
await n(e).toBeVisible(), await e.evaluate((e) => {
|
|
125
|
+
e.style.height = `${e.scrollHeight}px`, e.style.width = `${e.scrollWidth}px`;
|
|
126
|
+
});
|
|
127
|
+
}, p = (e) => /* @__PURE__ */ i("div", {
|
|
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 }) => {
|
|
134
|
+
if (n === "hover" && await e.hover(), n === "focus-visible" && await t.keyboard.press("Tab"), n === "active") {
|
|
135
|
+
let n = await e.boundingBox(), r = {
|
|
136
|
+
x: n.x + n.width / 2,
|
|
137
|
+
y: n.y + n.height / 2
|
|
138
|
+
};
|
|
139
|
+
await t.mouse.move(r.x, r.y), await t.mouse.down();
|
|
140
|
+
}
|
|
162
141
|
};
|
|
142
|
+
//#endregion
|
|
143
|
+
export { o as EMIT_SPY_SYMBOL, f as adjustSizeToAbsolutePosition, s as createEmitSpy, c as expectEmit, m as useFocusStateHooks, d as useMatrixScreenshotTest };
|
|
@@ -8,7 +8,7 @@ export declare const useMatrixScreenshotTest: <TContext extends HookContext = Ho
|
|
|
8
8
|
/**
|
|
9
9
|
* Creates a single matrix screenshot that includes the screenshots for every column-row combination.
|
|
10
10
|
*/
|
|
11
|
-
executeMatrixScreenshotTest: <TColumn extends string, TRow extends string>(options: MatrixScreenshotTestOptions<TColumn, TRow, TContext>) =>
|
|
11
|
+
executeMatrixScreenshotTest: <TColumn extends string, TRow extends string>(options: MatrixScreenshotTestOptions<TColumn, TRow, TContext>) => void;
|
|
12
12
|
};
|
|
13
13
|
/**
|
|
14
14
|
* Sets the component size to fit all absolute positioned content so it is fully included in screenshots.
|
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.2.
|
|
4
|
+
"version": "1.2.2-dev-20260420124344",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": "Schwarz IT KG",
|
|
7
7
|
"license": "Apache-2.0",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"typescript": "5.9.3",
|
|
38
|
-
"vite": "
|
|
38
|
+
"vite": "8.0.5",
|
|
39
39
|
"@sit-onyx/shared": "0.1.0"
|
|
40
40
|
},
|
|
41
41
|
"scripts": {
|