@rickcedwhat/playwright-smart-vision 0.1.0-next.3ca5c04

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 (69) hide show
  1. package/dist/configure.d.ts +30 -0
  2. package/dist/configure.d.ts.map +1 -0
  3. package/dist/configure.js +99 -0
  4. package/dist/configure.js.map +1 -0
  5. package/dist/devtools.d.ts +3 -0
  6. package/dist/devtools.d.ts.map +1 -0
  7. package/dist/devtools.js +235 -0
  8. package/dist/devtools.js.map +1 -0
  9. package/dist/element.d.ts +177 -0
  10. package/dist/element.d.ts.map +1 -0
  11. package/dist/element.js +433 -0
  12. package/dist/element.js.map +1 -0
  13. package/dist/element.test.d.ts +2 -0
  14. package/dist/element.test.d.ts.map +1 -0
  15. package/dist/element.test.js +207 -0
  16. package/dist/element.test.js.map +1 -0
  17. package/dist/field-extractor.d.ts +63 -0
  18. package/dist/field-extractor.d.ts.map +1 -0
  19. package/dist/field-extractor.js +438 -0
  20. package/dist/field-extractor.js.map +1 -0
  21. package/dist/index.d.ts +16 -0
  22. package/dist/index.d.ts.map +1 -0
  23. package/dist/index.js +9 -0
  24. package/dist/index.js.map +1 -0
  25. package/dist/ocr-overlay.d.ts +21 -0
  26. package/dist/ocr-overlay.d.ts.map +1 -0
  27. package/dist/ocr-overlay.js +102 -0
  28. package/dist/ocr-overlay.js.map +1 -0
  29. package/dist/ocr-step.d.ts +15 -0
  30. package/dist/ocr-step.d.ts.map +1 -0
  31. package/dist/ocr-step.js +41 -0
  32. package/dist/ocr-step.js.map +1 -0
  33. package/dist/ocr-test.d.ts +11 -0
  34. package/dist/ocr-test.d.ts.map +1 -0
  35. package/dist/ocr-test.js +39 -0
  36. package/dist/ocr-test.js.map +1 -0
  37. package/dist/playwright-helper.d.ts +64 -0
  38. package/dist/playwright-helper.d.ts.map +1 -0
  39. package/dist/playwright-helper.js +142 -0
  40. package/dist/playwright-helper.js.map +1 -0
  41. package/dist/screen-config.d.ts +91 -0
  42. package/dist/screen-config.d.ts.map +1 -0
  43. package/dist/screen-config.js +203 -0
  44. package/dist/screen-config.js.map +1 -0
  45. package/dist/screen-result.d.ts +103 -0
  46. package/dist/screen-result.d.ts.map +1 -0
  47. package/dist/screen-result.js +313 -0
  48. package/dist/screen-result.js.map +1 -0
  49. package/dist/typed-screen.d.ts +44 -0
  50. package/dist/typed-screen.d.ts.map +1 -0
  51. package/dist/typed-screen.js +72 -0
  52. package/dist/typed-screen.js.map +1 -0
  53. package/dist/types.d.ts +204 -0
  54. package/dist/types.d.ts.map +1 -0
  55. package/dist/types.js +19 -0
  56. package/dist/types.js.map +1 -0
  57. package/dist/utils/ocr.d.ts +52 -0
  58. package/dist/utils/ocr.d.ts.map +1 -0
  59. package/dist/utils/ocr.js +252 -0
  60. package/dist/utils/ocr.js.map +1 -0
  61. package/dist/utils/ocr.test.d.ts +2 -0
  62. package/dist/utils/ocr.test.d.ts.map +1 -0
  63. package/dist/utils/ocr.test.js +145 -0
  64. package/dist/utils/ocr.test.js.map +1 -0
  65. package/dist/utils/vision.d.ts +116 -0
  66. package/dist/utils/vision.d.ts.map +1 -0
  67. package/dist/utils/vision.js +340 -0
  68. package/dist/utils/vision.js.map +1 -0
  69. package/package.json +63 -0
