@harnessed-ts/cypress 0.0.0-stage → 0.7.0

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.cjs ADDED
@@ -0,0 +1,535 @@
1
+ 'use strict';
2
+
3
+ var core = require('@harnessed-ts/core');
4
+ var resolve = require('@harnessed-ts/resolve');
5
+ var dom = require('@testing-library/dom');
6
+ var userEvent = require('@testing-library/user-event');
7
+
8
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
9
+
10
+ var userEvent__default = /*#__PURE__*/_interopDefault(userEvent);
11
+
12
+ // src/driver-id.ts
13
+ var CYPRESS_DRIVER = "cypress";
14
+
15
+ // src/real-events.ts
16
+ var NAMED_KEYS = {
17
+ Enter: { code: "Enter", keyCode: 13, text: "\r" },
18
+ Tab: { code: "Tab", keyCode: 9 },
19
+ Backspace: { code: "Backspace", keyCode: 8 },
20
+ Delete: { code: "Delete", keyCode: 46 },
21
+ Escape: { code: "Escape", keyCode: 27 },
22
+ Space: { code: "Space", keyCode: 32, text: " " },
23
+ ArrowUp: { code: "ArrowUp", keyCode: 38 },
24
+ ArrowDown: { code: "ArrowDown", keyCode: 40 },
25
+ ArrowLeft: { code: "ArrowLeft", keyCode: 37 },
26
+ ArrowRight: { code: "ArrowRight", keyCode: 39 },
27
+ Home: { code: "Home", keyCode: 36 },
28
+ End: { code: "End", keyCode: 35 },
29
+ PageUp: { code: "PageUp", keyCode: 33 },
30
+ PageDown: { code: "PageDown", keyCode: 34 },
31
+ Insert: { code: "Insert", keyCode: 45 }
32
+ };
33
+ function keyDefinition(key) {
34
+ const named = NAMED_KEYS[key];
35
+ if (named !== void 0) return { key: key === "Space" ? " " : key, ...named };
36
+ if ([...key].length === 1) {
37
+ const upper = key.toUpperCase();
38
+ const code = /[A-Z]/.test(upper) ? `Key${upper}` : /[0-9]/.test(key) ? `Digit${key}` : "";
39
+ const keyCode = /[A-Z0-9]/.test(upper) ? upper.charCodeAt(0) : 0;
40
+ return { key, code, keyCode, text: key };
41
+ }
42
+ throw new Error(
43
+ `harnessed: realEvents cannot press "${key}". It presses single characters and ${Object.keys(NAMED_KEYS).join(", ")}; drop realEvents to press it through user-event.`
44
+ );
45
+ }
46
+ function send(command, params) {
47
+ return Promise.resolve(Cypress.automation("remote:debugger:protocol", { command, params }));
48
+ }
49
+ function requireChromium() {
50
+ if (!Cypress.isBrowser({ family: "chromium" })) {
51
+ throw new Error(
52
+ `harnessed: realEvents drives Chrome DevTools Protocol input, which only Chromium-family browsers (Chrome, Edge, Electron) have; this run is in ${Cypress.browser.name}. Leave realEvents off to use user-event there.`
53
+ );
54
+ }
55
+ }
56
+ function framesDownTo(target, within) {
57
+ for (const frame of within.querySelectorAll("iframe")) {
58
+ if (frame.contentWindow === target) return [frame];
59
+ const inner = frame.contentDocument;
60
+ const path = inner === null ? null : framesDownTo(target, inner);
61
+ if (path !== null) return [frame, ...path];
62
+ }
63
+ return null;
64
+ }
65
+ function centreOf(element) {
66
+ element.scrollIntoView({ block: "center", inline: "center" });
67
+ const box = element.getBoundingClientRect();
68
+ let x = box.left + box.width / 2;
69
+ let y = box.top + box.height / 2;
70
+ const view = element.ownerDocument.defaultView;
71
+ const top = window.top ?? window;
72
+ const frames = view === null || view === top ? [] : framesDownTo(view, top.document) ?? [];
73
+ for (const frame of frames.reverse()) {
74
+ const frameBox = frame.getBoundingClientRect();
75
+ const scale = frame.offsetWidth > 0 ? frameBox.width / frame.offsetWidth : 1;
76
+ const style = frame.ownerDocument.defaultView?.getComputedStyle(frame);
77
+ const insetX = frame.clientLeft + parseFloat(style?.paddingLeft ?? "0");
78
+ const insetY = frame.clientTop + parseFloat(style?.paddingTop ?? "0");
79
+ x = frameBox.left + (insetX + x) * scale;
80
+ y = frameBox.top + (insetY + y) * scale;
81
+ }
82
+ return { x, y };
83
+ }
84
+ async function realHover(element) {
85
+ const { x, y } = centreOf(element);
86
+ await send("Input.dispatchMouseEvent", { type: "mouseMoved", x, y });
87
+ }
88
+ async function realClick(element) {
89
+ const { x, y } = centreOf(element);
90
+ await send("Input.dispatchMouseEvent", { type: "mouseMoved", x, y });
91
+ const press = { x, y, button: "left", clickCount: 1 };
92
+ await send("Input.dispatchMouseEvent", { type: "mousePressed", buttons: 1, ...press });
93
+ await send("Input.dispatchMouseEvent", { type: "mouseReleased", buttons: 0, ...press });
94
+ }
95
+ async function realPress(key) {
96
+ const { text, keyCode, ...definition } = keyDefinition(key);
97
+ const common = { ...definition, windowsVirtualKeyCode: keyCode, nativeVirtualKeyCode: keyCode };
98
+ await send(
99
+ "Input.dispatchKeyEvent",
100
+ text === void 0 ? { type: "rawKeyDown", ...common } : { type: "keyDown", text, unmodifiedText: text, ...common }
101
+ );
102
+ await send("Input.dispatchKeyEvent", { type: "keyUp", ...common });
103
+ }
104
+ async function realInsertText(text) {
105
+ await send("Input.insertText", { text });
106
+ }
107
+
108
+ // src/cypress-query.ts
109
+ function toKeyboardInput(key) {
110
+ return key.length === 1 ? key : `{${key}}`;
111
+ }
112
+ var users = /* @__PURE__ */ new WeakMap();
113
+ function userFor(env) {
114
+ const { document } = env;
115
+ const bound = users.get(env);
116
+ if (bound !== void 0 && bound.document === document) return bound.user;
117
+ const user = userEvent__default.default.setup({ document });
118
+ users.set(env, { document, user });
119
+ return user;
120
+ }
121
+ async function waitUntil(condition, container, timeout) {
122
+ let refused;
123
+ await dom.waitFor(
124
+ async () => {
125
+ try {
126
+ await condition();
127
+ } catch (error) {
128
+ if (!(error instanceof resolve.FrameEntryError || error instanceof core.StrictModeViolation)) {
129
+ throw error;
130
+ }
131
+ refused = error;
132
+ }
133
+ },
134
+ // The default container is the spec frame's document, which never changes;
135
+ // watching the AUT's is what lets a mutation end the wait early.
136
+ { container, timeout }
137
+ );
138
+ if (refused !== void 0) throw refused;
139
+ }
140
+ var CypressQuery = class _CypressQuery extends core.Query {
141
+ constructor(env, scope, selector) {
142
+ super(scope, selector);
143
+ this.env = env;
144
+ }
145
+ env;
146
+ clone(selector) {
147
+ return new _CypressQuery(this.env, this.scope, selector);
148
+ }
149
+ /** Read per query: navigation replaces the document, and with it the body. */
150
+ get container() {
151
+ const { document } = this.env;
152
+ return document.body ?? document.documentElement;
153
+ }
154
+ element(options) {
155
+ return resolve.resolveOne(this.container, this.scope, this.selector, options?.timeout);
156
+ }
157
+ /** Keeps the command log telling the story: one entry per harness action. */
158
+ log(action, detail) {
159
+ if (!this.env.log) return;
160
+ const target = core.describeScope(this.scope, this.selector);
161
+ Cypress.log({
162
+ name: "harness",
163
+ message: `**${action}** ${target}${detail === void 0 ? "" : ` ${detail}`}`,
164
+ consoleProps: () => ({ action, target, detail })
165
+ });
166
+ }
167
+ get user() {
168
+ return userFor(this.env);
169
+ }
170
+ get real() {
171
+ if (this.env.realEvents) requireChromium();
172
+ return this.env.realEvents;
173
+ }
174
+ /**
175
+ * Trusted input returns as soon as the browser has dispatched it, so a read
176
+ * straight after could beat a framework that renders on a timer of its own
177
+ * (zoneless Angular schedules after the event). A zero-delay timer in the AUT
178
+ * window runs after any it queued, as user-event's own pause does in the
179
+ * other mode.
180
+ */
181
+ async afterReal(action) {
182
+ await action;
183
+ await new Promise((resolve) => this.env.window.setTimeout(resolve, 0));
184
+ }
185
+ /**
186
+ * Every match, resolved in one pass — see `DomQuery.all` for why. Each result is
187
+ * bound to its node and falls back to index resolution once that node leaves
188
+ * the document.
189
+ */
190
+ async all() {
191
+ return (await resolve.resolveAll(this.container, this.scope, this.selector)).map(
192
+ (element, index) => new BoundCypressQuery(this.env, this.scope, core.nth(this.selector, index), element)
193
+ );
194
+ }
195
+ // --- interactions -------------------------------------------------------
196
+ async click(options) {
197
+ this.log("click");
198
+ const element = await this.element(options);
199
+ await (this.real ? this.afterReal(realClick(element)) : this.user.click(element));
200
+ }
201
+ async fill(value, options) {
202
+ this.log("fill", JSON.stringify(value));
203
+ const element = await this.element(options);
204
+ if (this.real) {
205
+ await this.afterReal(realReplace(element, value));
206
+ return;
207
+ }
208
+ await this.user.clear(element);
209
+ if (value !== "") await this.user.type(element, value);
210
+ }
211
+ async clear(options) {
212
+ this.log("clear");
213
+ const element = await this.element(options);
214
+ await (this.real ? this.afterReal(realReplace(element, "")) : this.user.clear(element));
215
+ }
216
+ async check(options) {
217
+ this.log("check");
218
+ const element = await this.element(options);
219
+ if (element.checked) return;
220
+ await (this.real ? this.afterReal(realClick(element)) : this.user.click(element));
221
+ }
222
+ async uncheck(options) {
223
+ this.log("uncheck");
224
+ const element = await this.element(options);
225
+ if (!element.checked) return;
226
+ await (this.real ? this.afterReal(realClick(element)) : this.user.click(element));
227
+ }
228
+ /**
229
+ * Through user-event in both modes: a native `<select>` opens a popup the
230
+ * browser draws outside the page, which CDP pointer input cannot operate.
231
+ */
232
+ async selectOption(value, options) {
233
+ this.log("selectOption", JSON.stringify(value));
234
+ const element = await this.element(options);
235
+ if (element.multiple) {
236
+ const selected = [...element.selectedOptions].map((option) => option.value);
237
+ if (selected.length > 0) await this.user.deselectOptions(element, selected);
238
+ }
239
+ await this.user.selectOptions(element, value);
240
+ }
241
+ async hover(options) {
242
+ this.log("hover");
243
+ const element = await this.element(options);
244
+ await (this.real ? this.afterReal(realHover(element)) : this.user.hover(element));
245
+ }
246
+ async focus(options) {
247
+ this.log("focus");
248
+ (await this.element(options)).focus();
249
+ }
250
+ async blur(options) {
251
+ this.log("blur");
252
+ (await this.element(options)).blur();
253
+ }
254
+ async press(key, options) {
255
+ this.log("press", key);
256
+ const element = await this.element(options);
257
+ element.focus();
258
+ await (this.real ? this.afterReal(realPress(key)) : this.user.keyboard(toKeyboardInput(key)));
259
+ }
260
+ // --- observations -------------------------------------------------------
261
+ /**
262
+ * Through user-event, real events or not: the Chrome DevTools Protocol sets
263
+ * files only from paths on disk, and a File here has none.
264
+ */
265
+ async upload(files, options) {
266
+ const list = Array.isArray(files) ? files : [files];
267
+ this.log("upload", list.map((file) => file.name).join(", "));
268
+ const input = resolve.fileInputOf(await this.element(options));
269
+ core.checkFileTarget(input, list.length, this.scope, this.selector);
270
+ await this.user.upload(input, list);
271
+ }
272
+ async boundingBox(options) {
273
+ this.log("boundingBox");
274
+ return resolve.boundingBoxOf(await this.element(options), this.env.document);
275
+ }
276
+ async text(options) {
277
+ this.log("text");
278
+ return ((await this.element(options)).textContent ?? "").trim();
279
+ }
280
+ async inputValue(options) {
281
+ this.log("inputValue");
282
+ const element = await this.element(options);
283
+ return element.value ?? "";
284
+ }
285
+ async attribute(name, options) {
286
+ this.log("attribute", name);
287
+ return (await this.element(options)).getAttribute(name);
288
+ }
289
+ async isVisible(options) {
290
+ this.log("isVisible");
291
+ return this.visible(options);
292
+ }
293
+ /**
294
+ * A real browser lays the page out, so visibility is a layout question — a
295
+ * box, and not `visibility: hidden` — answered the way Playwright answers it,
296
+ * rather than the dom driver's computed-style walk.
297
+ */
298
+ async visible(options) {
299
+ try {
300
+ return resolve.isVisibleInLayout(await this.element(options), this.env.document);
301
+ } catch (error) {
302
+ if (error instanceof resolve.FrameEntryError || error instanceof core.StrictModeViolation) throw error;
303
+ return false;
304
+ }
305
+ }
306
+ async isEnabled(options) {
307
+ this.log("isEnabled");
308
+ const element = await this.element(options);
309
+ const disabled = element.disabled === true || element.closest(":disabled") !== null;
310
+ return core.enabledFrom(disabled, element.getAttribute("aria-disabled"));
311
+ }
312
+ async isChecked(options) {
313
+ this.log("isChecked");
314
+ const element = await this.element(options);
315
+ return core.checkedFrom(
316
+ element.getAttribute("aria-checked"),
317
+ Boolean(element.checked)
318
+ );
319
+ }
320
+ async selectedOptions(options) {
321
+ this.log("selectedOptions");
322
+ const element = await this.element(options);
323
+ return [...element.selectedOptions ?? []].map((option) => option.value);
324
+ }
325
+ // --- waiting ------------------------------------------------------------
326
+ async waitFor(state, options) {
327
+ this.log("waitFor", state);
328
+ const timeout = core.timeoutFor(options?.timeout);
329
+ const root = this.env.document.documentElement;
330
+ if (state === "visible") {
331
+ await waitUntil(
332
+ async () => {
333
+ if (!await this.visible({ timeout })) throw new Error("not visible yet");
334
+ },
335
+ root,
336
+ timeout
337
+ );
338
+ return;
339
+ }
340
+ await waitUntil(
341
+ async () => {
342
+ if (await this.count() !== 0 && await this.visible({ timeout })) {
343
+ throw new Error("still visible");
344
+ }
345
+ },
346
+ root,
347
+ timeout
348
+ );
349
+ }
350
+ async count() {
351
+ return resolve.countAll(this.container, this.scope, this.selector);
352
+ }
353
+ };
354
+ var SET_VALUE_TYPES = ["color", "date", "time", "datetime-local", "month", "range", "week"];
355
+ function setValue(input, value) {
356
+ const setter = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(input), "value")?.set;
357
+ if (setter === void 0) input.value = value;
358
+ else setter.call(input, value);
359
+ if (input.value !== value) {
360
+ throw new Error(
361
+ `harnessed: "${value}" is not a valid value for an <input type="${input.type}">.`
362
+ );
363
+ }
364
+ input.dispatchEvent(new Event("input", { bubbles: true, composed: true }));
365
+ input.dispatchEvent(new Event("change", { bubbles: true }));
366
+ }
367
+ async function realReplace(element, value) {
368
+ element.focus();
369
+ const input = element;
370
+ if (element.localName === "input" && SET_VALUE_TYPES.includes(input.type)) {
371
+ setValue(input, value);
372
+ return;
373
+ }
374
+ if (element.localName === "input" || element.localName === "textarea") {
375
+ element.select();
376
+ } else {
377
+ element.ownerDocument.getSelection()?.selectAllChildren(element);
378
+ }
379
+ await (value === "" ? realPress("Delete") : realInsertText(value));
380
+ }
381
+ var BoundCypressQuery = class extends CypressQuery {
382
+ constructor(env, scope, selector, bound) {
383
+ super(env, scope, selector);
384
+ this.bound = bound;
385
+ }
386
+ bound;
387
+ async element(options) {
388
+ if (this.bound.isConnected) return this.bound;
389
+ return super.element(options);
390
+ }
391
+ };
392
+ core.registerDriver(CYPRESS_DRIVER, (env, scope, selector) => {
393
+ return new CypressQuery(env, scope, selector);
394
+ });
395
+ var POLL_MS = 20;
396
+ function sleep(ms) {
397
+ return new Promise((resolve) => setTimeout(resolve, ms));
398
+ }
399
+ function baseOf(window2) {
400
+ const baseUrl = Cypress.config("baseUrl");
401
+ if (baseUrl !== null && baseUrl !== "") return baseUrl;
402
+ if (/^https?:$/.test(window2.location.protocol)) return window2.location.href;
403
+ return void 0;
404
+ }
405
+ function resolveUrl(window2, url) {
406
+ try {
407
+ return new URL(url, baseOf(window2));
408
+ } catch {
409
+ throw new Error(
410
+ `harnessed: cannot resolve "${url}": the application under test has not loaded a page yet and Cypress has no baseUrl. Set baseUrl, or pass an absolute URL.`
411
+ );
412
+ }
413
+ }
414
+ function sameDocument(from, to) {
415
+ const current = new URL(from);
416
+ return to.hash !== "" && current.href.split("#")[0] === to.href.split("#")[0];
417
+ }
418
+ async function goto(env, url) {
419
+ if (Cypress.testingType === "component") {
420
+ throw new Error(
421
+ "harnessed: goto() cannot run in component testing \u2014 the component is mounted in the spec frame, so navigating it would end the test. Navigate in an e2e spec, or mount the screen you want."
422
+ );
423
+ }
424
+ const { window: window2 } = env;
425
+ const leaving = window2.document;
426
+ const target = resolveUrl(window2, url);
427
+ const sameDoc = window2.location.protocol !== "about:" && sameDocument(window2.location.href, target);
428
+ window2.location.href = target.href;
429
+ if (sameDoc) return;
430
+ const timeout = Cypress.config("pageLoadTimeout");
431
+ const deadline = Date.now() + timeout;
432
+ for (; ; ) {
433
+ const document = window2.document;
434
+ if (document !== leaving && document.readyState !== "loading") return;
435
+ if (Date.now() > deadline) {
436
+ throw new Error(`harnessed: ${target.href} did not load within ${timeout}ms.`);
437
+ }
438
+ await sleep(POLL_MS);
439
+ }
440
+ }
441
+ core.registerNavigation(CYPRESS_DRIVER, {
442
+ goto,
443
+ currentUrl(env) {
444
+ return env.window.location.href;
445
+ },
446
+ async waitForUrl(env, matches, timeout) {
447
+ const { window: window2 } = env;
448
+ const deadline = Date.now() + timeout;
449
+ while (!matches(new URL(window2.location.href))) {
450
+ if (Date.now() > deadline) {
451
+ throw new Error(
452
+ `harnessed: the URL did not match within ${timeout}ms; it is ${window2.location.href}.`
453
+ );
454
+ }
455
+ await sleep(POLL_MS);
456
+ }
457
+ }
458
+ });
459
+
460
+ // src/env.ts
461
+ function cypress({
462
+ window: window2,
463
+ document,
464
+ realEvents = false,
465
+ log = true
466
+ }) {
467
+ return {
468
+ driver: CYPRESS_DRIVER,
469
+ window: window2,
470
+ get document() {
471
+ return document ?? window2.document;
472
+ },
473
+ realEvents,
474
+ log
475
+ };
476
+ }
477
+ function timeoutOf(options) {
478
+ return options?.timeout ?? core.getConfig().defaultTimeout * 4;
479
+ }
480
+ function envFor(window2, options) {
481
+ return cypress({
482
+ window: window2,
483
+ realEvents: options?.realEvents ?? false,
484
+ log: options?.log ?? true
485
+ });
486
+ }
487
+ function inPage(subject, fn, options) {
488
+ return cy.window({ log: false }).then({ timeout: timeoutOf(options) }, async (window2) => ({
489
+ result: await fn(envFor(window2, options))
490
+ })).then(({ result }) => cy.wrap(result === void 0 ? subject : result, { log: false }));
491
+ }
492
+ function registerCommands() {
493
+ Cypress.Commands.add(
494
+ "harnessEnv",
495
+ { prevSubject: "optional" },
496
+ (subject, fn, options) => inPage(subject, fn, options)
497
+ );
498
+ Cypress.Commands.add(
499
+ "harness",
500
+ { prevSubject: "optional" },
501
+ (subject, Harness, fnOrOptions, maybeOptions) => {
502
+ const fn = typeof fnOrOptions === "function" ? fnOrOptions : void 0;
503
+ const options = typeof fnOrOptions === "function" ? maybeOptions : fnOrOptions;
504
+ Cypress.log({ name: "harness", message: Harness.name });
505
+ return inPage(
506
+ subject,
507
+ (env) => {
508
+ const harness = new Harness(env);
509
+ return fn === void 0 ? harness : fn(harness);
510
+ },
511
+ options
512
+ );
513
+ }
514
+ );
515
+ Cypress.Commands.add(
516
+ "visitPage",
517
+ (Page, params, rawOptions) => {
518
+ const options = rawOptions;
519
+ return cy.window({ log: false }).then((window2) => {
520
+ const page = new Page(envFor(window2, options));
521
+ return cy.visit(page.urlFor(params)).then({ timeout: timeoutOf(options) }, async () => {
522
+ await page.expectReady();
523
+ return page;
524
+ });
525
+ });
526
+ }
527
+ );
528
+ }
529
+
530
+ exports.CYPRESS_DRIVER = CYPRESS_DRIVER;
531
+ exports.CypressQuery = CypressQuery;
532
+ exports.cypress = cypress;
533
+ exports.registerCommands = registerCommands;
534
+ //# sourceMappingURL=index.cjs.map
535
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/driver-id.ts","../src/real-events.ts","../src/cypress-query.ts","../src/navigation.ts","../src/env.ts","../src/commands.ts"],"names":["userEvent","waitForCondition","FrameEntryError","StrictModeViolation","Query","resolveOne","describeScope","resolveAll","withNth","fileInputOf","checkFileTarget","boundingBoxOf","isVisibleInLayout","enabledFrom","checkedFrom","timeoutFor","countAll","registerDriver","window","registerNavigation","getConfig"],"mappings":";;;;;;;;;;;;AACO,IAAM,cAAA,GAAiB;;;ACiB9B,IAAM,UAAA,GAA4C;AAAA,EAChD,OAAO,EAAE,IAAA,EAAM,SAAS,OAAA,EAAS,EAAA,EAAI,MAAM,IAAA,EAAK;AAAA,EAChD,GAAA,EAAK,EAAE,IAAA,EAAM,KAAA,EAAO,SAAS,CAAA,EAAE;AAAA,EAC/B,SAAA,EAAW,EAAE,IAAA,EAAM,WAAA,EAAa,SAAS,CAAA,EAAE;AAAA,EAC3C,MAAA,EAAQ,EAAE,IAAA,EAAM,QAAA,EAAU,SAAS,EAAA,EAAG;AAAA,EACtC,MAAA,EAAQ,EAAE,IAAA,EAAM,QAAA,EAAU,SAAS,EAAA,EAAG;AAAA,EACtC,OAAO,EAAE,IAAA,EAAM,SAAS,OAAA,EAAS,EAAA,EAAI,MAAM,GAAA,EAAI;AAAA,EAC/C,OAAA,EAAS,EAAE,IAAA,EAAM,SAAA,EAAW,SAAS,EAAA,EAAG;AAAA,EACxC,SAAA,EAAW,EAAE,IAAA,EAAM,WAAA,EAAa,SAAS,EAAA,EAAG;AAAA,EAC5C,SAAA,EAAW,EAAE,IAAA,EAAM,WAAA,EAAa,SAAS,EAAA,EAAG;AAAA,EAC5C,UAAA,EAAY,EAAE,IAAA,EAAM,YAAA,EAAc,SAAS,EAAA,EAAG;AAAA,EAC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O,MAAA;AAAA,QACL,OAAA;AAAA,QACA,CAAA,GAAA,KAAO;AACL,UAAA,MAAM,OAAA,GAAU,IAAI,OAAA,CAAQ,GAAG,CAAA;AAC/B,UAAA,OAAO,EAAA,KAAO,MAAA,GAAY,OAAA,GAAU,EAAA,CAAG,OAAO,CAAA;AAAA,QAChD,CAAA;AAAA,QACA;AAAA,OACF;AAAA,IACF;AAAA,GACF;AAEA,EAAA,OAAA,CAAQ,QAAA,CAAS,GAAA;AAAA,IACf,WAAA;AAAA,IACA,CAAC,IAAA,EAAmC,MAAA,EAAkB,UAAA,KAAyB;AAG7E,MAAA,MAAM,OAAA,GAAU,UAAA;AAChB,MAAA,OAAO,EAAA,CAAG,OAAO,EAAE,GAAA,EAAK,OAAO,CAAA,CAAE,IAAA,CAAK,CAAAA,OAAAA,KAAU;AAG9C,QAAA,MAAM,OAAO,IAAI,IAAA,CAAK,MAAA,CAAOA,OAAAA,EAAQ,OAAO,CAAC,CAAA;AAC7C,QAAA,OAAO,EAAA,CAAG,KAAA,CAAM,IAAA,CAAK,MAAA,CAAO,MAAM,CAAC,CAAA,CAAE,IAAA,CAAK,EAAE,OAAA,EAAS,SAAA,CAAU,OAAO,CAAA,IAAK,YAAY;AACrF,UAAA,MAAM,KAAK,WAAA,EAAY;AACvB,UAAA,OAAO,IAAA;AAAA,QACT,CAAC,CAAA;AAAA,MACH,CAAC,CAAA;AAAA,IACH;AAAA,GACF;AACF","file":"index.cjs","sourcesContent":["/** Its own module so `env.ts` and `cypress-query.ts` can share it without a cycle. */\nexport const CYPRESS_DRIVER = 'cypress'\n","/**\n * Trusted input through the Chrome DevTools Protocol, for `realEvents: true`.\n *\n * Cypress's own `trigger` and the cypress-real-events commands are `cy`\n * commands, and a harness runs inside a promise where nothing can be enqueued.\n * `Cypress.automation('remote:debugger:protocol')` is the one way to reach CDP\n * that is itself a promise. The browser then produces the events — `isTrusted`,\n * default actions and all — rather than a script imitating them.\n */\n\ninterface KeyDefinition {\n code: string\n keyCode: number\n /** What the key types, for the keys that type something. */\n text?: string\n}\n\n/** The named keys a harness presses. Printable characters are derived instead. */\nconst NAMED_KEYS: Record<string, KeyDefinition> = {\n Enter: { code: 'Enter', keyCode: 13, text: '\\r' },\n Tab: { code: 'Tab', keyCode: 9 },\n Backspace: { code: 'Backspace', keyCode: 8 },\n Delete: { code: 'Delete', keyCode: 46 },\n Escape: { code: 'Escape', keyCode: 27 },\n Space: { code: 'Space', keyCode: 32, text: ' ' },\n ArrowUp: { code: 'ArrowUp', keyCode: 38 },\n ArrowDown: { code: 'ArrowDown', keyCode: 40 },\n ArrowLeft: { code: 'ArrowLeft', keyCode: 37 },\n ArrowRight: { code: 'ArrowRight', keyCode: 39 },\n Home: { code: 'Home', keyCode: 36 },\n End: { code: 'End', keyCode: 35 },\n PageUp: { code: 'PageUp', keyCode: 33 },\n PageDown: { code: 'PageDown', keyCode: 34 },\n Insert: { code: 'Insert', keyCode: 45 },\n}\n\nfunction keyDefinition(key: string): { key: string } & KeyDefinition {\n const named = NAMED_KEYS[key]\n if (named !== undefined) return { key: key === 'Space' ? ' ' : key, ...named }\n if ([...key].length === 1) {\n const upper = key.toUpperCase()\n const code = /[A-Z]/.test(upper) ? `Key${upper}` : /[0-9]/.test(key) ? `Digit${key}` : ''\n const keyCode = /[A-Z0-9]/.test(upper) ? upper.charCodeAt(0) : 0\n return { key, code, keyCode, text: key }\n }\n throw new Error(\n `harnessed: realEvents cannot press \"${key}\". It presses single characters and ` +\n `${Object.keys(NAMED_KEYS).join(', ')}; drop realEvents to press it through user-event.`,\n )\n}\n\nfunction send(command: string, params: Record<string, unknown>): Promise<unknown> {\n return Promise.resolve(Cypress.automation('remote:debugger:protocol', { command, params }))\n}\n\n/** Refuses early and by name, instead of failing inside the automation channel. */\nexport function requireChromium(): void {\n if (!Cypress.isBrowser({ family: 'chromium' })) {\n throw new Error(\n `harnessed: realEvents drives Chrome DevTools Protocol input, which only ` +\n `Chromium-family browsers (Chrome, Edge, Electron) have; this run is in ` +\n `${Cypress.browser.name}. Leave realEvents off to use user-event there.`,\n )\n }\n}\n\n/**\n * The `<iframe>` elements between the top-level page and `target`, outermost\n * first. Searched for from the top rather than climbed to with `frameElement`,\n * because Cypress hides the AUT's `frameElement` from the app (it reads `null`).\n */\nfunction framesDownTo(target: Window, within: Document): HTMLIFrameElement[] | null {\n for (const frame of within.querySelectorAll('iframe')) {\n if (frame.contentWindow === target) return [frame]\n // A cross-origin frame's document is null: nothing to search in it.\n const inner = frame.contentDocument\n const path = inner === null ? null : framesDownTo(target, inner)\n if (path !== null) return [frame, ...path]\n }\n return null\n}\n\n/**\n * The centre of an element in the top-level viewport, which is where CDP input\n * is addressed. The AUT is a frame inside Cypress's runner — scaled to fit it,\n * in run mode — and a framed harness adds frames of its own, so each level adds\n * its frame's offset and scales by the transform the runner put on it.\n */\nfunction centreOf(element: Element): { x: number; y: number } {\n element.scrollIntoView({ block: 'center', inline: 'center' })\n const box = element.getBoundingClientRect()\n let x = box.left + box.width / 2\n let y = box.top + box.height / 2\n const view = element.ownerDocument.defaultView\n const top = window.top ?? window\n const frames = view === null || view === top ? [] : (framesDownTo(view, top.document) ?? [])\n for (const frame of frames.reverse()) {\n const frameBox = frame.getBoundingClientRect()\n const scale = frame.offsetWidth > 0 ? frameBox.width / frame.offsetWidth : 1\n const style = frame.ownerDocument.defaultView?.getComputedStyle(frame)\n const insetX = frame.clientLeft + parseFloat(style?.paddingLeft ?? '0')\n const insetY = frame.clientTop + parseFloat(style?.paddingTop ?? '0')\n x = frameBox.left + (insetX + x) * scale\n y = frameBox.top + (insetY + y) * scale\n }\n return { x, y }\n}\n\nexport async function realHover(element: Element): Promise<void> {\n const { x, y } = centreOf(element)\n await send('Input.dispatchMouseEvent', { type: 'mouseMoved', x, y })\n}\n\nexport async function realClick(element: Element): Promise<void> {\n const { x, y } = centreOf(element)\n await send('Input.dispatchMouseEvent', { type: 'mouseMoved', x, y })\n const press = { x, y, button: 'left', clickCount: 1 }\n await send('Input.dispatchMouseEvent', { type: 'mousePressed', buttons: 1, ...press })\n await send('Input.dispatchMouseEvent', { type: 'mouseReleased', buttons: 0, ...press })\n}\n\n/** One key, down then up, into whatever has focus. */\nexport async function realPress(key: string): Promise<void> {\n const { text, keyCode, ...definition } = keyDefinition(key)\n const common = { ...definition, windowsVirtualKeyCode: keyCode, nativeVirtualKeyCode: keyCode }\n // `keyDown` with text is what types; a key that types nothing is a raw key.\n await send(\n 'Input.dispatchKeyEvent',\n text === undefined\n ? { type: 'rawKeyDown', ...common }\n : { type: 'keyDown', text, unmodifiedText: text, ...common },\n )\n await send('Input.dispatchKeyEvent', { type: 'keyUp', ...common })\n}\n\n/** Text into whatever has focus, the way an IME commits it — Playwright's `fill`. */\nexport async function realInsertText(text: string): Promise<void> {\n await send('Input.insertText', { text })\n}\n","import { Query, registerDriver } from '@harnessed-ts/core'\nimport type { BoundingBox, EnvConfig, Selector, WaitOptions, WaitState } from '@harnessed-ts/core'\nimport {\n checkedFrom,\n checkFileTarget,\n describeScope,\n enabledFrom,\n nth as withNth,\n StrictModeViolation,\n timeoutFor,\n} from '@harnessed-ts/core'\nimport {\n boundingBoxOf,\n countAll,\n fileInputOf,\n FrameEntryError,\n isVisibleInLayout,\n resolveAll,\n resolveOne,\n} from '@harnessed-ts/resolve'\nimport { waitFor as waitForCondition } from '@testing-library/dom'\nimport userEvent from '@testing-library/user-event'\nimport type { UserEvent } from '@testing-library/user-event'\nimport { CYPRESS_DRIVER } from './driver-id'\nimport type { CypressEnv } from './env'\nimport { realClick, realHover, realInsertText, realPress, requireChromium } from './real-events'\n\n/** Playwright key names such as `Enter` map onto user-event's `{Enter}` syntax. */\nfunction toKeyboardInput(key: string): string {\n return key.length === 1 ? key : `{${key}}`\n}\n\n/**\n * One user-event instance per env and AUT document — the dom driver's one\n * `userEvent.setup()` per test, made lazily.\n *\n * It has to be bound to the AUT's document: by default it binds to the spec\n * frame's, which is a different page. Navigation brings a new document, so the\n * binding is renewed when the document changes. And it must not outlive the\n * env: user-event remembers the last element the pointer was over, and in\n * component testing — one document for the whole run — that element may sit in\n * a frame an earlier test unmounted, whose window is gone.\n */\nconst users = new WeakMap<CypressEnv, { document: Document; user: UserEvent }>()\n\nfunction userFor(env: CypressEnv): UserEvent {\n const { document } = env\n const bound = users.get(env)\n if (bound !== undefined && bound.document === document) return bound.user\n const user = userEvent.setup({ document })\n users.set(env, { document, user })\n return user\n}\n\n/**\n * Testing Library's `waitFor` retries every throw, but a frame that cannot be\n * entered never becomes enterable, and several matches never become one — so\n * either ends the wait at once.\n */\nasync function waitUntil(\n condition: () => Promise<void>,\n container: HTMLElement,\n timeout: number,\n): Promise<void> {\n let refused: FrameEntryError | StrictModeViolation | undefined\n await waitForCondition(\n async () => {\n try {\n await condition()\n } catch (error) {\n if (!(error instanceof FrameEntryError || error instanceof StrictModeViolation)) {\n throw error\n }\n refused = error\n }\n },\n // The default container is the spec frame's document, which never changes;\n // watching the AUT's is what lets a mutation end the wait early.\n { container, timeout },\n )\n if (refused !== undefined) throw refused\n}\n\n/**\n * Cypress driver. It runs inside the `cy.harness` bridge's promise, in the spec\n * frame, and reaches into the application under test's frame — same-origin, so\n * the shared resolver works on its document directly, exactly as the dom driver\n * does on jsdom's.\n */\nexport class CypressQuery extends Query {\n constructor(\n protected readonly env: CypressEnv,\n scope: readonly Selector[],\n selector: Selector,\n ) {\n super(scope, selector)\n }\n\n protected override clone(selector: Selector): Query {\n return new CypressQuery(this.env, this.scope, selector)\n }\n\n /** Read per query: navigation replaces the document, and with it the body. */\n private get container(): HTMLElement {\n const { document } = this.env\n return document.body ?? document.documentElement\n }\n\n protected element(options?: WaitOptions): Promise<HTMLElement> {\n return resolveOne(this.container, this.scope, this.selector, options?.timeout)\n }\n\n /** Keeps the command log telling the story: one entry per harness action. */\n protected log(action: string, detail?: string): void {\n if (!this.env.log) return\n const target = describeScope(this.scope, this.selector)\n Cypress.log({\n name: 'harness',\n message: `**${action}** ${target}${detail === undefined ? '' : ` ${detail}`}`,\n consoleProps: () => ({ action, target, detail }),\n })\n }\n\n private get user(): UserEvent {\n return userFor(this.env)\n }\n\n private get real(): boolean {\n if (this.env.realEvents) requireChromium()\n return this.env.realEvents\n }\n\n /**\n * Trusted input returns as soon as the browser has dispatched it, so a read\n * straight after could beat a framework that renders on a timer of its own\n * (zoneless Angular schedules after the event). A zero-delay timer in the AUT\n * window runs after any it queued, as user-event's own pause does in the\n * other mode.\n */\n private async afterReal(action: Promise<void>): Promise<void> {\n await action\n await new Promise<void>(resolve => this.env.window.setTimeout(resolve, 0))\n }\n\n /**\n * Every match, resolved in one pass — see `DomQuery.all` for why. Each result is\n * bound to its node and falls back to index resolution once that node leaves\n * the document.\n */\n override async all(): Promise<Query[]> {\n return (await resolveAll(this.container, this.scope, this.selector)).map(\n (element, index) =>\n new BoundCypressQuery(this.env, this.scope, withNth(this.selector, index), element),\n )\n }\n\n // --- interactions -------------------------------------------------------\n\n override async click(options?: WaitOptions): Promise<void> {\n this.log('click')\n const element = await this.element(options)\n await (this.real ? this.afterReal(realClick(element)) : this.user.click(element))\n }\n\n override async fill(value: string, options?: WaitOptions): Promise<void> {\n this.log('fill', JSON.stringify(value))\n const element = await this.element(options)\n if (this.real) {\n await this.afterReal(realReplace(element, value))\n return\n }\n await this.user.clear(element)\n // user-event throws on an empty string, and clearing is the whole intent\n // anyway — which is also what Playwright's fill('') does.\n if (value !== '') await this.user.type(element, value)\n }\n\n override async clear(options?: WaitOptions): Promise<void> {\n this.log('clear')\n const element = await this.element(options)\n await (this.real ? this.afterReal(realReplace(element, '')) : this.user.clear(element))\n }\n\n override async check(options?: WaitOptions): Promise<void> {\n this.log('check')\n const element = await this.element(options)\n if ((element as HTMLInputElement).checked) return\n await (this.real ? this.afterReal(realClick(element)) : this.user.click(element))\n }\n\n override async uncheck(options?: WaitOptions): Promise<void> {\n this.log('uncheck')\n const element = await this.element(options)\n if (!(element as HTMLInputElement).checked) return\n await (this.real ? this.afterReal(realClick(element)) : this.user.click(element))\n }\n\n /**\n * Through user-event in both modes: a native `<select>` opens a popup the\n * browser draws outside the page, which CDP pointer input cannot operate.\n */\n override async selectOption(value: string | string[], options?: WaitOptions): Promise<void> {\n this.log('selectOption', JSON.stringify(value))\n const element = (await this.element(options)) as HTMLSelectElement\n // user-event adds to a multi-select's existing selection; Playwright replaces\n // it. Replacing is the useful semantic and the one the shared API promises,\n // so clear first.\n if (element.multiple) {\n const selected = [...element.selectedOptions].map(option => option.value)\n if (selected.length > 0) await this.user.deselectOptions(element, selected)\n }\n await this.user.selectOptions(element, value)\n }\n\n override async hover(options?: WaitOptions): Promise<void> {\n this.log('hover')\n const element = await this.element(options)\n await (this.real ? this.afterReal(realHover(element)) : this.user.hover(element))\n }\n\n override async focus(options?: WaitOptions): Promise<void> {\n this.log('focus')\n ;(await this.element(options)).focus()\n }\n\n override async blur(options?: WaitOptions): Promise<void> {\n this.log('blur')\n ;(await this.element(options)).blur()\n }\n\n override async press(key: string, options?: WaitOptions): Promise<void> {\n this.log('press', key)\n const element = await this.element(options)\n element.focus()\n await (this.real ? this.afterReal(realPress(key)) : this.user.keyboard(toKeyboardInput(key)))\n }\n\n // --- observations -------------------------------------------------------\n\n /**\n * Through user-event, real events or not: the Chrome DevTools Protocol sets\n * files only from paths on disk, and a File here has none.\n */\n override async upload(files: File | File[], options?: WaitOptions): Promise<void> {\n const list = Array.isArray(files) ? files : [files]\n this.log('upload', list.map(file => file.name).join(', '))\n const input = fileInputOf(await this.element(options))\n checkFileTarget(input, list.length, this.scope, this.selector)\n await this.user.upload(input, list)\n }\n\n override async boundingBox(options?: WaitOptions): Promise<BoundingBox> {\n this.log('boundingBox')\n return boundingBoxOf(await this.element(options), this.env.document)\n }\n\n override async text(options?: WaitOptions): Promise<string> {\n this.log('text')\n return ((await this.element(options)).textContent ?? '').trim()\n }\n\n override async inputValue(options?: WaitOptions): Promise<string> {\n this.log('inputValue')\n const element = await this.element(options)\n return (element as HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement).value ?? ''\n }\n\n override async attribute(name: string, options?: WaitOptions): Promise<string | null> {\n this.log('attribute', name)\n return (await this.element(options)).getAttribute(name)\n }\n\n override async isVisible(options?: WaitOptions): Promise<boolean> {\n this.log('isVisible')\n return this.visible(options)\n }\n\n /**\n * A real browser lays the page out, so visibility is a layout question — a\n * box, and not `visibility: hidden` — answered the way Playwright answers it,\n * rather than the dom driver's computed-style walk.\n */\n private async visible(options?: WaitOptions): Promise<boolean> {\n try {\n return isVisibleInLayout(await this.element(options), this.env.document)\n } catch (error) {\n // Several matches is ambiguity, not invisibility: answering false would\n // claim that nodes on screen are not.\n if (error instanceof FrameEntryError || error instanceof StrictModeViolation) throw error\n // Not on screen at all, or an index past the last match. Prefer isAbsent()\n // to ask this — it answers without first waiting out the retry timeout.\n return false\n }\n }\n\n override async isEnabled(options?: WaitOptions): Promise<boolean> {\n this.log('isEnabled')\n const element = await this.element(options)\n // The DOM property accounts for an ancestor `<fieldset disabled>` where the\n // attribute does not — see the dom driver.\n const disabled =\n (element as HTMLInputElement).disabled === true || element.closest(':disabled') !== null\n return enabledFrom(disabled, element.getAttribute('aria-disabled'))\n }\n\n override async isChecked(options?: WaitOptions): Promise<boolean> {\n this.log('isChecked')\n const element = await this.element(options)\n return checkedFrom(\n element.getAttribute('aria-checked'),\n Boolean((element as HTMLInputElement).checked),\n )\n }\n\n override async selectedOptions(options?: WaitOptions): Promise<string[]> {\n this.log('selectedOptions')\n const element = (await this.element(options)) as HTMLSelectElement\n return [...(element.selectedOptions ?? [])].map(option => option.value)\n }\n\n // --- waiting ------------------------------------------------------------\n\n override async waitFor(state: WaitState, options?: WaitOptions): Promise<void> {\n this.log('waitFor', state)\n const timeout = timeoutFor(options?.timeout)\n const root = this.env.document.documentElement\n if (state === 'visible') {\n await waitUntil(\n async () => {\n if (!(await this.visible({ timeout }))) throw new Error('not visible yet')\n },\n root,\n timeout,\n )\n return\n }\n await waitUntil(\n async () => {\n if ((await this.count()) !== 0 && (await this.visible({ timeout }))) {\n throw new Error('still visible')\n }\n },\n root,\n timeout,\n )\n }\n\n override async count(): Promise<number> {\n return countAll(this.container, this.scope, this.selector)\n }\n}\n\n/**\n * Input types Playwright's `fill()` sets directly rather than types into: their\n * value is not text, so keystrokes into them mean nothing.\n */\nconst SET_VALUE_TYPES = ['color', 'date', 'time', 'datetime-local', 'month', 'range', 'week']\n\n/**\n * Sets the value and fires the events a person's edit ends with, as Playwright\n * does for these types. The setter is the prototype's, not the element's own:\n * React shadows `value` on the instance to track it, and a write through that\n * shadow would make the `input` event look like no change at all.\n */\nfunction setValue(input: HTMLInputElement, value: string): void {\n const setter = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(input), 'value')?.set\n if (setter === undefined) input.value = value\n else setter.call(input, value)\n if (input.value !== value) {\n throw new Error(\n `harnessed: \"${value}\" is not a valid value for an <input type=\"${input.type}\">.`,\n )\n }\n input.dispatchEvent(new Event('input', { bubbles: true, composed: true }))\n input.dispatchEvent(new Event('change', { bubbles: true }))\n}\n\n/**\n * Selects what the field holds and types over it, so the browser fires the\n * trusted input events a person's keystrokes would. Empty means delete. A\n * date, time, colour or range input takes no typing, so its value is set.\n */\nasync function realReplace(element: HTMLElement, value: string): Promise<void> {\n element.focus()\n // localName, not instanceof: the element belongs to the AUT's realm, not ours.\n const input = element as HTMLInputElement\n if (element.localName === 'input' && SET_VALUE_TYPES.includes(input.type)) {\n setValue(input, value)\n return\n }\n if (element.localName === 'input' || element.localName === 'textarea') {\n ;(element as HTMLInputElement | HTMLTextAreaElement).select()\n } else {\n element.ownerDocument.getSelection()?.selectAllChildren(element)\n }\n await (value === '' ? realPress('Delete') : realInsertText(value))\n}\n\n/** A query pinned to a node `all()` already found. See `BoundDomQuery`. */\nclass BoundCypressQuery extends CypressQuery {\n constructor(\n env: CypressEnv,\n scope: readonly Selector[],\n selector: Selector,\n private readonly bound: HTMLElement,\n ) {\n super(env, scope, selector)\n }\n\n protected override async element(options?: WaitOptions): Promise<HTMLElement> {\n if (this.bound.isConnected) return this.bound\n // A re-render replaced the node; the selector still carries this query's\n // index, so ordinary resolution finds the replacement.\n return super.element(options)\n }\n}\n\n/**\n * Registering on import is what lets `@harnessed-ts/core` stay driver-free: core\n * holds a registry keyed by driver id and never imports a driver itself.\n */\nregisterDriver(CYPRESS_DRIVER, (env: EnvConfig, scope, selector) => {\n return new CypressQuery(env as CypressEnv, scope, selector)\n})\n","import { registerNavigation } from '@harnessed-ts/core'\nimport type { EnvConfig } from '@harnessed-ts/core'\nimport { CYPRESS_DRIVER } from './driver-id'\nimport type { CypressEnv } from './env'\n\nconst POLL_MS = 20\n\nfunction sleep(ms: number): Promise<void> {\n return new Promise(resolve => setTimeout(resolve, ms))\n}\n\n/**\n * Where a relative URL is resolved from: Cypress's `baseUrl`, as Playwright\n * resolves against its `baseURL` — never the page the AUT happens to be on, or\n * the same `goto('step-two')` would land somewhere different from each page.\n * Without a `baseUrl`, the AUT's own URL is the only base there is; the AUT\n * starts each test on `about:blank`, which resolves nothing.\n */\nfunction baseOf(window: Window): string | undefined {\n const baseUrl = Cypress.config('baseUrl')\n if (baseUrl !== null && baseUrl !== '') return baseUrl\n if (/^https?:$/.test(window.location.protocol)) return window.location.href\n return undefined\n}\n\nfunction resolveUrl(window: Window, url: string): URL {\n try {\n return new URL(url, baseOf(window))\n } catch {\n throw new Error(\n `harnessed: cannot resolve \"${url}\": the application under test has not loaded a ` +\n `page yet and Cypress has no baseUrl. Set baseUrl, or pass an absolute URL.`,\n )\n }\n}\n\n/** Only the fragment differs, so the browser scrolls instead of loading a document. */\nfunction sameDocument(from: string, to: URL): boolean {\n const current = new URL(from)\n return to.hash !== '' && current.href.split('#')[0] === to.href.split('#')[0]\n}\n\n/**\n * Navigates inside the bridge's promise. Assigning `location.href` asks the AUT\n * frame to load a new document; Cypress sees the load the same way it sees a link\n * click and re-instruments the page. What the promise has to wait for is the\n * swap itself — the old document gone and the new one parsed — which is what\n * Playwright's `domcontentloaded` waits for too. Readiness beyond that is the\n * page's own `expectReady()`.\n */\nasync function goto(env: EnvConfig, url: string): Promise<void> {\n if (Cypress.testingType === 'component') {\n throw new Error(\n 'harnessed: goto() cannot run in component testing — the component is mounted in ' +\n 'the spec frame, so navigating it would end the test. Navigate in an e2e spec, ' +\n 'or mount the screen you want.',\n )\n }\n const { window } = env as CypressEnv\n const leaving = window.document\n const target = resolveUrl(window, url)\n const sameDoc =\n window.location.protocol !== 'about:' && sameDocument(window.location.href, target)\n window.location.href = target.href\n if (sameDoc) return\n\n // A first load through Vite's dev server can take a while; Cypress's own\n // budget for a page load is the honest one to wait out.\n const timeout = Cypress.config('pageLoadTimeout')\n const deadline = Date.now() + timeout\n for (;;) {\n const document = window.document\n if (document !== leaving && document.readyState !== 'loading') return\n if (Date.now() > deadline) {\n throw new Error(`harnessed: ${target.href} did not load within ${timeout}ms.`)\n }\n await sleep(POLL_MS)\n }\n}\n\n/**\n * This driver can navigate, so it registers the capability a page's `goto()`\n * runs on. `currentUrl` and `waitForUrl` read the AUT's own location, which is\n * always the live one: `window` is the frame's WindowProxy.\n */\nregisterNavigation(CYPRESS_DRIVER, {\n goto,\n currentUrl(env) {\n return (env as CypressEnv).window.location.href\n },\n async waitForUrl(env, matches, timeout) {\n const { window } = env as CypressEnv\n const deadline = Date.now() + timeout\n while (!matches(new URL(window.location.href))) {\n if (Date.now() > deadline) {\n throw new Error(\n `harnessed: the URL did not match within ${timeout}ms; it is ${window.location.href}.`,\n )\n }\n await sleep(POLL_MS)\n }\n },\n})\n","import type { EnvConfig } from '@harnessed-ts/core'\nimport { CYPRESS_DRIVER } from './driver-id'\n// Imported for its side effect: constructing an env is the moment the driver has\n// to be in the registry, and a bare re-export could be tree-shaken away.\nimport './cypress-query'\nimport './navigation'\n\nexport { CYPRESS_DRIVER }\n\nexport interface CypressEnv extends EnvConfig {\n readonly driver: typeof CYPRESS_DRIVER\n /**\n * The application under test's window — what `cy.window()` yields. That is the\n * AUT frame's WindowProxy, which stays the same object when the frame\n * navigates, so it is safe to hold across a `goto()`.\n */\n readonly window: Window\n /**\n * Where queries start. Read from `window` at every query unless it was pinned:\n * navigation replaces the document, and a query must never search the one the\n * frame has left.\n */\n readonly document: Document\n /**\n * Interactions go through Chrome DevTools Protocol input — trusted events from\n * the browser itself — instead of `@testing-library/user-event`. Chromium only.\n */\n readonly realEvents: boolean\n /** Whether each harness action writes an entry to Cypress's command log. */\n readonly log: boolean\n}\n\nexport interface CypressEnvOptions {\n /** The AUT window: `cy.window()`'s subject. */\n window: Window\n /** Pins queries to one document. Omit it to follow the AUT through navigation. */\n document?: Document\n /** Trusted CDP input instead of user-event. Chromium only. Default `false`. */\n realEvents?: boolean\n /** Write each harness action to the command log. Default `true`. */\n log?: boolean\n}\n\n/**\n * Builds the env a harness is constructed with under Cypress. The commands in\n * `@harnessed-ts/cypress/support` build it for you; call this directly only when\n * you already hold the AUT window.\n */\nexport function cypress({\n window,\n document,\n realEvents = false,\n log = true,\n}: CypressEnvOptions): CypressEnv {\n return {\n driver: CYPRESS_DRIVER,\n window,\n get document(): Document {\n return document ?? window.document\n },\n realEvents,\n log,\n }\n}\n","import { getConfig } from '@harnessed-ts/core'\nimport type { EnvConfig, WaitOptions } from '@harnessed-ts/core'\nimport { cypress } from './env'\nimport type { CypressEnv } from './env'\n\n/** What every bridge command accepts. */\nexport interface HarnessCommandOptions {\n /**\n * How long the whole callback may take. Defaults to four times the configured\n * `defaultTimeout`: one harness flow is several waits in a row, and Cypress's own\n * 4 s command timeout would otherwise cut it short.\n */\n timeout?: number\n /** Trusted CDP input instead of user-event. Chromium only. */\n realEvents?: boolean\n /** Write each harness action to the command log. Default `true`. */\n log?: boolean\n}\n\n/** Any harness or page class: constructed from an env, like every harness. */\nexport type HarnessClass<H> = new (env: EnvConfig) => H\n\n/** What `cy.visitPage` needs of a page — structural, so this package does not depend on `@harnessed-ts/page`. */\nexport interface VisitablePage {\n // Method syntax on purpose: a page's `urlFor` takes its own params tuple, and\n // only a method signature accepts every one of them.\n urlFor(...args: unknown[]): string\n expectReady(options?: WaitOptions): Promise<void>\n}\n\n/** The params `PageClass.urlFor` takes, then the command's options. */\nexport type VisitPageArgs<P extends VisitablePage> = [\n ...Parameters<P['urlFor']>,\n options?: HarnessCommandOptions,\n]\n\n/** What a callback command yields: its result, or the subject when it resolves nothing. */\nexport type Yielded<T, Subject> = T extends void | undefined ? Subject : T\n\ndeclare global {\n // Cypress's augmentation point is this global namespace.\n namespace Cypress {\n // The type parameter is Cypress's, default and all; a merged declaration only\n // has to repeat its name.\n interface Chainable<Subject> {\n /**\n * Runs `fn` against the application under test with a harnessed env, and\n * yields what it resolves to — or, like `cy.then`, passes the subject\n * through when it resolves nothing. One command: everything inside is\n * awaited promises, never `cy` commands.\n */\n harnessEnv<T>(\n fn: (env: CypressEnv) => T | PromiseLike<T>,\n options?: HarnessCommandOptions,\n ): Chainable<Yielded<T, Subject>>\n /** Yields a harness constructed against the application under test. */\n harness<H>(Harness: HarnessClass<H>, options?: HarnessCommandOptions): Chainable<H>\n /**\n * Constructs a harness against the application under test and awaits `fn`\n * with it, yielding what `fn` resolves to (or passing the subject through,\n * when that is nothing):\n *\n * ```ts\n * cy.harness(LoginFormHarness, async form => {\n * await form.fillIn({ email: 'ada@example.com' })\n * await expect(form).not.to.be.absent\n * })\n * ```\n */\n harness<H, T>(\n Harness: HarnessClass<H>,\n fn: (harness: H) => T | PromiseLike<T>,\n options?: HarnessCommandOptions,\n ): Chainable<Yielded<T, Subject>>\n /**\n * `cy.visit(page.urlFor(params))`, then waits for the page's `expectReady()`\n * and yields the page. Navigation belongs to Cypress's queue, which is why\n * this is a command and `page.goto()` is not the way in.\n */\n visitPage<P extends VisitablePage>(\n Page: HarnessClass<P>,\n ...args: VisitPageArgs<P>\n ): Chainable<P>\n }\n }\n}\n\nfunction timeoutOf(options?: HarnessCommandOptions): number {\n return options?.timeout ?? getConfig().defaultTimeout * 4\n}\n\nfunction envFor(window: Window, options?: HarnessCommandOptions): CypressEnv {\n return cypress({\n window,\n realEvents: options?.realEvents ?? false,\n log: options?.log ?? true,\n })\n}\n\n/**\n * The bridge. Cypress commands are enqueued, not awaited, and a promise cannot\n * enqueue one — so a harness runs entirely inside a single `then`, as plain\n * promises against the AUT document. Cypress waits for the promise and fails the\n * test with whatever it rejects with.\n *\n * What it yields is `Yielded`: the result, or the subject when the result is\n * `undefined`. A `then` cannot yield `undefined` — it passes its own subject,\n * the AUT window, through instead — so the result travels boxed, and `cy.wrap`\n * yields it as is, `undefined` included.\n */\nfunction inPage<T>(\n subject: unknown,\n fn: (env: CypressEnv) => T | PromiseLike<T>,\n options?: HarnessCommandOptions,\n): Cypress.Chainable<unknown> {\n return cy\n .window({ log: false })\n .then({ timeout: timeoutOf(options) }, async window => ({\n result: await fn(envFor(window, options)),\n }))\n .then(({ result }) => cy.wrap(result === undefined ? subject : result, { log: false }))\n}\n\n/**\n * Registers `cy.harnessEnv`, `cy.harness` and `cy.visitPage`. Importing\n * `@harnessed-ts/cypress/support` calls this; call it yourself only if you\n * register commands from your own support file instead.\n */\nexport function registerCommands(): void {\n // 'optional': chained from anything or from nothing. The subject is only ever\n // passed through, never acted on.\n Cypress.Commands.add(\n 'harnessEnv',\n { prevSubject: 'optional' },\n <T>(\n subject: unknown,\n fn: (env: CypressEnv) => T | PromiseLike<T>,\n options?: HarnessCommandOptions,\n ) => inPage(subject, fn, options),\n )\n\n Cypress.Commands.add(\n 'harness',\n { prevSubject: 'optional' },\n <H, T>(\n subject: unknown,\n Harness: HarnessClass<H>,\n fnOrOptions?: ((harness: H) => T | PromiseLike<T>) | HarnessCommandOptions,\n maybeOptions?: HarnessCommandOptions,\n ) => {\n const fn = typeof fnOrOptions === 'function' ? fnOrOptions : undefined\n const options = typeof fnOrOptions === 'function' ? maybeOptions : fnOrOptions\n Cypress.log({ name: 'harness', message: Harness.name })\n return inPage(\n subject,\n env => {\n const harness = new Harness(env)\n return fn === undefined ? harness : fn(harness)\n },\n options,\n )\n },\n )\n\n Cypress.Commands.add(\n 'visitPage',\n (Page: HarnessClass<VisitablePage>, params?: unknown, rawOptions?: unknown) => {\n // Cypress erases the generic signature here; the declaration above is what\n // callers are checked against.\n const options = rawOptions as HarnessCommandOptions | undefined\n return cy.window({ log: false }).then(window => {\n // urlFor needs no navigation, so the page can be built before the visit;\n // the AUT window it holds is the same object after it.\n const page = new Page(envFor(window, options))\n return cy.visit(page.urlFor(params)).then({ timeout: timeoutOf(options) }, async () => {\n await page.expectReady()\n return page\n })\n })\n },\n )\n}\n"]}
@@ -0,0 +1,6 @@
1
+ export { cypress, CYPRESS_DRIVER } from './env';
2
+ export type { CypressEnv, CypressEnvOptions } from './env';
3
+ export { CypressQuery } from './cypress-query';
4
+ export { registerCommands } from './commands';
5
+ export type { HarnessClass, HarnessCommandOptions, VisitablePage, VisitPageArgs, Yielded, } from './commands';
6
+ //# sourceMappingURL=index.d.ts.map