@sit-onyx/playwright-utils 1.1.0 → 1.1.1-dev-20260204144323
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 +40 -40
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { expect as f } from "@playwright/test";
|
|
2
2
|
import { jsxs as d, jsx as u } from "playwright/jsx-runtime";
|
|
3
3
|
import { test as k, expect as v } from "@playwright/experimental-ct-vue";
|
|
4
|
-
const
|
|
5
|
-
const t = [],
|
|
4
|
+
const S = /* @__PURE__ */ Symbol("EMIT_SPY_SYMBOL"), I = () => {
|
|
5
|
+
const t = [], n = (...r) => {
|
|
6
6
|
t.push(r);
|
|
7
7
|
};
|
|
8
|
-
return
|
|
9
|
-
}, Y = (t,
|
|
10
|
-
const e = t[
|
|
11
|
-
f(e).toHaveLength(
|
|
12
|
-
const c = e[
|
|
8
|
+
return n[S] = t, n;
|
|
9
|
+
}, Y = (t, n, r) => {
|
|
10
|
+
const e = t[S];
|
|
11
|
+
f(e).toHaveLength(n);
|
|
12
|
+
const c = e[n - 1];
|
|
13
13
|
return r && f(c).toMatchObject(r), c;
|
|
14
|
-
}, m = (t) => t.replace(/\W/g, "-"), L = (t) => {
|
|
15
|
-
const
|
|
14
|
+
}, m = (t) => t.replace(/\W/g, (n) => n.codePointAt(0)?.toString() || "-"), L = (t) => {
|
|
15
|
+
const n = () => {
|
|
16
16
|
const r = [
|
|
17
17
|
`"blank ${t.columns.map((e) => `column-${m(e)}`).join(" ")}"`
|
|
18
18
|
];
|
|
@@ -45,7 +45,7 @@ const $ = /* @__PURE__ */ Symbol("EMIT_SPY_SYMBOL"), I = () => {
|
|
|
45
45
|
alignItems: "center",
|
|
46
46
|
justifyContent: "center",
|
|
47
47
|
gridTemplateColumns: `auto repeat(${t.columns.length}, 1fr)`,
|
|
48
|
-
gridTemplateAreas:
|
|
48
|
+
gridTemplateAreas: n()
|
|
49
49
|
},
|
|
50
50
|
children: [
|
|
51
51
|
/* @__PURE__ */ u("div", { style: { gridArea: "blank" } }),
|
|
@@ -55,36 +55,36 @@ const $ = /* @__PURE__ */ Symbol("EMIT_SPY_SYMBOL"), I = () => {
|
|
|
55
55
|
)
|
|
56
56
|
] });
|
|
57
57
|
}, G = (t = {}) => {
|
|
58
|
-
const
|
|
58
|
+
const n = t.test ?? k;
|
|
59
59
|
return {
|
|
60
60
|
/**
|
|
61
61
|
* Creates a single matrix screenshot that includes the screenshots for every column-row combination.
|
|
62
62
|
*/
|
|
63
63
|
executeMatrixScreenshotTest: async (e) => {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
const E = async (s,
|
|
64
|
+
n(`${e.name}`, async ({ mount: c, page: i, browserName: $, context: b }) => {
|
|
65
|
+
n.setTimeout(e.columns.length * e.rows.length * 25e3);
|
|
66
|
+
const E = async (s, a, l) => {
|
|
67
67
|
await i.getByRole("document").focus(), await i.getByRole("document").hover({ position: { x: 0, y: 0 }, force: !0 }), await i.mouse.up();
|
|
68
68
|
const o = await c(s);
|
|
69
69
|
await t.defaults?.hooks?.beforeEach?.(
|
|
70
70
|
o,
|
|
71
71
|
i,
|
|
72
|
-
|
|
72
|
+
a,
|
|
73
73
|
l,
|
|
74
74
|
e.context
|
|
75
|
-
), await e.hooks?.beforeEach?.(o, i,
|
|
76
|
-
const x = await o.screenshot({ animations: "disabled" }), h = await o.boundingBox(),
|
|
75
|
+
), await e.hooks?.beforeEach?.(o, i, a, l, e.context);
|
|
76
|
+
const x = await o.screenshot({ animations: "disabled" }), h = await o.boundingBox(), B = `${m(l)}-${m(a)}`;
|
|
77
77
|
return await t.defaults?.hooks?.afterEach?.(
|
|
78
78
|
o,
|
|
79
79
|
i,
|
|
80
|
-
|
|
80
|
+
a,
|
|
81
81
|
l,
|
|
82
82
|
e.context
|
|
83
|
-
), await e.hooks?.afterEach?.(o, i,
|
|
83
|
+
), await e.hooks?.afterEach?.(o, i, a, l, e.context), { box: h, id: B, screenshot: x };
|
|
84
84
|
}, w = /* @__PURE__ */ new Map();
|
|
85
85
|
for (const s of e.rows)
|
|
86
|
-
for (const
|
|
87
|
-
const l = e.component(
|
|
86
|
+
for (const a of e.columns) {
|
|
87
|
+
const l = e.component(a, s), o = e.removePadding ?? t.defaults?.removePadding, h = await E(/* @__PURE__ */ u(
|
|
88
88
|
"div",
|
|
89
89
|
{
|
|
90
90
|
style: {
|
|
@@ -94,43 +94,43 @@ const $ = /* @__PURE__ */ Symbol("EMIT_SPY_SYMBOL"), I = () => {
|
|
|
94
94
|
},
|
|
95
95
|
children: l
|
|
96
96
|
}
|
|
97
|
-
),
|
|
97
|
+
), a, s);
|
|
98
98
|
w.set(h.id, h);
|
|
99
99
|
}
|
|
100
100
|
const y = "/_playwright-matrix-screenshot";
|
|
101
|
-
await b.route(`${y}*`, (s,
|
|
102
|
-
const o = new URL(
|
|
101
|
+
await b.route(`${y}*`, (s, a) => {
|
|
102
|
+
const o = new URL(a.url()).searchParams.get("id") ?? "";
|
|
103
103
|
return s.fulfill({
|
|
104
104
|
status: 200,
|
|
105
105
|
contentType: "image/png",
|
|
106
106
|
body: w.get(o)?.screenshot
|
|
107
107
|
});
|
|
108
108
|
});
|
|
109
|
-
const T = Array.from(w.values()).map(({ box: s, id:
|
|
109
|
+
const T = Array.from(w.values()).map(({ box: s, id: a }) => /* @__PURE__ */ u(
|
|
110
110
|
"img",
|
|
111
111
|
{
|
|
112
112
|
width: s?.width,
|
|
113
113
|
height: s?.height,
|
|
114
|
-
style: { gridArea:
|
|
115
|
-
src: `${y}?id=${
|
|
116
|
-
alt:
|
|
114
|
+
style: { gridArea: a },
|
|
115
|
+
src: `${y}?id=${a}`,
|
|
116
|
+
alt: a
|
|
117
117
|
}
|
|
118
|
-
)),
|
|
118
|
+
)), A = e.rows.map((s) => g({ name: s, type: "row" })), M = e.columns.map(
|
|
119
119
|
(s) => g({ name: s, type: "column" })
|
|
120
|
-
),
|
|
120
|
+
), P = L({
|
|
121
121
|
columns: e.columns,
|
|
122
122
|
rows: e.rows,
|
|
123
123
|
name: e.name,
|
|
124
|
-
browserName:
|
|
125
|
-
children: [...T, ...
|
|
126
|
-
}),
|
|
127
|
-
await v(
|
|
124
|
+
browserName: $,
|
|
125
|
+
children: [...T, ...A, ...M]
|
|
126
|
+
}), j = await c(P);
|
|
127
|
+
await v(j).toHaveScreenshot(`${e.name}.png`), await i.unroute(`${y}*`);
|
|
128
128
|
});
|
|
129
129
|
}
|
|
130
130
|
};
|
|
131
131
|
}, N = async (t) => {
|
|
132
|
-
await v(t).toBeVisible(), await t.evaluate((
|
|
133
|
-
|
|
132
|
+
await v(t).toBeVisible(), await t.evaluate((n) => {
|
|
133
|
+
n.style.height = `${n.scrollHeight}px`, n.style.width = `${n.scrollWidth}px`;
|
|
134
134
|
});
|
|
135
135
|
}, g = (t) => /* @__PURE__ */ u(
|
|
136
136
|
"div",
|
|
@@ -138,14 +138,14 @@ const $ = /* @__PURE__ */ Symbol("EMIT_SPY_SYMBOL"), I = () => {
|
|
|
138
138
|
style: { textAlign: "center", gridArea: `${t.type}-${m(t.name)}` },
|
|
139
139
|
children: t.name
|
|
140
140
|
}
|
|
141
|
-
), z = async ({ component: t, page:
|
|
142
|
-
if (r === "hover" && await t.hover(), r === "focus-visible" && await
|
|
141
|
+
), z = async ({ component: t, page: n, state: r }) => {
|
|
142
|
+
if (r === "hover" && await t.hover(), r === "focus-visible" && await n.keyboard.press("Tab"), r === "active") {
|
|
143
143
|
const e = await t.boundingBox(), c = { x: e.x + e.width / 2, y: e.y + e.height / 2 };
|
|
144
|
-
await
|
|
144
|
+
await n.mouse.move(c.x, c.y), await n.mouse.down();
|
|
145
145
|
}
|
|
146
146
|
};
|
|
147
147
|
export {
|
|
148
|
-
|
|
148
|
+
S as EMIT_SPY_SYMBOL,
|
|
149
149
|
N as adjustSizeToAbsolutePosition,
|
|
150
150
|
I as createEmitSpy,
|
|
151
151
|
Y as expectEmit,
|
package/package.json
CHANGED