@sit-onyx/playwright-utils 1.1.0 → 1.1.1-dev-20260205082424

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.
Files changed (2) hide show
  1. package/dist/index.js +40 -40
  2. 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 $ = /* @__PURE__ */ Symbol("EMIT_SPY_SYMBOL"), I = () => {
5
- const t = [], a = (...r) => {
4
+ const S = /* @__PURE__ */ Symbol("EMIT_SPY_SYMBOL"), I = () => {
5
+ const t = [], n = (...r) => {
6
6
  t.push(r);
7
7
  };
8
- return a[$] = t, a;
9
- }, Y = (t, a, r) => {
10
- const e = t[$];
11
- f(e).toHaveLength(a);
12
- const c = e[a - 1];
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 a = () => {
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: a()
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 a = t.test ?? k;
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
- a(`${e.name}`, async ({ mount: c, page: i, browserName: S, context: b }) => {
65
- a.setTimeout(e.columns.length * e.rows.length * 25e3);
66
- const E = async (s, n, l) => {
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
- n,
72
+ a,
73
73
  l,
74
74
  e.context
75
- ), await e.hooks?.beforeEach?.(o, i, n, l, e.context);
76
- const x = await o.screenshot({ animations: "disabled" }), h = await o.boundingBox(), P = `${m(l)}-${m(n)}`;
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
- n,
80
+ a,
81
81
  l,
82
82
  e.context
83
- ), await e.hooks?.afterEach?.(o, i, n, l, e.context), { box: h, id: P, screenshot: x };
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 n of e.columns) {
87
- const l = e.component(n, s), o = e.removePadding ?? t.defaults?.removePadding, h = await E(/* @__PURE__ */ u(
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
- ), n, s);
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, n) => {
102
- const o = new URL(n.url()).searchParams.get("id") ?? "";
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: n }) => /* @__PURE__ */ u(
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: n },
115
- src: `${y}?id=${n}`,
116
- alt: n
114
+ style: { gridArea: a },
115
+ src: `${y}?id=${a}`,
116
+ alt: a
117
117
  }
118
- )), M = e.rows.map((s) => g({ name: s, type: "row" })), A = e.columns.map(
118
+ )), A = e.rows.map((s) => g({ name: s, type: "row" })), M = e.columns.map(
119
119
  (s) => g({ name: s, type: "column" })
120
- ), j = L({
120
+ ), P = L({
121
121
  columns: e.columns,
122
122
  rows: e.rows,
123
123
  name: e.name,
124
- browserName: S,
125
- children: [...T, ...M, ...A]
126
- }), B = await c(j);
127
- await v(B).toHaveScreenshot(`${e.name}.png`), await i.unroute(`${y}*`);
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((a) => {
133
- a.style.height = `${a.scrollHeight}px`, a.style.width = `${a.scrollWidth}px`;
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: a, state: r }) => {
142
- if (r === "hover" && await t.hover(), r === "focus-visible" && await a.keyboard.press("Tab"), r === "active") {
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 a.mouse.move(c.x, c.y), await a.mouse.down();
144
+ await n.mouse.move(c.x, c.y), await n.mouse.down();
145
145
  }
146
146
  };
147
147
  export {
148
- $ as EMIT_SPY_SYMBOL,
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
@@ -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.1.0",
4
+ "version": "1.1.1-dev-20260205082424",
5
5
  "type": "module",
6
6
  "author": "Schwarz IT KG",
7
7
  "license": "Apache-2.0",