@immense/vue-pom-generator 1.0.92 → 1.0.94
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/README.md +33 -17
- package/RELEASE_NOTES.md +64 -100
- package/dist/index.cjs +789 -296
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +790 -297
- package/dist/index.mjs.map +1 -1
- package/dist/playwright/runtime.cjs +945 -0
- package/dist/playwright/runtime.cjs.map +1 -0
- package/dist/playwright/runtime.mjs +945 -0
- package/dist/playwright/runtime.mjs.map +1 -0
- package/dist/plugin/create-vue-pom-generator-plugins.d.ts.map +1 -1
- package/dist/plugin/internal/build-plugin.d.ts +1 -1
- package/dist/plugin/internal/build-plugin.d.ts.map +1 -1
- package/dist/plugin/internal/dev-plugin.d.ts +1 -1
- package/dist/plugin/internal/dev-plugin.d.ts.map +1 -1
- package/dist/plugin/internal-plugins.d.ts +1 -1
- package/dist/plugin/internal-plugins.d.ts.map +1 -1
- package/dist/plugin/resolved-injection-options.d.ts +2 -2
- package/dist/plugin/resolved-injection-options.d.ts.map +1 -1
- package/dist/plugin/types.d.ts +13 -7
- package/dist/plugin/types.d.ts.map +1 -1
- package/dist/plugin/vue-plugin.d.ts +1 -1
- package/dist/plugin/vue-plugin.d.ts.map +1 -1
- package/dist/tests/wrapper-contract.test.d.ts +2 -0
- package/dist/tests/wrapper-contract.test.d.ts.map +1 -0
- package/dist/transform.d.ts +6 -12
- package/dist/transform.d.ts.map +1 -1
- package/dist/utils.d.ts.map +1 -1
- package/dist/vite.config.d.ts.map +1 -1
- package/dist/wrapper-contract.d.ts +37 -0
- package/dist/wrapper-contract.d.ts.map +1 -0
- package/package.json +6 -1
|
@@ -0,0 +1,945 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const POINTER_CALLOUT_IDS = {
|
|
4
|
+
annotation: "__pw_pointer_callout__",
|
|
5
|
+
arrow: "__pw_pointer_callout_arrow__",
|
|
6
|
+
content: "__pw_pointer_callout_content__"
|
|
7
|
+
};
|
|
8
|
+
const POINTER_CALLOUT_THEME = {
|
|
9
|
+
background: "#dc2626",
|
|
10
|
+
border: "0px solid transparent",
|
|
11
|
+
borderRadius: 0,
|
|
12
|
+
boxShadow: "0 20px 44px rgba(127, 29, 29, 0.32)",
|
|
13
|
+
charsPerLine: 28,
|
|
14
|
+
gap: 18,
|
|
15
|
+
margin: 18,
|
|
16
|
+
maxWidth: 320,
|
|
17
|
+
minHeight: 52,
|
|
18
|
+
minWidth: 180,
|
|
19
|
+
textColor: "#f8fafc"
|
|
20
|
+
};
|
|
21
|
+
function measureCalloutBubble(text) {
|
|
22
|
+
return {
|
|
23
|
+
bubbleWidth: Math.min(
|
|
24
|
+
POINTER_CALLOUT_THEME.maxWidth,
|
|
25
|
+
Math.max(
|
|
26
|
+
POINTER_CALLOUT_THEME.minWidth,
|
|
27
|
+
Math.min(text.length, POINTER_CALLOUT_THEME.charsPerLine) * 7 + 44
|
|
28
|
+
)
|
|
29
|
+
),
|
|
30
|
+
bubbleHeight: Math.max(
|
|
31
|
+
POINTER_CALLOUT_THEME.minHeight,
|
|
32
|
+
Math.ceil(Math.max(text.length, 1) / POINTER_CALLOUT_THEME.charsPerLine) * 20 + 24
|
|
33
|
+
)
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
async function __pw_ensure_simple_callout__(page) {
|
|
37
|
+
await page.evaluate(
|
|
38
|
+
({
|
|
39
|
+
annotationId,
|
|
40
|
+
contentId,
|
|
41
|
+
background,
|
|
42
|
+
border,
|
|
43
|
+
borderRadius,
|
|
44
|
+
boxShadow,
|
|
45
|
+
textColor
|
|
46
|
+
}) => {
|
|
47
|
+
const ensureElement = (id, tagName) => {
|
|
48
|
+
const existing = document.getElementById(id);
|
|
49
|
+
if (existing instanceof HTMLElement) {
|
|
50
|
+
return existing;
|
|
51
|
+
}
|
|
52
|
+
const created = document.createElement(tagName);
|
|
53
|
+
created.id = id;
|
|
54
|
+
return created;
|
|
55
|
+
};
|
|
56
|
+
const annotation = ensureElement(annotationId, "div");
|
|
57
|
+
annotation.setAttribute(
|
|
58
|
+
"style",
|
|
59
|
+
[
|
|
60
|
+
"position:fixed",
|
|
61
|
+
"z-index:2147483647",
|
|
62
|
+
"pointer-events:none",
|
|
63
|
+
"left:18px",
|
|
64
|
+
"top:18px",
|
|
65
|
+
"width:220px",
|
|
66
|
+
"box-sizing:border-box",
|
|
67
|
+
"padding:12px 16px",
|
|
68
|
+
"border:" + border,
|
|
69
|
+
"border-radius:" + borderRadius + "px",
|
|
70
|
+
"background:" + background,
|
|
71
|
+
"color:" + textColor,
|
|
72
|
+
"font:600 13px/1.45 Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif",
|
|
73
|
+
"letter-spacing:0.01em",
|
|
74
|
+
"box-shadow:" + boxShadow,
|
|
75
|
+
"opacity:0",
|
|
76
|
+
"white-space:normal",
|
|
77
|
+
"transform:translate3d(0,0,0)",
|
|
78
|
+
"transform-origin:center"
|
|
79
|
+
].join(";")
|
|
80
|
+
);
|
|
81
|
+
const content = ensureElement(contentId, "div");
|
|
82
|
+
content.setAttribute("style", "position:relative;z-index:1;");
|
|
83
|
+
if (!annotation.isConnected) {
|
|
84
|
+
document.body.appendChild(annotation);
|
|
85
|
+
}
|
|
86
|
+
if (content.parentElement !== annotation) {
|
|
87
|
+
annotation.appendChild(content);
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
annotationId: POINTER_CALLOUT_IDS.annotation,
|
|
92
|
+
contentId: POINTER_CALLOUT_IDS.content,
|
|
93
|
+
background: POINTER_CALLOUT_THEME.background,
|
|
94
|
+
border: POINTER_CALLOUT_THEME.border,
|
|
95
|
+
borderRadius: POINTER_CALLOUT_THEME.borderRadius,
|
|
96
|
+
boxShadow: POINTER_CALLOUT_THEME.boxShadow,
|
|
97
|
+
textColor: POINTER_CALLOUT_THEME.textColor
|
|
98
|
+
}
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
const __pw_default_callout_renderer__ = {
|
|
102
|
+
overlayIds: [
|
|
103
|
+
POINTER_CALLOUT_IDS.annotation,
|
|
104
|
+
POINTER_CALLOUT_IDS.content,
|
|
105
|
+
POINTER_CALLOUT_IDS.arrow
|
|
106
|
+
],
|
|
107
|
+
async hide(page) {
|
|
108
|
+
await page.evaluate(
|
|
109
|
+
({ annotationId, contentId, arrowId }) => {
|
|
110
|
+
const annotation = document.getElementById(annotationId);
|
|
111
|
+
const content = document.getElementById(contentId);
|
|
112
|
+
const arrow = document.getElementById(arrowId);
|
|
113
|
+
if (!annotation) {
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
if (content) {
|
|
117
|
+
content.textContent = "";
|
|
118
|
+
}
|
|
119
|
+
annotation.style.transition = "opacity 120ms ease-in-out, transform 160ms ease-in-out";
|
|
120
|
+
annotation.style.opacity = "0";
|
|
121
|
+
annotation.style.transform = "scale(0.96)";
|
|
122
|
+
annotation.setAttribute("data-placement", "hidden");
|
|
123
|
+
if (arrow) {
|
|
124
|
+
arrow.style.opacity = "0";
|
|
125
|
+
arrow.style.left = "";
|
|
126
|
+
arrow.style.top = "";
|
|
127
|
+
arrow.style.right = "";
|
|
128
|
+
arrow.style.bottom = "";
|
|
129
|
+
}
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
annotationId: POINTER_CALLOUT_IDS.annotation,
|
|
133
|
+
contentId: POINTER_CALLOUT_IDS.content,
|
|
134
|
+
arrowId: POINTER_CALLOUT_IDS.arrow
|
|
135
|
+
}
|
|
136
|
+
);
|
|
137
|
+
},
|
|
138
|
+
async show(page, request) {
|
|
139
|
+
await __pw_ensure_simple_callout__(page);
|
|
140
|
+
const { bubbleHeight, bubbleWidth } = measureCalloutBubble(request.text);
|
|
141
|
+
await page.evaluate(
|
|
142
|
+
({
|
|
143
|
+
annotationId,
|
|
144
|
+
contentId,
|
|
145
|
+
arrowId,
|
|
146
|
+
bubbleHeight: bubbleHeight2,
|
|
147
|
+
bubbleWidth: bubbleWidth2,
|
|
148
|
+
border,
|
|
149
|
+
borderRadius,
|
|
150
|
+
background,
|
|
151
|
+
gap,
|
|
152
|
+
text,
|
|
153
|
+
targetBox,
|
|
154
|
+
margin
|
|
155
|
+
}) => {
|
|
156
|
+
const annotation = document.getElementById(annotationId);
|
|
157
|
+
const content = document.getElementById(contentId);
|
|
158
|
+
const arrow = document.getElementById(arrowId);
|
|
159
|
+
if (!annotation || !content) {
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
const viewportWidth = Math.max(window.innerWidth || 0, document.documentElement.clientWidth, 1280);
|
|
163
|
+
const viewportHeight = Math.max(window.innerHeight || 0, document.documentElement.clientHeight, 720);
|
|
164
|
+
const clamp = (value, min, max) => Math.min(max, Math.max(min, value));
|
|
165
|
+
const targetCenterX = targetBox.x + targetBox.width / 2;
|
|
166
|
+
const targetCenterY = targetBox.y + targetBox.height / 2;
|
|
167
|
+
const maxX = Math.max(margin, viewportWidth - bubbleWidth2 - margin);
|
|
168
|
+
const maxY = Math.max(margin, viewportHeight - bubbleHeight2 - margin);
|
|
169
|
+
const candidates = [
|
|
170
|
+
{
|
|
171
|
+
placement: "right",
|
|
172
|
+
x: targetBox.x + targetBox.width + gap,
|
|
173
|
+
y: targetCenterY - bubbleHeight2 / 2
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
placement: "bottom",
|
|
177
|
+
x: targetCenterX - bubbleWidth2 / 2,
|
|
178
|
+
y: targetBox.y + targetBox.height + gap
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
placement: "left",
|
|
182
|
+
x: targetBox.x - bubbleWidth2 - gap,
|
|
183
|
+
y: targetCenterY - bubbleHeight2 / 2
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
placement: "top",
|
|
187
|
+
x: targetCenterX - bubbleWidth2 / 2,
|
|
188
|
+
y: targetBox.y - bubbleHeight2 - gap
|
|
189
|
+
}
|
|
190
|
+
];
|
|
191
|
+
let placement = "center";
|
|
192
|
+
let resolvedX = clamp(targetCenterX - bubbleWidth2 / 2, margin, maxX);
|
|
193
|
+
let resolvedY = clamp(targetCenterY - bubbleHeight2 / 2, margin, maxY);
|
|
194
|
+
for (const candidate of candidates) {
|
|
195
|
+
const clampedX = clamp(candidate.x, margin, maxX);
|
|
196
|
+
const clampedY = clamp(candidate.y, margin, maxY);
|
|
197
|
+
const fitsWithoutShift = Math.abs(clampedX - candidate.x) < 1 && Math.abs(clampedY - candidate.y) < 1;
|
|
198
|
+
if (fitsWithoutShift) {
|
|
199
|
+
placement = candidate.placement;
|
|
200
|
+
resolvedX = candidate.x;
|
|
201
|
+
resolvedY = candidate.y;
|
|
202
|
+
break;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
content.textContent = text;
|
|
206
|
+
annotation.style.width = `${bubbleWidth2}px`;
|
|
207
|
+
annotation.style.minHeight = `${bubbleHeight2}px`;
|
|
208
|
+
annotation.style.background = background;
|
|
209
|
+
annotation.style.border = border;
|
|
210
|
+
annotation.style.borderRadius = `${borderRadius}px`;
|
|
211
|
+
annotation.style.transition = "opacity 120ms ease-in-out, transform 160ms ease-in-out";
|
|
212
|
+
annotation.style.willChange = "left, top, opacity, transform";
|
|
213
|
+
annotation.style.left = `${Math.round(resolvedX)}px`;
|
|
214
|
+
annotation.style.top = `${Math.round(resolvedY)}px`;
|
|
215
|
+
annotation.style.opacity = "1";
|
|
216
|
+
annotation.style.transform = "scale(1)";
|
|
217
|
+
annotation.setAttribute("data-placement", placement);
|
|
218
|
+
if (arrow) {
|
|
219
|
+
arrow.style.opacity = "0";
|
|
220
|
+
arrow.style.left = "";
|
|
221
|
+
arrow.style.top = "";
|
|
222
|
+
arrow.style.right = "";
|
|
223
|
+
arrow.style.bottom = "";
|
|
224
|
+
}
|
|
225
|
+
},
|
|
226
|
+
{
|
|
227
|
+
annotationId: POINTER_CALLOUT_IDS.annotation,
|
|
228
|
+
contentId: POINTER_CALLOUT_IDS.content,
|
|
229
|
+
arrowId: POINTER_CALLOUT_IDS.arrow,
|
|
230
|
+
bubbleHeight,
|
|
231
|
+
bubbleWidth,
|
|
232
|
+
border: POINTER_CALLOUT_THEME.border,
|
|
233
|
+
borderRadius: POINTER_CALLOUT_THEME.borderRadius,
|
|
234
|
+
background: POINTER_CALLOUT_THEME.background,
|
|
235
|
+
gap: POINTER_CALLOUT_THEME.gap,
|
|
236
|
+
text: request.text,
|
|
237
|
+
targetBox: request.targetBox,
|
|
238
|
+
margin: POINTER_CALLOUT_THEME.margin
|
|
239
|
+
}
|
|
240
|
+
);
|
|
241
|
+
}
|
|
242
|
+
};
|
|
243
|
+
class Callout {
|
|
244
|
+
page;
|
|
245
|
+
extraOverlayIds;
|
|
246
|
+
renderer;
|
|
247
|
+
constructor(page, options) {
|
|
248
|
+
this.page = page;
|
|
249
|
+
this.extraOverlayIds = options?.extraOverlayIds ?? [];
|
|
250
|
+
this.renderer = options?.renderer ?? __pw_default_callout_renderer__;
|
|
251
|
+
}
|
|
252
|
+
toLocator(target) {
|
|
253
|
+
return typeof target === "string" ? this.page.locator(target) : target;
|
|
254
|
+
}
|
|
255
|
+
async hide() {
|
|
256
|
+
await this.renderer.hide(this.page);
|
|
257
|
+
}
|
|
258
|
+
async showForElement(target, annotationText, options) {
|
|
259
|
+
const text = annotationText.trim();
|
|
260
|
+
if (!text) {
|
|
261
|
+
await this.hide();
|
|
262
|
+
return;
|
|
263
|
+
}
|
|
264
|
+
const locator = this.toLocator(target);
|
|
265
|
+
if (!options?.skipScroll) {
|
|
266
|
+
try {
|
|
267
|
+
await locator.first().scrollIntoViewIfNeeded();
|
|
268
|
+
} catch {
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
const targetBox = options?.targetBox ?? await locator.first().boundingBox();
|
|
272
|
+
if (!targetBox) {
|
|
273
|
+
throw new Error("Callout.showForElement: target has no bounding box");
|
|
274
|
+
}
|
|
275
|
+
const overlayIds = Array.from(/* @__PURE__ */ new Set([
|
|
276
|
+
...this.renderer.overlayIds ?? [],
|
|
277
|
+
...this.extraOverlayIds
|
|
278
|
+
]));
|
|
279
|
+
await this.renderer.show(this.page, {
|
|
280
|
+
overlayIds,
|
|
281
|
+
target,
|
|
282
|
+
targetBox: {
|
|
283
|
+
height: targetBox.height,
|
|
284
|
+
width: targetBox.width,
|
|
285
|
+
x: targetBox.x,
|
|
286
|
+
y: targetBox.y
|
|
287
|
+
},
|
|
288
|
+
text
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
const __PW_POINTER_ID__ = "__pw_pointer__";
|
|
293
|
+
const __PW_EDITABLE_DESCENDANT_SELECTOR__ = "input, textarea, select, [contenteditable=''], [contenteditable='true'], [contenteditable]:not([contenteditable='false'])";
|
|
294
|
+
const __PW_POINTER_PNG__ = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAeCAQAAACGG/bgAAAAAmJLR0QA/4ePzL8AAAAJcEhZcwAAHsYAAB7GAZEt8iwAAAAHdElNRQfgAwgMIwdxU/i7AAABZklEQVQ4y43TsU4UURSH8W+XmYwkS2I09CRKpKGhsvIJjG9giQmliHFZlkUIGnEF7KTiCagpsYHWhoTQaiUUxLixYZb5KAAZZhbunu7O/PKfe+fcA+/pqwb4DuximEqXhT4iI8dMpBWEsWsuGYdpZFttiLSSgTvhZ1W/SvfO1CvYdV1kPghV68a30zzUWZH5pBqEui7dnqlFmLoq0gxC1XfGZdoLal2kea8ahLoqKXNAJQBT2yJzwUTVt0bS6ANqy1gaVCEq/oVTtjji4hQVhhnlYBH4WIJV9vlkXLm+10R8oJb79Jl1j9UdazJRGpkrmNkSF9SOz2T71s7MSIfD2lmmfjGSRz3hK8l4w1P+bah/HJLN0sys2JSMZQB+jKo6KSc8vLlLn5ikzF4268Wg2+pPOWW6ONcpr3PrXy9VfS473M/D7H+TLmrqsXtOGctvxvMv2oVNP+Av0uHbzbxyJaywyUjx8TlnPY2YxqkDdAAAAABJRU5ErkJggg==";
|
|
295
|
+
const __pw_pointer_positions__ = /* @__PURE__ */ new WeakMap();
|
|
296
|
+
function __pw_set_pointer_pos__(page, x, y) {
|
|
297
|
+
__pw_pointer_positions__.set(page, { x, y });
|
|
298
|
+
}
|
|
299
|
+
let animationOptions = {
|
|
300
|
+
extraDelayMs: 0
|
|
301
|
+
};
|
|
302
|
+
const __pw_default_pointer_renderer__ = {
|
|
303
|
+
overlayIds: [__PW_POINTER_ID__],
|
|
304
|
+
async ensure(page) {
|
|
305
|
+
const exists = await page.evaluate(
|
|
306
|
+
({ pointerId }) => document.getElementById(pointerId) != null,
|
|
307
|
+
{ pointerId: __PW_POINTER_ID__ }
|
|
308
|
+
);
|
|
309
|
+
if (exists) return;
|
|
310
|
+
__pw_set_pointer_pos__(page, 0, 0);
|
|
311
|
+
await page.evaluate(
|
|
312
|
+
({ id, src }) => {
|
|
313
|
+
const img = document.createElement("img");
|
|
314
|
+
img.setAttribute("src", src);
|
|
315
|
+
img.setAttribute("id", id);
|
|
316
|
+
img.setAttribute(
|
|
317
|
+
"style",
|
|
318
|
+
"position:fixed;z-index:2147483647;pointer-events:none;left:0;top:0;transform-origin:0 0;"
|
|
319
|
+
);
|
|
320
|
+
document.body.appendChild(img);
|
|
321
|
+
},
|
|
322
|
+
{
|
|
323
|
+
id: __PW_POINTER_ID__,
|
|
324
|
+
src: __PW_POINTER_PNG__
|
|
325
|
+
}
|
|
326
|
+
);
|
|
327
|
+
},
|
|
328
|
+
async move(page, request) {
|
|
329
|
+
await page.evaluate(
|
|
330
|
+
({
|
|
331
|
+
animate,
|
|
332
|
+
dur,
|
|
333
|
+
ex,
|
|
334
|
+
ey,
|
|
335
|
+
id,
|
|
336
|
+
style,
|
|
337
|
+
sx,
|
|
338
|
+
sy
|
|
339
|
+
}) => {
|
|
340
|
+
const el = document.getElementById(id);
|
|
341
|
+
if (!el) {
|
|
342
|
+
return;
|
|
343
|
+
}
|
|
344
|
+
el.style.transition = "";
|
|
345
|
+
el.style.willChange = "left, top";
|
|
346
|
+
el.style.left = `${animate ? sx : ex}px`;
|
|
347
|
+
el.style.top = `${animate ? sy : ey}px`;
|
|
348
|
+
if (animate) {
|
|
349
|
+
void el.offsetWidth;
|
|
350
|
+
el.style.transition = `left ${dur}ms ${style}, top ${dur}ms ${style}`;
|
|
351
|
+
el.style.left = `${ex}px`;
|
|
352
|
+
el.style.top = `${ey}px`;
|
|
353
|
+
}
|
|
354
|
+
},
|
|
355
|
+
{
|
|
356
|
+
animate: request.animate,
|
|
357
|
+
dur: request.durationMilliseconds,
|
|
358
|
+
ex: request.endX,
|
|
359
|
+
ey: request.endY,
|
|
360
|
+
id: __PW_POINTER_ID__,
|
|
361
|
+
style: request.transitionStyle,
|
|
362
|
+
sx: request.startX,
|
|
363
|
+
sy: request.startY
|
|
364
|
+
}
|
|
365
|
+
);
|
|
366
|
+
},
|
|
367
|
+
async press(page, request) {
|
|
368
|
+
await page.evaluate(
|
|
369
|
+
({ id, dur }) => {
|
|
370
|
+
const el = document.getElementById(id);
|
|
371
|
+
if (el) {
|
|
372
|
+
el.style.transition = `transform ${dur}ms`;
|
|
373
|
+
el.style.transform = "scale(0.6)";
|
|
374
|
+
setTimeout(() => {
|
|
375
|
+
el.style.transition = `transform ${dur}ms`;
|
|
376
|
+
el.style.transform = "scale(1)";
|
|
377
|
+
}, dur);
|
|
378
|
+
}
|
|
379
|
+
},
|
|
380
|
+
{ id: __PW_POINTER_ID__, dur: request.durationMilliseconds }
|
|
381
|
+
);
|
|
382
|
+
}
|
|
383
|
+
};
|
|
384
|
+
class Pointer {
|
|
385
|
+
page;
|
|
386
|
+
testIdAttribute;
|
|
387
|
+
callout;
|
|
388
|
+
renderer;
|
|
389
|
+
constructor(page, testIdAttribute, callout, renderer) {
|
|
390
|
+
this.page = page;
|
|
391
|
+
this.testIdAttribute = (testIdAttribute ?? "data-testid").trim() || "data-testid";
|
|
392
|
+
this.renderer = renderer ?? __pw_default_pointer_renderer__;
|
|
393
|
+
const calloutOptions = {
|
|
394
|
+
extraOverlayIds: this.renderer.overlayIds
|
|
395
|
+
};
|
|
396
|
+
this.callout = callout ?? new Callout(page, calloutOptions);
|
|
397
|
+
}
|
|
398
|
+
toLocator(target) {
|
|
399
|
+
return typeof target === "string" ? this.page.locator(target) : target;
|
|
400
|
+
}
|
|
401
|
+
async getTestId(locator) {
|
|
402
|
+
const raw = await locator.first().getAttribute(this.testIdAttribute);
|
|
403
|
+
const trimmed = (raw ?? "").trim();
|
|
404
|
+
return trimmed || void 0;
|
|
405
|
+
}
|
|
406
|
+
/**
|
|
407
|
+
* Playwright waits for an element's box to be stable, but a component library can
|
|
408
|
+
* still suppress pointer handlers while an ancestor overlay is finishing a CSS
|
|
409
|
+
* transition. Wait for finite animations on the target's ancestor chain so the
|
|
410
|
+
* generated action observes the same ready state a user sees. Infinite decorative
|
|
411
|
+
* animations are ignored, and a stuck finite animation fails within the shared 5s
|
|
412
|
+
* interaction budget instead of encouraging consumer-side sleeps.
|
|
413
|
+
*/
|
|
414
|
+
async waitForFiniteAncestorAnimations(locator) {
|
|
415
|
+
await locator.first().evaluate(async (element) => {
|
|
416
|
+
const timeoutMs = 5e3;
|
|
417
|
+
const animations = /* @__PURE__ */ new Set();
|
|
418
|
+
for (let current = element; current; current = current.parentElement ?? null) {
|
|
419
|
+
if (typeof current.getAnimations !== "function") continue;
|
|
420
|
+
for (const animation of current.getAnimations()) {
|
|
421
|
+
const iterations = Number(animation.effect?.getComputedTiming().iterations ?? 1);
|
|
422
|
+
if (animation.playState === "running" && Number.isFinite(iterations)) {
|
|
423
|
+
animations.add(animation);
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
if (animations.size === 0) return;
|
|
428
|
+
let timer;
|
|
429
|
+
try {
|
|
430
|
+
await Promise.race([
|
|
431
|
+
Promise.allSettled([...animations].map((animation) => animation.finished)),
|
|
432
|
+
new Promise((_resolve, reject) => {
|
|
433
|
+
timer = setTimeout(() => {
|
|
434
|
+
reject(new Error(`[vue-pom-generator] Timed out after ${timeoutMs}ms waiting for click-target animations to finish.`));
|
|
435
|
+
}, timeoutMs);
|
|
436
|
+
})
|
|
437
|
+
]);
|
|
438
|
+
} finally {
|
|
439
|
+
if (timer !== void 0) clearTimeout(timer);
|
|
440
|
+
}
|
|
441
|
+
});
|
|
442
|
+
}
|
|
443
|
+
async isEditableElement(locator) {
|
|
444
|
+
try {
|
|
445
|
+
return await locator.first().evaluate((element) => {
|
|
446
|
+
if (!(element instanceof HTMLElement)) {
|
|
447
|
+
return false;
|
|
448
|
+
}
|
|
449
|
+
const tagName = element.tagName.toLowerCase();
|
|
450
|
+
return tagName === "input" || tagName === "textarea" || tagName === "select" || element.isContentEditable;
|
|
451
|
+
});
|
|
452
|
+
} catch {
|
|
453
|
+
return false;
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
async resolveEditableLocator(locator) {
|
|
457
|
+
const first = locator.first();
|
|
458
|
+
if (await this.isEditableElement(first)) {
|
|
459
|
+
return first;
|
|
460
|
+
}
|
|
461
|
+
const descendant = first.locator(__PW_EDITABLE_DESCENDANT_SELECTOR__).first();
|
|
462
|
+
try {
|
|
463
|
+
if (await descendant.count() > 0) {
|
|
464
|
+
return descendant;
|
|
465
|
+
}
|
|
466
|
+
} catch {
|
|
467
|
+
}
|
|
468
|
+
return first;
|
|
469
|
+
}
|
|
470
|
+
async animateCursorToElement(target, executeClick = true, delayMs = 1e3, annotationText = "", options) {
|
|
471
|
+
const locator = this.toLocator(target);
|
|
472
|
+
const trimmedAnnotationText = annotationText.trim();
|
|
473
|
+
const opts = animationOptions;
|
|
474
|
+
if (executeClick) {
|
|
475
|
+
await this.waitForFiniteAncestorAnimations(locator);
|
|
476
|
+
}
|
|
477
|
+
{
|
|
478
|
+
if (trimmedAnnotationText) {
|
|
479
|
+
await this.callout.showForElement(locator, trimmedAnnotationText);
|
|
480
|
+
}
|
|
481
|
+
const extraDelay = Math.max(0, opts.extraDelayMs);
|
|
482
|
+
if (extraDelay > 0) await this.page.waitForTimeout(extraDelay);
|
|
483
|
+
let clickedTestId2;
|
|
484
|
+
if (executeClick) {
|
|
485
|
+
if (options?.afterClick) {
|
|
486
|
+
try {
|
|
487
|
+
clickedTestId2 = await this.getTestId(locator);
|
|
488
|
+
} catch {
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
await locator.first().click();
|
|
492
|
+
}
|
|
493
|
+
if (options?.afterClick) {
|
|
494
|
+
await options.afterClick({ testId: clickedTestId2, instrumented: Boolean(clickedTestId2) });
|
|
495
|
+
}
|
|
496
|
+
return;
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
async animateCursorToElementAndClickAndFill(target, text, executeClick = true, delayMs = 1e3, annotationText = "", options) {
|
|
500
|
+
await this.animateCursorToElement(target, executeClick, delayMs, annotationText, options);
|
|
501
|
+
const locator = this.toLocator(target);
|
|
502
|
+
const editableLocator = await this.resolveEditableLocator(locator);
|
|
503
|
+
{
|
|
504
|
+
await editableLocator.fill(text);
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
const POM_ACTIVE_ACTION_REGISTRY = /* @__PURE__ */ Symbol.for("@immense/vue-pom-generator.active-action-registry");
|
|
509
|
+
function setPomAction(page, action) {
|
|
510
|
+
const globalRecord = globalThis;
|
|
511
|
+
const registry = globalRecord[POM_ACTIVE_ACTION_REGISTRY] ?? /* @__PURE__ */ new WeakMap();
|
|
512
|
+
globalRecord[POM_ACTIVE_ACTION_REGISTRY] = registry;
|
|
513
|
+
registry.set(page, { ...action, expectedTestIds: [...action.expectedTestIds] });
|
|
514
|
+
}
|
|
515
|
+
class ObjectId {
|
|
516
|
+
raw;
|
|
517
|
+
constructor(raw) {
|
|
518
|
+
if (!raw) {
|
|
519
|
+
throw new Error("ObjectId: raw value is empty");
|
|
520
|
+
}
|
|
521
|
+
this.raw = raw;
|
|
522
|
+
}
|
|
523
|
+
toString() {
|
|
524
|
+
return this.raw;
|
|
525
|
+
}
|
|
526
|
+
asInt() {
|
|
527
|
+
return this.AsInt();
|
|
528
|
+
}
|
|
529
|
+
AsInt() {
|
|
530
|
+
if (!/^\d+$/.test(this.raw)) {
|
|
531
|
+
throw new Error(`ObjectId.AsInt: '${this.raw}' is not a base-10 integer string`);
|
|
532
|
+
}
|
|
533
|
+
const parsed = Number.parseInt(this.raw, 10);
|
|
534
|
+
if (!Number.isSafeInteger(parsed)) {
|
|
535
|
+
throw new TypeError(`ObjectId.AsInt: '${this.raw}' is not a safe integer`);
|
|
536
|
+
}
|
|
537
|
+
return parsed;
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
class BasePage {
|
|
541
|
+
testIdAttribute;
|
|
542
|
+
callout;
|
|
543
|
+
pointer;
|
|
544
|
+
/**
|
|
545
|
+
* The narrowed Playwright page, stored privately. The narrowing (`PwPage` =
|
|
546
|
+
* `BasePagePage`) is what lets the unit-test `FakePage` double satisfy the
|
|
547
|
+
* constructor without stubbing ~250 `Page` members; it never escapes this
|
|
548
|
+
* class. Subclasses (generated and hand-written POMs) reach the page through
|
|
549
|
+
* the widened {@link BasePage.page} getter, which surfaces Playwright's full
|
|
550
|
+
* `Page` so custom POMs can use `getByRole`/`waitForResponse`/`waitForFunction`
|
|
551
|
+
* etc. for JS/DOM elements the generator can't key.
|
|
552
|
+
*/
|
|
553
|
+
_page;
|
|
554
|
+
/**
|
|
555
|
+
* Playwright's full `Page`, exposed to subclasses. This is the single,
|
|
556
|
+
* sanctioned way generated/custom POMs touch the page — there is no separate
|
|
557
|
+
* `rawPage`. The narrowed storage (`_page`) is widened here; the value is a
|
|
558
|
+
* real `Page` at runtime.
|
|
559
|
+
*/
|
|
560
|
+
get page() {
|
|
561
|
+
return this._page;
|
|
562
|
+
}
|
|
563
|
+
/**
|
|
564
|
+
* @param page - Playwright page object (narrowed `PwPage` so test doubles fit).
|
|
565
|
+
*/
|
|
566
|
+
constructor(page, options) {
|
|
567
|
+
this._page = page;
|
|
568
|
+
this.testIdAttribute = (options?.testIdAttribute || "data-testid").trim() || "data-testid";
|
|
569
|
+
const pointerRenderer = options?.renderers?.pointer;
|
|
570
|
+
this.callout = new Callout(this._page, {
|
|
571
|
+
extraOverlayIds: pointerRenderer?.overlayIds,
|
|
572
|
+
renderer: options?.renderers?.callout
|
|
573
|
+
});
|
|
574
|
+
this.pointer = new Pointer(this._page, this.testIdAttribute, this.callout, pointerRenderer);
|
|
575
|
+
}
|
|
576
|
+
get screencast() {
|
|
577
|
+
return this.page.screencast;
|
|
578
|
+
}
|
|
579
|
+
async waitForTestIdClickEventAfter(testId, options) {
|
|
580
|
+
{
|
|
581
|
+
return;
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
getAfterPointerClick(wait = true) {
|
|
585
|
+
return void 0;
|
|
586
|
+
}
|
|
587
|
+
selectorForTestId(testId) {
|
|
588
|
+
return `[${this.testIdAttribute}="${testId}"]`;
|
|
589
|
+
}
|
|
590
|
+
describeLocator(locator, description) {
|
|
591
|
+
const normalizedDescription = description?.trim();
|
|
592
|
+
return normalizedDescription ? locator.describe(normalizedDescription) : locator;
|
|
593
|
+
}
|
|
594
|
+
locatorByTestId(testId, description) {
|
|
595
|
+
return this.describeLocator(this.page.locator(this.selectorForTestId(testId)), description);
|
|
596
|
+
}
|
|
597
|
+
async resolveVisibleTestIdLocator(testIds, description, methodName, componentName) {
|
|
598
|
+
this.recordPomAction(componentName, methodName, testIds);
|
|
599
|
+
const locators = testIds.map((testId) => this.locatorByTestId(testId, description));
|
|
600
|
+
if (!locators.length) {
|
|
601
|
+
throw new Error(`[pom] ${methodName} has no candidate test ids.`);
|
|
602
|
+
}
|
|
603
|
+
try {
|
|
604
|
+
await Promise.any(locators.map((locator) => locator.waitFor({ state: "visible", timeout: 5e3 })));
|
|
605
|
+
} catch (error) {
|
|
606
|
+
throw new Error(
|
|
607
|
+
`[pom] ${methodName} could not find a visible element for any generated test id: ${testIds.join(", ")}`,
|
|
608
|
+
{ cause: error }
|
|
609
|
+
);
|
|
610
|
+
}
|
|
611
|
+
for (const locator of locators) {
|
|
612
|
+
if (await locator.isVisible()) return locator;
|
|
613
|
+
}
|
|
614
|
+
return locators[0];
|
|
615
|
+
}
|
|
616
|
+
recordPomAction(componentName, methodName, expectedTestIds) {
|
|
617
|
+
setPomAction(this.page, { componentName, methodName, expectedTestIds });
|
|
618
|
+
}
|
|
619
|
+
locatorWithinTestIdByLabel(rootTestId, label, options) {
|
|
620
|
+
const locator = this.locatorByTestId(rootTestId).filter({ visible: true }).first().getByText(label, { exact: options?.exact ?? true });
|
|
621
|
+
return this.describeLocator(locator, options?.description);
|
|
622
|
+
}
|
|
623
|
+
/**
|
|
624
|
+
* Animates the pointer to an element.
|
|
625
|
+
*/
|
|
626
|
+
async animateCursorToElement(target, executeClick = true, delayMs = 1e3, annotationText = "", options) {
|
|
627
|
+
await this.pointer.animateCursorToElement(target, executeClick, delayMs, annotationText, options);
|
|
628
|
+
}
|
|
629
|
+
async showCallout(target, annotationText) {
|
|
630
|
+
await this.callout.showForElement(target, annotationText);
|
|
631
|
+
}
|
|
632
|
+
async showCalloutByTestId(testId, annotationText) {
|
|
633
|
+
await this.showCallout(this.selectorForTestId(testId), annotationText);
|
|
634
|
+
}
|
|
635
|
+
async hideCallout() {
|
|
636
|
+
await this.callout.hide();
|
|
637
|
+
}
|
|
638
|
+
/**
|
|
639
|
+
* Creates an indexable proxy for keyed elements so generated POMs can expose
|
|
640
|
+
* ergonomic accessors like:
|
|
641
|
+
* expect(page.SaveButton["MyKey"]).toBeVisible();
|
|
642
|
+
*/
|
|
643
|
+
keyedLocators(getLocator) {
|
|
644
|
+
const handler = {
|
|
645
|
+
get: (_t, prop) => {
|
|
646
|
+
if (prop === "then" || typeof prop === "symbol") {
|
|
647
|
+
return void 0;
|
|
648
|
+
}
|
|
649
|
+
return getLocator(String(prop));
|
|
650
|
+
}
|
|
651
|
+
};
|
|
652
|
+
return new Proxy({}, handler);
|
|
653
|
+
}
|
|
654
|
+
async getObjectId(options) {
|
|
655
|
+
const timeoutMs = options?.timeoutMs ?? 5e3;
|
|
656
|
+
const deadline = Date.now() + timeoutMs;
|
|
657
|
+
while (true) {
|
|
658
|
+
const url = this.page.url();
|
|
659
|
+
const match = url.match(/\/(\d+)(?:[/?#]|$)/);
|
|
660
|
+
if (match) {
|
|
661
|
+
return new ObjectId(match[1]);
|
|
662
|
+
}
|
|
663
|
+
if (Date.now() >= deadline) {
|
|
664
|
+
throw new Error(`getObjectId: could not find a numeric id in url '${url}' within ${timeoutMs}ms`);
|
|
665
|
+
}
|
|
666
|
+
await new Promise((resolve) => setTimeout(resolve, 50));
|
|
667
|
+
}
|
|
668
|
+
}
|
|
669
|
+
async getObjectIdAsInt(options) {
|
|
670
|
+
const objectId = await this.getObjectId(options);
|
|
671
|
+
return objectId.asInt();
|
|
672
|
+
}
|
|
673
|
+
/**
|
|
674
|
+
* Wraps an async factory for a page object into a chainable Fluent<T>.
|
|
675
|
+
*
|
|
676
|
+
* The returned proxy:
|
|
677
|
+
* - forwards method calls to the resolved object
|
|
678
|
+
* - queues async method calls (Promise-returning) so they execute in order
|
|
679
|
+
* - is PromiseLike, so `await` yields the underlying object
|
|
680
|
+
*/
|
|
681
|
+
fluent(factory) {
|
|
682
|
+
const rootPromise = factory();
|
|
683
|
+
const getRoot = () => rootPromise;
|
|
684
|
+
let queue = Promise.resolve();
|
|
685
|
+
let rootProxy;
|
|
686
|
+
const VALUE_RETURNING_METHODS = /* @__PURE__ */ new Set([
|
|
687
|
+
"getObjectId",
|
|
688
|
+
"getObjectIdAsInt"
|
|
689
|
+
]);
|
|
690
|
+
const getCtorName = (obj) => {
|
|
691
|
+
const o = obj;
|
|
692
|
+
return o.constructor?.name ?? "object";
|
|
693
|
+
};
|
|
694
|
+
const createValueProxy = (getValue) => {
|
|
695
|
+
const handler = {
|
|
696
|
+
get: (_t, prop) => {
|
|
697
|
+
if (prop === "then") {
|
|
698
|
+
return (onFulfilled, onRejected) => {
|
|
699
|
+
return queue.then(() => getValue()).then(onFulfilled, onRejected);
|
|
700
|
+
};
|
|
701
|
+
}
|
|
702
|
+
return createValueMemberProxy(getValue, prop);
|
|
703
|
+
}
|
|
704
|
+
};
|
|
705
|
+
const target = () => void 0;
|
|
706
|
+
return new Proxy(target, handler);
|
|
707
|
+
};
|
|
708
|
+
function createValueMemberProxy(getParent, member) {
|
|
709
|
+
const handler = {
|
|
710
|
+
get: (_t, prop) => {
|
|
711
|
+
if (prop === "then") {
|
|
712
|
+
return (onFulfilled, onRejected) => {
|
|
713
|
+
return queue.then(async () => {
|
|
714
|
+
const parent = await getParent();
|
|
715
|
+
const value = Reflect.get(parent, member);
|
|
716
|
+
if (value == null) {
|
|
717
|
+
throw new Error(`Fluent: '${String(member)}' does not exist on ${getCtorName(parent)}`);
|
|
718
|
+
}
|
|
719
|
+
return value;
|
|
720
|
+
}).then(onFulfilled, onRejected);
|
|
721
|
+
};
|
|
722
|
+
}
|
|
723
|
+
return createValueMemberProxy(async () => {
|
|
724
|
+
const parent = await getParent();
|
|
725
|
+
const value = Reflect.get(parent, member);
|
|
726
|
+
if (value == null) {
|
|
727
|
+
throw new Error(`Fluent: '${String(member)}' does not exist on ${getCtorName(parent)}`);
|
|
728
|
+
}
|
|
729
|
+
return value;
|
|
730
|
+
}, prop);
|
|
731
|
+
},
|
|
732
|
+
apply: (_t, _thisArg, args) => {
|
|
733
|
+
const resultPromise = new Promise((resolve, reject) => {
|
|
734
|
+
queue = queue.then(async () => {
|
|
735
|
+
const parent = await getParent();
|
|
736
|
+
const value = Reflect.get(parent, member);
|
|
737
|
+
if (typeof value !== "function") {
|
|
738
|
+
throw new TypeError(`Fluent: '${String(member)}' is not a function on ${getCtorName(parent)}`);
|
|
739
|
+
}
|
|
740
|
+
const fn = value;
|
|
741
|
+
const result = fn.apply(parent, args);
|
|
742
|
+
const resolved = result instanceof Promise ? await result : result;
|
|
743
|
+
resolve(resolved);
|
|
744
|
+
}).catch(reject);
|
|
745
|
+
});
|
|
746
|
+
return createValueProxy(() => resultPromise);
|
|
747
|
+
}
|
|
748
|
+
};
|
|
749
|
+
const target = () => void 0;
|
|
750
|
+
return new Proxy(target, handler);
|
|
751
|
+
}
|
|
752
|
+
const createMemberProxy = (getParent, member) => {
|
|
753
|
+
const handler = {
|
|
754
|
+
get: (_t, prop) => {
|
|
755
|
+
if (prop === "then") {
|
|
756
|
+
return (onFulfilled, onRejected) => {
|
|
757
|
+
return queue.then(async () => {
|
|
758
|
+
const parent = await getParent();
|
|
759
|
+
const value = Reflect.get(parent, member);
|
|
760
|
+
if (value == null) {
|
|
761
|
+
throw new Error(`Fluent: '${String(member)}' does not exist on ${parent.constructor?.name ?? "object"}`);
|
|
762
|
+
}
|
|
763
|
+
return value;
|
|
764
|
+
}).then(onFulfilled, onRejected);
|
|
765
|
+
};
|
|
766
|
+
}
|
|
767
|
+
return createMemberProxy(async () => {
|
|
768
|
+
const parent = await getParent();
|
|
769
|
+
const value = Reflect.get(parent, member);
|
|
770
|
+
if (value == null) {
|
|
771
|
+
throw new Error(`Fluent: '${String(member)}' does not exist on ${parent.constructor?.name ?? "object"}`);
|
|
772
|
+
}
|
|
773
|
+
return value;
|
|
774
|
+
}, prop);
|
|
775
|
+
},
|
|
776
|
+
apply: (_t, _thisArg, args) => {
|
|
777
|
+
const resultPromise = new Promise((resolve, reject) => {
|
|
778
|
+
queue = queue.then(async () => {
|
|
779
|
+
const parent = await getParent();
|
|
780
|
+
const value = Reflect.get(parent, member);
|
|
781
|
+
if (typeof value !== "function") {
|
|
782
|
+
throw new TypeError(`Fluent: '${String(member)}' is not a function on ${parent.constructor?.name ?? "object"}`);
|
|
783
|
+
}
|
|
784
|
+
const fn = value;
|
|
785
|
+
const result = fn.apply(parent, args);
|
|
786
|
+
const resolved = result instanceof Promise ? await result : result;
|
|
787
|
+
resolve(resolved);
|
|
788
|
+
}).catch(reject);
|
|
789
|
+
});
|
|
790
|
+
if (VALUE_RETURNING_METHODS.has(member)) {
|
|
791
|
+
return createValueProxy(() => resultPromise);
|
|
792
|
+
}
|
|
793
|
+
return rootProxy;
|
|
794
|
+
}
|
|
795
|
+
};
|
|
796
|
+
const target = () => void 0;
|
|
797
|
+
return new Proxy(target, handler);
|
|
798
|
+
};
|
|
799
|
+
const rootHandler = {
|
|
800
|
+
get: (_t, prop) => {
|
|
801
|
+
if (prop === "then") {
|
|
802
|
+
return (onFulfilled, onRejected) => {
|
|
803
|
+
return queue.then(() => getRoot()).then(onFulfilled, onRejected);
|
|
804
|
+
};
|
|
805
|
+
}
|
|
806
|
+
return createMemberProxy(getRoot, prop);
|
|
807
|
+
}
|
|
808
|
+
};
|
|
809
|
+
const rootTarget = {};
|
|
810
|
+
rootProxy = new Proxy(rootTarget, rootHandler);
|
|
811
|
+
return rootProxy;
|
|
812
|
+
}
|
|
813
|
+
/**
|
|
814
|
+
* Clicks on an element with the specified data-testid
|
|
815
|
+
* @param testId The data-testid of the element to click
|
|
816
|
+
*/
|
|
817
|
+
async clickByTestId(testId, annotationText = "", wait = true, description, action) {
|
|
818
|
+
this.recordPomAction(action?.componentName, action?.methodName ?? description ?? "clickByTestId", [testId]);
|
|
819
|
+
const locator = this.locatorByTestId(testId, description).filter({ visible: true }).first();
|
|
820
|
+
let clickTarget = locator;
|
|
821
|
+
let activateWithKeyboard = false;
|
|
822
|
+
if (action?.preferAssociatedLabel) {
|
|
823
|
+
const visibleControl = locator;
|
|
824
|
+
const controlId = await visibleControl.getAttribute("id");
|
|
825
|
+
if (controlId) {
|
|
826
|
+
const associatedLabel = this.page.locator(`label[for=${JSON.stringify(controlId)}]`).first();
|
|
827
|
+
if (await associatedLabel.count() > 0) {
|
|
828
|
+
if (await associatedLabel.isVisible()) {
|
|
829
|
+
clickTarget = associatedLabel;
|
|
830
|
+
} else {
|
|
831
|
+
activateWithKeyboard = true;
|
|
832
|
+
}
|
|
833
|
+
}
|
|
834
|
+
} else {
|
|
835
|
+
clickTarget = visibleControl;
|
|
836
|
+
}
|
|
837
|
+
}
|
|
838
|
+
const afterClick = this.getAfterPointerClick(wait);
|
|
839
|
+
if (activateWithKeyboard) {
|
|
840
|
+
await this.pointer.animateCursorToElement(locator, false, 200, annotationText);
|
|
841
|
+
await locator.press("Space");
|
|
842
|
+
if (afterClick) {
|
|
843
|
+
await afterClick({ testId, instrumented: true });
|
|
844
|
+
}
|
|
845
|
+
return;
|
|
846
|
+
}
|
|
847
|
+
await this.pointer.animateCursorToElement(clickTarget, true, 200, annotationText, afterClick ? { afterClick } : void 0);
|
|
848
|
+
}
|
|
849
|
+
async clickLocator(locator, annotationText = "", wait = true) {
|
|
850
|
+
const afterClick = this.getAfterPointerClick(wait);
|
|
851
|
+
await this.pointer.animateCursorToElement(locator, true, 200, annotationText, afterClick ? { afterClick } : void 0);
|
|
852
|
+
}
|
|
853
|
+
async clickWithinTestIdByLabel(rootTestId, label, annotationText = "", wait = true, options) {
|
|
854
|
+
this.recordPomAction(options?.componentName, options?.methodName ?? options?.description ?? "clickWithinTestIdByLabel", [rootTestId]);
|
|
855
|
+
const locator = this.locatorWithinTestIdByLabel(rootTestId, label, {
|
|
856
|
+
exact: options?.exact,
|
|
857
|
+
description: options?.description
|
|
858
|
+
});
|
|
859
|
+
await this.clickLocator(locator, annotationText, wait);
|
|
860
|
+
}
|
|
861
|
+
async fillInputByTestId(testId, text, annotationText = "", description, action) {
|
|
862
|
+
this.recordPomAction(action?.componentName, action?.methodName ?? description ?? "fillInputByTestId", [testId]);
|
|
863
|
+
const locator = this.locatorByTestId(testId, description).filter({ visible: true }).first();
|
|
864
|
+
const afterClick = this.getAfterPointerClick();
|
|
865
|
+
await this.pointer.animateCursorToElementAndClickAndFill(locator, text, true, 200, annotationText, afterClick ? { afterClick } : void 0);
|
|
866
|
+
}
|
|
867
|
+
/**
|
|
868
|
+
* Interacts with a vue-select control rooted by a data-testid.
|
|
869
|
+
* This is emitted frequently by the generator; keeping it here reduces per-page duplicated code.
|
|
870
|
+
*/
|
|
871
|
+
async selectVSelectByTestId(testId, value, annotationText = "", description, action) {
|
|
872
|
+
this.recordPomAction(action?.componentName, action?.methodName ?? description ?? "selectVSelectByTestId", [testId]);
|
|
873
|
+
const root = this.locatorByTestId(testId, description).filter({ visible: true }).first();
|
|
874
|
+
const input = root.locator("input");
|
|
875
|
+
await this.pointer.animateCursorToElement(input, false, 200, annotationText);
|
|
876
|
+
await input.click();
|
|
877
|
+
await this.pointer.animateCursorToElementAndClickAndFill(input, value, false, 200, annotationText);
|
|
878
|
+
const option = root.locator("ul.vs__dropdown-menu li[role='option']").first();
|
|
879
|
+
await option.waitFor({ state: "visible", timeout: 5e3 });
|
|
880
|
+
const afterClick = this.getAfterPointerClick();
|
|
881
|
+
await this.pointer.animateCursorToElement(option, true, 200, annotationText, afterClick ? { afterClick } : void 0);
|
|
882
|
+
}
|
|
883
|
+
async fillInputByLocator(locator, text, annotationText = "") {
|
|
884
|
+
const afterClick = this.getAfterPointerClick();
|
|
885
|
+
await this.pointer.animateCursorToElementAndClickAndFill(locator, text, true, 200, annotationText, afterClick ? { afterClick } : void 0);
|
|
886
|
+
}
|
|
887
|
+
async clickByAriaLabel(ariaLabel, annotationText = "") {
|
|
888
|
+
const afterClick = this.getAfterPointerClick();
|
|
889
|
+
await this.pointer.animateCursorToElement(`[aria-label="${ariaLabel}"]`, true, 200, annotationText, afterClick ? { afterClick } : void 0);
|
|
890
|
+
}
|
|
891
|
+
/**
|
|
892
|
+
* Types text into an element with the specified data-testid
|
|
893
|
+
* @param testId The data-testid of the element to type into
|
|
894
|
+
* @param text The text to type
|
|
895
|
+
*/
|
|
896
|
+
async typeByTestId(testId, text) {
|
|
897
|
+
await this.fillInputByTestId(testId, text);
|
|
898
|
+
}
|
|
899
|
+
/**
|
|
900
|
+
* Checks if an element with the specified data-testid is visible
|
|
901
|
+
* @param testId The data-testid of the element to check
|
|
902
|
+
* @returns True if the element is visible, false otherwise
|
|
903
|
+
*/
|
|
904
|
+
async isVisibleByTestId(testId) {
|
|
905
|
+
return this.locatorByTestId(testId).isVisible();
|
|
906
|
+
}
|
|
907
|
+
/**
|
|
908
|
+
* Gets the text content of an element with the specified data-testid
|
|
909
|
+
* @param testId The data-testid of the element to get text from
|
|
910
|
+
* @returns The text content of the element
|
|
911
|
+
*/
|
|
912
|
+
async getTextByTestId(testId) {
|
|
913
|
+
return this.locatorByTestId(testId).textContent();
|
|
914
|
+
}
|
|
915
|
+
/**
|
|
916
|
+
* Waits for an element with the specified data-testid to be visible
|
|
917
|
+
* @param testId The data-testid of the element to wait for
|
|
918
|
+
* @param options Optional timeout and other options
|
|
919
|
+
* @param options.timeout The maximum time to wait for the element to be visible (default is 5000ms)
|
|
920
|
+
* @returns A promise that resolves when the element is visible
|
|
921
|
+
*/
|
|
922
|
+
async waitForTestId(testId, options) {
|
|
923
|
+
await this.locatorByTestId(testId).waitFor({ state: "visible", timeout: options?.timeout ?? 5e3 });
|
|
924
|
+
}
|
|
925
|
+
/**
|
|
926
|
+
* Hovers over an element with the specified data-testid
|
|
927
|
+
* @param testId The data-testid of the element to hover over
|
|
928
|
+
*/
|
|
929
|
+
async hoverByTestId(testId) {
|
|
930
|
+
const locator = this.locatorByTestId(testId);
|
|
931
|
+
await this.pointer.animateCursorToElement(locator, false, 200, "");
|
|
932
|
+
await locator.hover();
|
|
933
|
+
}
|
|
934
|
+
/**
|
|
935
|
+
* Selects an option from a dropdown with the specified data-testid
|
|
936
|
+
* @param testId The data-testid of the dropdown
|
|
937
|
+
* @param value The value to select
|
|
938
|
+
*/
|
|
939
|
+
async selectByTestId(testId, value) {
|
|
940
|
+
await this.locatorByTestId(testId).selectOption(value);
|
|
941
|
+
}
|
|
942
|
+
}
|
|
943
|
+
exports.BasePage = BasePage;
|
|
944
|
+
exports.ObjectId = ObjectId;
|
|
945
|
+
//# sourceMappingURL=runtime.cjs.map
|