@sit-onyx/playwright-utils 1.2.0 → 1.2.1-dev-20260313154245
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 +3 -3
- package/dist/index.js +48 -44
- package/package.json +1 -1
package/dist/emits/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Component } from "vue";
|
|
1
|
+
import type { Component, Events } from "vue";
|
|
2
2
|
import type { ComponentEmitProps } from "./types.js";
|
|
3
3
|
export declare const EMIT_SPY_SYMBOL: unique symbol;
|
|
4
4
|
/**
|
|
@@ -14,7 +14,7 @@ export declare const EMIT_SPY_SYMBOL: unique symbol;
|
|
|
14
14
|
* expectEmit(onUpdateOpen, 1, [false]);
|
|
15
15
|
* ```
|
|
16
16
|
*/
|
|
17
|
-
export declare const createEmitSpy: <C extends Component, Key extends keyof Emits, Emits = ComponentEmitProps<C>, Handler = NonNullable<Emits[Key]
|
|
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[]>() => {
|
|
18
18
|
(...args: Args): void;
|
|
19
19
|
[EMIT_SPY_SYMBOL]: Args[];
|
|
20
20
|
};
|
|
@@ -25,4 +25,4 @@ export declare const createEmitSpy: <C extends Component, Key extends keyof Emit
|
|
|
25
25
|
*/
|
|
26
26
|
export declare const expectEmit: <Handler extends {
|
|
27
27
|
[EMIT_SPY_SYMBOL]: unknown[][];
|
|
28
|
-
}>(emitSpy: Handler, n: number, matches?: unknown[]) => unknown[] | undefined
|
|
28
|
+
}>(emitSpy: Handler, n: number, matches?: unknown[]) => Promise<unknown[] | undefined>;
|
package/dist/index.js
CHANGED
|
@@ -1,18 +1,22 @@
|
|
|
1
|
-
import { expect as f } from "@playwright/test";
|
|
1
|
+
import { test as B, expect as f } from "@playwright/test";
|
|
2
2
|
import { jsxs as m, jsx as u } from "playwright/jsx-runtime";
|
|
3
|
-
import { expect as v, test as
|
|
4
|
-
const S = /* @__PURE__ */ Symbol("EMIT_SPY_SYMBOL"),
|
|
5
|
-
const t = [],
|
|
3
|
+
import { expect as v, test as L } from "@playwright/experimental-ct-vue";
|
|
4
|
+
const S = /* @__PURE__ */ Symbol("EMIT_SPY_SYMBOL"), Y = () => {
|
|
5
|
+
const t = [], a = (...r) => {
|
|
6
6
|
t.push(r);
|
|
7
7
|
};
|
|
8
|
-
return
|
|
9
|
-
},
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
8
|
+
return a[S] = t, a;
|
|
9
|
+
}, G = (t, a, r) => B.step(
|
|
10
|
+
"check emitted events",
|
|
11
|
+
async () => {
|
|
12
|
+
const e = t[S];
|
|
13
|
+
f(e, "Should have emitted at least n times.").toHaveLength(a);
|
|
14
|
+
const c = e[a - 1];
|
|
15
|
+
return r && f(c, "Should match expected emit details.").toMatchObject(r), c;
|
|
16
|
+
},
|
|
17
|
+
{ box: !0 }
|
|
18
|
+
), d = (t) => t.replace(/\W/g, (a) => a.codePointAt(0)?.toString() || "-"), H = (t) => {
|
|
19
|
+
const a = () => {
|
|
16
20
|
const r = [
|
|
17
21
|
`"blank ${t.columns.map((e) => `column-${d(e)}`).join(" ")}"`
|
|
18
22
|
];
|
|
@@ -45,7 +49,7 @@ const S = /* @__PURE__ */ Symbol("EMIT_SPY_SYMBOL"), I = () => {
|
|
|
45
49
|
alignItems: "center",
|
|
46
50
|
justifyContent: "center",
|
|
47
51
|
gridTemplateColumns: `auto repeat(${t.columns.length}, 1fr)`,
|
|
48
|
-
gridTemplateAreas:
|
|
52
|
+
gridTemplateAreas: a()
|
|
49
53
|
},
|
|
50
54
|
children: [
|
|
51
55
|
/* @__PURE__ */ u("div", { style: { gridArea: "blank" } }),
|
|
@@ -54,41 +58,41 @@ const S = /* @__PURE__ */ Symbol("EMIT_SPY_SYMBOL"), I = () => {
|
|
|
54
58
|
}
|
|
55
59
|
)
|
|
56
60
|
] });
|
|
57
|
-
},
|
|
58
|
-
const
|
|
61
|
+
}, N = (t = {}) => {
|
|
62
|
+
const a = t.test ?? L;
|
|
59
63
|
return {
|
|
60
64
|
/**
|
|
61
65
|
* Creates a single matrix screenshot that includes the screenshots for every column-row combination.
|
|
62
66
|
*/
|
|
63
67
|
executeMatrixScreenshotTest: async (e) => {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
const E = async (s,
|
|
68
|
+
a(`${e.name}`, async ({ mount: c, page: i, browserName: $, context: b }) => {
|
|
69
|
+
a.setTimeout(e.columns.length * e.rows.length * 25e3);
|
|
70
|
+
const E = async (s, n, l) => {
|
|
67
71
|
await i.getByRole("document").focus(), await i.getByRole("document").hover({ position: { x: 0, y: 0 }, force: !0 }), await i.mouse.up();
|
|
68
72
|
const o = await c(s);
|
|
69
73
|
await t.defaults?.hooks?.beforeEach?.(
|
|
70
74
|
o,
|
|
71
75
|
i,
|
|
72
|
-
|
|
76
|
+
n,
|
|
73
77
|
l,
|
|
74
78
|
e.context
|
|
75
|
-
), await e.hooks?.beforeEach?.(o, i,
|
|
79
|
+
), await e.hooks?.beforeEach?.(o, i, n, l, e.context);
|
|
76
80
|
const x = await o.screenshot({
|
|
77
81
|
animations: "disabled",
|
|
78
82
|
...t.defaults?.screenshotOptions,
|
|
79
83
|
...e.screenshotOptions
|
|
80
|
-
}), h = await o.boundingBox(),
|
|
84
|
+
}), h = await o.boundingBox(), k = `${d(l)}-${d(n)}`;
|
|
81
85
|
return await t.defaults?.hooks?.afterEach?.(
|
|
82
86
|
o,
|
|
83
87
|
i,
|
|
84
|
-
|
|
88
|
+
n,
|
|
85
89
|
l,
|
|
86
90
|
e.context
|
|
87
|
-
), await e.hooks?.afterEach?.(o, i,
|
|
91
|
+
), await e.hooks?.afterEach?.(o, i, n, l, e.context), { box: h, id: k, screenshot: x };
|
|
88
92
|
}, w = /* @__PURE__ */ new Map();
|
|
89
93
|
for (const s of e.rows)
|
|
90
|
-
for (const
|
|
91
|
-
const l = e.component(
|
|
94
|
+
for (const n of e.columns) {
|
|
95
|
+
const l = e.component(n, s), o = e.removePadding ?? t.defaults?.removePadding, h = await E(/* @__PURE__ */ u(
|
|
92
96
|
"div",
|
|
93
97
|
{
|
|
94
98
|
style: {
|
|
@@ -98,30 +102,30 @@ const S = /* @__PURE__ */ Symbol("EMIT_SPY_SYMBOL"), I = () => {
|
|
|
98
102
|
},
|
|
99
103
|
children: l
|
|
100
104
|
}
|
|
101
|
-
),
|
|
105
|
+
), n, s);
|
|
102
106
|
w.set(h.id, h);
|
|
103
107
|
}
|
|
104
108
|
const y = "/_playwright-matrix-screenshot";
|
|
105
|
-
await b.route(`${y}*`, (s,
|
|
106
|
-
const o = new URL(
|
|
109
|
+
await b.route(`${y}*`, (s, n) => {
|
|
110
|
+
const o = new URL(n.url()).searchParams.get("id") ?? "";
|
|
107
111
|
return s.fulfill({
|
|
108
112
|
status: 200,
|
|
109
113
|
contentType: "image/png",
|
|
110
114
|
body: w.get(o)?.screenshot
|
|
111
115
|
});
|
|
112
116
|
});
|
|
113
|
-
const T = Array.from(w.values()).map(({ box: s, id:
|
|
117
|
+
const T = Array.from(w.values()).map(({ box: s, id: n }) => /* @__PURE__ */ u(
|
|
114
118
|
"img",
|
|
115
119
|
{
|
|
116
120
|
width: s?.width,
|
|
117
121
|
height: s?.height,
|
|
118
|
-
style: { gridArea:
|
|
119
|
-
src: `${y}?id=${
|
|
120
|
-
alt:
|
|
122
|
+
style: { gridArea: n },
|
|
123
|
+
src: `${y}?id=${n}`,
|
|
124
|
+
alt: n
|
|
121
125
|
}
|
|
122
126
|
)), A = e.rows.map((s) => g({ name: s, type: "row" })), M = e.columns.map(
|
|
123
127
|
(s) => g({ name: s, type: "column" })
|
|
124
|
-
), P =
|
|
128
|
+
), P = H({
|
|
125
129
|
columns: e.columns,
|
|
126
130
|
rows: e.rows,
|
|
127
131
|
name: e.name,
|
|
@@ -132,9 +136,9 @@ const S = /* @__PURE__ */ Symbol("EMIT_SPY_SYMBOL"), I = () => {
|
|
|
132
136
|
});
|
|
133
137
|
}
|
|
134
138
|
};
|
|
135
|
-
},
|
|
136
|
-
await v(t).toBeVisible(), await t.evaluate((
|
|
137
|
-
|
|
139
|
+
}, O = async (t) => {
|
|
140
|
+
await v(t).toBeVisible(), await t.evaluate((a) => {
|
|
141
|
+
a.style.height = `${a.scrollHeight}px`, a.style.width = `${a.scrollWidth}px`;
|
|
138
142
|
});
|
|
139
143
|
}, g = (t) => /* @__PURE__ */ u(
|
|
140
144
|
"div",
|
|
@@ -142,17 +146,17 @@ const S = /* @__PURE__ */ Symbol("EMIT_SPY_SYMBOL"), I = () => {
|
|
|
142
146
|
style: { textAlign: "center", gridArea: `${t.type}-${d(t.name)}` },
|
|
143
147
|
children: t.name
|
|
144
148
|
}
|
|
145
|
-
),
|
|
146
|
-
if (r === "hover" && await t.hover(), r === "focus-visible" && await
|
|
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") {
|
|
147
151
|
const e = await t.boundingBox(), c = { x: e.x + e.width / 2, y: e.y + e.height / 2 };
|
|
148
|
-
await
|
|
152
|
+
await a.mouse.move(c.x, c.y), await a.mouse.down();
|
|
149
153
|
}
|
|
150
154
|
};
|
|
151
155
|
export {
|
|
152
156
|
S as EMIT_SPY_SYMBOL,
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
157
|
+
O as adjustSizeToAbsolutePosition,
|
|
158
|
+
Y as createEmitSpy,
|
|
159
|
+
G as expectEmit,
|
|
160
|
+
p as useFocusStateHooks,
|
|
161
|
+
N as useMatrixScreenshotTest
|
|
158
162
|
};
|
package/package.json
CHANGED