@@ -0,0 +1,433 @@
1
+ import { ocrTextMatches, } from './utils/ocr.js';
2
+ import { ocrStep, expectTimeout } from './ocr-step.js';
3
+ export const VISIBLE_CONFIDENCE = 0.7;
4
+ function formatExpected(expected) {
5
+ return expected instanceof RegExp ? String(expected) : `"${expected}"`;
6
+ }
7
+ function formatSwaps(swaps) {
8
+ return Object.entries(swaps).map(([from, to]) => {
9
+ const allowed = (typeof to === 'string' ? [to] : [...to]).join('|');
10
+ return `${from}→${allowed}`;
11
+ }).join(', ');
12
+ }
13
+ function formatMatchNote(match) {
14
+ const bits = [];
15
+ if (match.swaps && Object.keys(match.swaps).length) {
16
+ bits.push(`allowed swaps: ${formatSwaps(match.swaps)}`);
17
+ }
18
+ if (match.overflow)
19
+ bits.push(`overflow: ${match.overflow}`);
20
+ if (match.read && match.read !== 'ocr')
21
+ bits.push(`read: ${match.read}`);
22
+ return bits.length ? ` (${bits.join('; ')})` : '';
23
+ }
24
+ /**
25
+ * Playwright-style element wrapper with chainable assertions
26
+ * Includes built-in retry logic similar to Playwright's auto-waiting
27
+ */
28
+ export class ScreenElement {
29
+ result;
30
+ page;
31
+ live;
32
+ parentName;
33
+ constructor(result, page, live, parentName) {
34
+ this.result = result;
35
+ this.page = page;
36
+ this.live = live;
37
+ this.parentName = parentName;
38
+ }
39
+ get label() {
40
+ return this.parentName ? `${this.parentName}.${this.result.name}` : this.result.name;
41
+ }
42
+ get rootName() {
43
+ return this.parentName ?? this.result.name;
44
+ }
45
+ get partName() {
46
+ return this.parentName ? this.result.name : undefined;
47
+ }
48
+ /**
49
+ * Get the element's current value
50
+ */
51
+ value() {
52
+ return this.result.value;
53
+ }
54
+ /**
55
+ * OCR for one inner box on a shared-label row.
56
+ */
57
+ part(name) {
58
+ const found = this.result.parts?.find((part) => part.name === name);
59
+ if (!found) {
60
+ const known = (this.result.parts || []).map((part) => part.name).join(', ') || 'none';
61
+ throw new Error(`Part "${name}" not found on element "${this.result.name}" (parts: ${known})`);
62
+ }
63
+ return new ScreenElement(found, this.page, this.live, this.parentName ?? this.result.name);
64
+ }
65
+ /**
66
+ * Get the element's location on screen
67
+ */
68
+ location() {
69
+ return this.result.location;
70
+ }
71
+ /**
72
+ * Get the element's match confidence
73
+ */
74
+ confidence() {
75
+ return this.result.confidence;
76
+ }
77
+ /**
78
+ * Get the element's type
79
+ */
80
+ type() {
81
+ return this.result.type;
82
+ }
83
+ /**
84
+ * Get the active variant (if element has variants)
85
+ */
86
+ variant() {
87
+ return this.result.variant;
88
+ }
89
+ /**
90
+ * Wait until this element's template matches the live screenshot.
91
+ */
92
+ async waitFor(options = {}) {
93
+ const visible = options.visible !== false;
94
+ return ocrStep(`element('${this.label}').waitFor({ visible: ${visible} })`, async () => {
95
+ await this.waitUntil(options);
96
+ await this.withOverlay();
97
+ });
98
+ }
99
+ /**
100
+ * Assert element is filled/has content
101
+ * @throws if element is empty after timeout
102
+ */
103
+ async toBeFilled(options) {
104
+ return ocrStep(`element('${this.label}').toBeFilled()`, async () => {
105
+ try {
106
+ await this.retryAssertion(() => this.result.isEmpty ? `Element "${this.label}" is not filled` : undefined, expectTimeout(options?.timeout));
107
+ }
108
+ finally {
109
+ await this.withOverlay();
110
+ }
111
+ });
112
+ }
113
+ /**
114
+ * Assert element is empty/has no content
115
+ * @throws if element is filled after timeout
116
+ */
117
+ async toBeEmpty(options) {
118
+ return ocrStep(`element('${this.label}').toBeEmpty()`, async () => {
119
+ try {
120
+ await this.retryAssertion(() => !this.result.isEmpty ? `Element "${this.label}" is not empty` : undefined, expectTimeout(options?.timeout));
121
+ }
122
+ finally {
123
+ await this.withOverlay();
124
+ }
125
+ });
126
+ }
127
+ /**
128
+ * Assert element is visible (found with confidence > threshold).
129
+ * When bound to a live page, waits until the template matches.
130
+ */
131
+ async toBeVisible(options) {
132
+ return ocrStep(`element('${this.label}').toBeVisible()`, async () => {
133
+ if (this.live && this.page) {
134
+ await this.waitUntil(options?.timeout !== undefined
135
+ ? { visible: true, timeout: options.timeout }
136
+ : { visible: true });
137
+ }
138
+ this.syncResult();
139
+ await this.withOverlay();
140
+ if (!this.result.confidence || this.result.confidence < VISIBLE_CONFIDENCE) {
141
+ throw new Error(`Element "${this.label}" is not visible (confidence: ${this.result.confidence})`);
142
+ }
143
+ });
144
+ }
145
+ /**
146
+ * Assert element has specific text/value
147
+ * @throws if text doesn't match after timeout
148
+ */
149
+ async toHaveText(expected, options) {
150
+ return ocrStep(`element('${this.label}').toHaveText(${formatExpected(expected)})`, async () => {
151
+ const match = this.resolvedMatch(options);
152
+ const matchOpts = {
153
+ ...(match.swaps !== undefined && { swaps: match.swaps }),
154
+ ...(match.overflow !== undefined && { overflow: match.overflow }),
155
+ ...(options?.overflowSlop !== undefined && { overflowSlop: options.overflowSlop }),
156
+ };
157
+ if (match.read === 'clipboard') {
158
+ await this.ensureLocated(options?.timeout);
159
+ const actual = await this.copyFromField();
160
+ try {
161
+ if (!ocrTextMatches(actual, expected, matchOpts)) {
162
+ throw new Error(`Element "${this.label}" does not have text ${formatExpected(expected)}${formatMatchNote(match)}. Actual: "${actual}"`);
163
+ }
164
+ }
165
+ finally {
166
+ await this.withOverlay();
167
+ }
168
+ return;
169
+ }
170
+ try {
171
+ await this.retryAssertion(() => {
172
+ const actual = this.result.value;
173
+ return ocrTextMatches(actual, expected, matchOpts)
174
+ ? undefined
175
+ : `Element "${this.label}" does not have text ${formatExpected(expected)}${formatMatchNote(match)}. Actual: "${actual}"`;
176
+ }, expectTimeout(options?.timeout));
177
+ }
178
+ finally {
179
+ await this.withOverlay();
180
+ }
181
+ });
182
+ }
183
+ /**
184
+ * Assert element has exact text/value
185
+ * @throws if text doesn't match exactly after timeout
186
+ */
187
+ async toHaveValue(expected, options) {
188
+ return ocrStep(`element('${this.label}').toHaveValue(${formatExpected(expected)})`, async () => {
189
+ const match = this.resolvedMatch(options);
190
+ const matchOpts = {
191
+ ...(match.swaps !== undefined && { swaps: match.swaps }),
192
+ ...(match.overflow !== undefined && { overflow: match.overflow }),
193
+ ...(options?.overflowSlop !== undefined && { overflowSlop: options.overflowSlop }),
194
+ exact: !match.overflow,
195
+ };
196
+ if (match.read === 'clipboard') {
197
+ await this.ensureLocated(options?.timeout);
198
+ const actual = await this.copyFromField();
199
+ try {
200
+ if (!ocrTextMatches(actual, expected, matchOpts)) {
201
+ throw new Error(`Element "${this.label}" does not have value "${expected}"${formatMatchNote(match)}. Actual: "${actual}"`);
202
+ }
203
+ }
204
+ finally {
205
+ await this.withOverlay();
206
+ }
207
+ return;
208
+ }
209
+ try {
210
+ await this.retryAssertion(() => {
211
+ const actual = this.result.value;
212
+ return ocrTextMatches(actual, expected, matchOpts)
213
+ ? undefined
214
+ : `Element "${this.label}" does not have value "${expected}"${formatMatchNote(match)}. Actual: "${actual}"`;
215
+ }, expectTimeout(options?.timeout));
216
+ }
217
+ finally {
218
+ await this.withOverlay();
219
+ }
220
+ });
221
+ }
222
+ /**
223
+ * Assert checkbox/toggle is checked
224
+ * @throws if not checked after timeout
225
+ */
226
+ async toBeChecked(options) {
227
+ return ocrStep(`element('${this.label}').toBeChecked()`, async () => {
228
+ try {
229
+ await this.retryAssertion(() => this.result.value !== 'checked' ? `Element "${this.label}" is not checked` : undefined, expectTimeout(options?.timeout));
230
+ }
231
+ finally {
232
+ await this.withOverlay();
233
+ }
234
+ });
235
+ }
236
+ /**
237
+ * Assert checkbox/toggle is unchecked
238
+ * @throws if checked after timeout
239
+ */
240
+ async toBeUnchecked(options) {
241
+ return ocrStep(`element('${this.label}').toBeUnchecked()`, async () => {
242
+ try {
243
+ await this.retryAssertion(() => this.result.value !== 'unchecked' ? `Element "${this.label}" is not unchecked` : undefined, expectTimeout(options?.timeout));
244
+ }
245
+ finally {
246
+ await this.withOverlay();
247
+ }
248
+ });
249
+ }
250
+ /**
251
+ * Assert element is in specific variant state
252
+ * @throws if variant doesn't match after timeout
253
+ */
254
+ async toHaveVariant(expected, options) {
255
+ return ocrStep(`element('${this.label}').toHaveVariant(${JSON.stringify(expected)})`, async () => {
256
+ try {
257
+ await this.retryAssertion(() => {
258
+ const actual = this.result.variant;
259
+ return actual !== expected
260
+ ? `Element "${this.label}" does not have variant "${expected}". Actual: "${actual || 'none'}"`
261
+ : undefined;
262
+ }, expectTimeout(options?.timeout));
263
+ }
264
+ finally {
265
+ await this.withOverlay();
266
+ }
267
+ });
268
+ }
269
+ /**
270
+ * Assert element matches with high confidence
271
+ * @throws if confidence below threshold after timeout
272
+ */
273
+ async toHaveConfidence(threshold, options) {
274
+ return ocrStep(`element('${this.label}').toHaveConfidence(${threshold})`, async () => {
275
+ try {
276
+ await this.retryAssertion(() => {
277
+ const conf = this.result.confidence;
278
+ return !conf || conf < threshold
279
+ ? `Element "${this.label}" confidence ${conf} is below ${threshold}`
280
+ : undefined;
281
+ }, expectTimeout(options?.timeout));
282
+ }
283
+ finally {
284
+ await this.withOverlay();
285
+ }
286
+ });
287
+ }
288
+ /**
289
+ * Click the element at its center
290
+ * Requires page to be provided
291
+ */
292
+ async click(options) {
293
+ return ocrStep(`element('${this.label}').click()`, async () => {
294
+ await this.ensureLocated(options?.timeout);
295
+ await this.withOverlay(async () => {
296
+ await this.clickRect(this.result.ocrLocation ?? this.result.location);
297
+ this.live?.markDirty();
298
+ });
299
+ });
300
+ }
301
+ /**
302
+ * Type text into the element.
303
+ * Clicks the value box (ocrRect), not the label crop, then types.
304
+ * Requires page to be provided
305
+ */
306
+ async fill(text, options) {
307
+ return ocrStep(`element('${this.label}').fill(${JSON.stringify(text)})`, async () => {
308
+ await this.ensureLocated(options?.timeout);
309
+ await this.withOverlay(async () => {
310
+ await this.clickRect(this.result.ocrLocation ?? this.result.location);
311
+ await this.page.keyboard.press('ControlOrMeta+A');
312
+ await this.page.keyboard.press('Backspace');
313
+ await this.page.keyboard.insertText(text);
314
+ this.live?.markDirty();
315
+ });
316
+ });
317
+ }
318
+ async clickRect(rect) {
319
+ if (!this.page) {
320
+ throw new Error('Page not provided. Cannot click element.');
321
+ }
322
+ await this.page.mouse.click(rect.x + rect.width / 2, rect.y + rect.height / 2);
323
+ }
324
+ /**
325
+ * Get custom metadata from custom matcher
326
+ * Returns undefined if no metadata available
327
+ */
328
+ metadata() {
329
+ return this.result.metadata;
330
+ }
331
+ /**
332
+ * Get a specific metadata value
333
+ */
334
+ getMetadata(key) {
335
+ return this.result.metadata?.[key];
336
+ }
337
+ /**
338
+ * Get element info for debugging
339
+ */
340
+ info() {
341
+ return { ...this.result };
342
+ }
343
+ syncResult() {
344
+ if (!this.live)
345
+ return;
346
+ const latest = this.live.elementResult(this.rootName, this.partName);
347
+ if (latest)
348
+ this.result = latest;
349
+ }
350
+ async highlight() {
351
+ await this.live?.paintOverlay(this.result, this.label);
352
+ }
353
+ async withOverlay(body) {
354
+ try {
355
+ await this.highlight();
356
+ if (body)
357
+ return await body();
358
+ }
359
+ finally {
360
+ await this.live?.hideOverlay();
361
+ }
362
+ }
363
+ isLocated() {
364
+ this.syncResult();
365
+ return this.result.location.width > 0 && (this.result.confidence ?? 0) >= VISIBLE_CONFIDENCE;
366
+ }
367
+ async ensureLocated(timeout) {
368
+ if (this.isLocated())
369
+ return;
370
+ await this.waitUntil(timeout !== undefined ? { visible: true, timeout } : { visible: true });
371
+ }
372
+ async waitUntil(options = {}) {
373
+ if (!this.live) {
374
+ throw new Error(`element('${this.label}').waitFor() requires ScreenResult.bind(page, extractor, screen, shotDir)`);
375
+ }
376
+ await this.live.waitForElement(this.rootName, options);
377
+ this.syncResult();
378
+ }
379
+ resolvedMatch(options) {
380
+ const fromConfig = this.live?.matchOptions(this.rootName, this.partName) ?? {};
381
+ const match = {};
382
+ const swaps = options?.swaps ?? fromConfig.swaps;
383
+ const overflow = options?.overflow ?? fromConfig.overflow;
384
+ const read = options?.read ?? fromConfig.read;
385
+ if (swaps)
386
+ match.swaps = swaps;
387
+ if (overflow)
388
+ match.overflow = overflow;
389
+ if (read)
390
+ match.read = read;
391
+ return match;
392
+ }
393
+ /**
394
+ * Retry a synchronous assertion check until it passes or the deadline is reached.
395
+ * `check` returns an error message string on failure, or undefined on success.
396
+ * When timeout is 0 or there is no live screen, the check runs exactly once.
397
+ */
398
+ async retryAssertion(check, timeout) {
399
+ await this.live?.ensureFresh();
400
+ this.syncResult();
401
+ const first = check();
402
+ if (first === undefined)
403
+ return;
404
+ const live = this.live;
405
+ if (!live || timeout === 0)
406
+ throw new Error(first);
407
+ const deadline = Date.now() + timeout;
408
+ let lastErr = first;
409
+ while (Date.now() < deadline) {
410
+ live.markDirty();
411
+ await new Promise((r) => setTimeout(r, 150));
412
+ await live.ensureFresh();
413
+ this.syncResult();
414
+ const next = check();
415
+ if (next === undefined)
416
+ return;
417
+ lastErr = next;
418
+ }
419
+ throw new Error(lastErr);
420
+ }
421
+ async copyFromField() {
422
+ if (!this.page) {
423
+ throw new Error(`element('${this.label}') clipboard read requires a page`);
424
+ }
425
+ await this.page.context().grantPermissions(['clipboard-read', 'clipboard-write']);
426
+ await this.highlight();
427
+ await this.clickRect(this.result.ocrLocation ?? this.result.location);
428
+ await this.page.keyboard.press('ControlOrMeta+A');
429
+ await this.page.keyboard.press('ControlOrMeta+C');
430
+ return this.page.evaluate(() => navigator.clipboard.readText());
431
+ }
432
+ }
433
+ //# sourceMappingURL=element.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"element.js","sourceRoot":"","sources":["../src/element.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,cAAc,GAIf,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAEvD,MAAM,CAAC,MAAM,kBAAkB,GAAG,GAAG,CAAC;AAkCtC,SAAS,cAAc,CAAC,QAAyB;IAC/C,OAAO,QAAQ,YAAY,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI,QAAQ,GAAG,CAAC;AACzE,CAAC;AAED,SAAS,WAAW,CAAC,KAAe;IAClC,OAAO,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,EAAE,EAAE;QAC9C,MAAM,OAAO,GAAG,CAAC,OAAO,EAAE,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACpE,OAAO,GAAG,IAAI,IAAI,OAAO,EAAE,CAAC;IAC9B,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAChB,CAAC;AAED,SAAS,eAAe,CAAC,KAAmB;IAC1C,MAAM,IAAI,GAAa,EAAE,CAAC;IAC1B,IAAI,KAAK,CAAC,KAAK,I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EAAE,CAAC;YAClB,MAAM,IAAI,GAAG,KAAK,EAAE,CAAC;YACrB,IAAI,IAAI,KAAK,SAAS;gBAAE,OAAO;YAC/B,OAAO,GAAG,IAAI,CAAC;QACjB,CAAC;QACD,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC;IAC3B,CAAC;IAEO,KAAK,CAAC,aAAa;QACzB,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;YACf,MAAM,IAAI,KAAK,CAAC,YAAY,IAAI,CAAC,KAAK,mCAAmC,CAAC,CAAC;QAC7E,CAAC;QACD,MAAM,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,gBAAgB,CAAC,CAAC,gBAAgB,EAAE,iBAAiB,CAAC,CAAC,CAAC;QAClF,MAAM,IAAI,CAAC,SAAS,EAAE,CAAC;QACvB,MAAM,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,WAAW,IAAI,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QACtE,MAAM,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC;QAClD,MAAM,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC;QAClD,OAAO,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,SAAS,CAAC,QAAQ,EAAE,CAAC,CAAC;IAClE,CAAC;CACF"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=element.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"element.test.d.ts","sourceRoot":"","sources":["../src/element.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,207 @@
1
+ import { describe, it, expect, vi, afterEach } from 'vitest';
2
+ import { ScreenElement } from './element.js';
3
+ import { expectTimeout } from './ocr-step.js';
4
+ // ---------------------------------------------------------------------------
5
+ // Helpers
6
+ // ---------------------------------------------------------------------------
7
+ const zeroRect = { x: 0, y: 0, width: 0, height: 0 };
8
+ /**
9
+ * A mock LiveScreen whose elementResult cycles through `sequence` on each
10
+ * ensureFresh() call. The last entry is held once the sequence is exhausted.
11
+ */
12
+ function makeLiveScreen(sequence) {
13
+ let callCount = 0;
14
+ return {
15
+ async ensureFresh() { callCount++; },
16
+ elementResult(name) {
17
+ const idx = Math.min(Math.max(callCount - 1, 0), sequence.length - 1);
18
+ return { name, value: '', location: zeroRect, isEmpty: true, ...sequence[idx] };
19
+ },
20
+ matchOptions(_name, _part) { return {}; },
21
+ markDirty() { },
22
+ async waitForElement(_name, _opts) { },
23
+ async paintOverlay() { },
24
+ async hideOverlay() { },
25
+ };
26
+ }
27
+ function makeElement(result, live) {
28
+ const full = { name: 'field', value: '', location: zeroRect, isEmpty: true, ...result };
29
+ return new ScreenElement(full, undefined, live);
30
+ }
31
+ // ---------------------------------------------------------------------------
32
+ // expectTimeout
33
+ // ---------------------------------------------------------------------------
34
+ describe('expectTimeout', () => {
35
+ it('returns the provided override unchanged', () => {
36
+ expect(expectTimeout(0)).toBe(0);
37
+ expect(expectTimeout(3_000)).toBe(3_000);
38
+ expect(expectTimeout(10_000)).toBe(10_000);
39
+ });
40
+ it('returns 0 outside a Playwright test (test.info() throws)', () => {
41
+ // In Vitest, Playwright's test.info() throws — expectTimeout() should catch that.
42
+ expect(expectTimeout()).toBe(0);
43
+ });
44
+ });
45
+ // ---------------------------------------------------------------------------
46
+ // retryAssertion — tested through toBeFilled / toBeEmpty / toHaveVariant
47
+ // ---------------------------------------------------------------------------
48
+ describe('retryAssertion — no live screen (single-shot always)', () => {
49
+ it('passes immediately when condition holds', async () => {
50
+ const el = makeElement({ isEmpty: false });
51
+ await expect(el.toBeFilled()).resolves.toBeUndefined();
52
+ });
53
+ it('throws immediately when condition does not hold', async () => {
54
+ const el = makeElement({ isEmpty: true });
55
+ await expect(el.toBeFilled()).rejects.toThrow(/is not filled/);
56
+ });
57
+ it('does not retry even when a non-zero timeout is passed', async () => {
58
+ // Without a LiveScreen, retryAssertion short-circuits after the first check.
59
+ const el = makeElement({ isEmpty: true });
60
+ await expect(el.toBeFilled({ timeout: 5_000 })).rejects.toThrow(/is not filled/);
61
+ });
62
+ });
63
+ describe('retryAssertion — timeout: 0 (explicit single-shot)', () => {
64
+ it('asserts once and passes', async () => {
65
+ const live = makeLiveScreen([{ isEmpty: false }]);
66
+ const el = makeElement({ isEmpty: true }, live);
67
+ await expect(el.toBeFilled({ timeout: 0 })).resolves.toBeUndefined();
68
+ });
69
+ it('asserts once and throws — ensureFresh called exactly once', async () => {
70
+ const live = makeLiveScreen([{ isEmpty: true }]);
71
+ const spy = vi.spyOn(live, 'ensureFresh');
72
+ const el = makeElement({ isEmpty: true }, live);
73
+ await expect(el.toBeFilled({ timeout: 0 })).rejects.toThrow(/is not filled/);
74
+ expect(spy).toHaveBeenCalledTimes(1);
75
+ });
76
+ });
77
+ describe('retryAssertion — live screen, passes on retry', () => {
78
+ afterEach(() => vi.useRealTimers());
79
+ it('toBeFilled: retries until the element becomes filled', async () => {
80
+ vi.useFakeTimers();
81
+ const live = makeLiveScreen([
82
+ { isEmpty: true }, // first check: fails
83
+ { isEmpty: false }, // after retry: passes
84
+ ]);
85
+ const el = makeElement({ isEmpty: true }, live);
86
+ const p = el.toBeFilled({ timeout: 1_000 });
87
+ await vi.runAllTimersAsync();
88
+ await expect(p).resolves.toBeUndefined();
89
+ });
90
+ it('toBeEmpty: retries until the element becomes empty', async () => {
91
+ vi.useFakeTimers();
92
+ const live = makeLiveScreen([
93
+ { isEmpty: false }, // first check: fails
94
+ { isEmpty: true }, // after retry: passes
95
+ ]);
96
+ const el = makeElement({ isEmpty: false }, live);
97
+ const p = el.toBeEmpty({ timeout: 1_000 });
98
+ await vi.runAllTimersAsync();
99
+ await expect(p).resolves.toBeUndefined();
100
+ });
101
+ it('toHaveVariant: retries until the variant matches', async () => {
102
+ vi.useFakeTimers();
103
+ const live = makeLiveScreen([
104
+ { variant: 'enabled' }, // first check: wrong variant
105
+ { variant: 'disabled' }, // after retry: matches
106
+ ]);
107
+ const el = makeElement({ variant: 'enabled' }, live);
108
+ const p = el.toHaveVariant('disabled', { timeout: 1_000 });
109
+ await vi.runAllTimersAsync();
110
+ await expect(p).resolves.toBeUndefined();
111
+ });
112
+ it('toBeChecked: retries until the checkbox becomes checked', async () => {
113
+ vi.useFakeTimers();
114
+ const live = makeLiveScreen([
115
+ { value: 'unchecked' },
116
+ { value: 'checked' },
117
+ ]);
118
+ const el = makeElement({ value: 'unchecked' }, live);
119
+ const p = el.toBeChecked({ timeout: 1_000 });
120
+ await vi.runAllTimersAsync();
121
+ await expect(p).resolves.toBeUndefined();
122
+ });
123
+ });
124
+ describe('retryAssertion — live screen, times out', () => {
125
+ afterEach(() => vi.useRealTimers());
126
+ it('throws the last error message after timeout', async () => {
127
+ vi.useFakeTimers();
128
+ const live = makeLiveScreen([{ isEmpty: true }]); // never fills
129
+ const el = makeElement({ isEmpty: true }, live);
130
+ const rejection = el.toBeFilled({ timeout: 300 });
131
+ // Attach .catch() before advancing timers to prevent unhandled-rejection warning.
132
+ const caught = rejection.catch((e) => e);
133
+ await vi.runAllTimersAsync();
134
+ const err = await caught;
135
+ expect(err).toBeInstanceOf(Error);
136
+ expect(err.message).toMatch(/is not filled/);
137
+ });
138
+ it('throws with the correct variant in the error message', async () => {
139
+ vi.useFakeTimers();
140
+ const live = makeLiveScreen([{ variant: 'enabled' }]);
141
+ const el = makeElement({ variant: 'enabled' }, live);
142
+ const rejection = el.toHaveVariant('disabled', { timeout: 300 });
143
+ const caught = rejection.catch((e) => e);
144
+ await vi.runAllTimersAsync();
145
+ const err = await caught;
146
+ expect(err).toBeInstanceOf(Error);
147
+ expect(err.message).toMatch(/disabled/);
148
+ expect(err.message).toMatch(/enabled/);
149
+ });
150
+ });
151
+ // ---------------------------------------------------------------------------
152
+ // toHaveText / toHaveValue — assertion logic (no retry; timeout implicitly 0 outside test)
153
+ // ---------------------------------------------------------------------------
154
+ describe('toHaveText', () => {
155
+ it('passes when actual contains expected substring', async () => {
156
+ const el = makeElement({ value: 'HELLO WORLD' });
157
+ await expect(el.toHaveText('HELLO')).resolves.toBeUndefined();
158
+ });
159
+ it('passes for a matching RegExp', async () => {
160
+ const el = makeElement({ value: 'ABC123' });
161
+ await expect(el.toHaveText(/^\w+\d+$/)).resolves.toBeUndefined();
162
+ });
163
+ it('throws when actual does not match', async () => {
164
+ const el = makeElement({ value: 'WORLD' });
165
+ await expect(el.toHaveText('HELLO')).rejects.toThrow(/does not have text/);
166
+ });
167
+ it('passes with a swap substitution', async () => {
168
+ const el = makeElement({ value: 'USER Q EXAMPLE.COM' });
169
+ await expect(el.toHaveText('USER @ EXAMPLE.COM', { swaps: { '@': 'Q' } })).resolves.toBeUndefined();
170
+ });
171
+ });
172
+ describe('toHaveValue', () => {
173
+ it('passes on exact match', async () => {
174
+ const el = makeElement({ value: '760 543 2987' });
175
+ await expect(el.toHaveValue('760 543 2987')).resolves.toBeUndefined();
176
+ });
177
+ it('throws when actual differs', async () => {
178
+ const el = makeElement({ value: '760 543 2987' });
179
+ await expect(el.toHaveValue('555 555 5555')).rejects.toThrow(/does not have value/);
180
+ });
181
+ it('throws when actual is only a substring of expected (exact by default)', async () => {
182
+ const el = makeElement({ value: '760' });
183
+ await expect(el.toHaveValue('760 543 2987')).rejects.toThrow(/does not have value/);
184
+ });
185
+ });
186
+ // ---------------------------------------------------------------------------
187
+ // toBeChecked / toBeUnchecked — state assertions
188
+ // ---------------------------------------------------------------------------
189
+ describe('toBeChecked / toBeUnchecked', () => {
190
+ it('toBeChecked passes when value is "checked"', async () => {
191
+ const el = makeElement({ value: 'checked' });
192
+ await expect(el.toBeChecked()).resolves.toBeUndefined();
193
+ });
194
+ it('toBeChecked throws when value is "unchecked"', async () => {
195
+ const el = makeElement({ value: 'unchecked' });
196
+ await expect(el.toBeChecked()).rejects.toThrow(/is not checked/);
197
+ });
198
+ it('toBeUnchecked passes when value is "unchecked"', async () => {
199
+ const el = makeElement({ value: 'unchecked' });
200
+ await expect(el.toBeUnchecked()).resolves.toBeUndefined();
201
+ });
202
+ it('toBeUnchecked throws when value is "checked"', async () => {
203
+ const el = makeElement({ value: 'checked' });
204
+ await expect(el.toBeUnchecked()).rejects.toThrow(/is not unchecked/);
205
+ });
206
+ });
207
+ //# sourceMappingURL=element.test.js.map