@harnessed-ts/testcafe 0.7.0 → 0.8.1
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/CHANGELOG.md +27 -0
- package/README.md +2 -0
- package/dist/chunk-HA6QY24A.js +73 -0
- package/dist/chunk-HA6QY24A.js.map +1 -0
- package/dist/env.d.ts +1 -0
- package/dist/env.d.ts.map +1 -1
- package/dist/index.cjs +65 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/mock-transport.d.ts +2 -0
- package/dist/mock-transport.d.ts.map +1 -0
- package/dist/mock.cjs +84 -0
- package/dist/mock.cjs.map +1 -0
- package/dist/mock.d.ts +18 -0
- package/dist/mock.d.ts.map +1 -0
- package/dist/mock.js +4 -0
- package/dist/mock.js.map +1 -0
- package/package.json +16 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,32 @@
|
|
|
1
1
|
# @harnessed-ts/testcafe
|
|
2
2
|
|
|
3
|
+
## 0.8.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- @harnessed-ts/core@0.8.1
|
|
8
|
+
- @harnessed-ts/mock@0.8.1
|
|
9
|
+
- @harnessed-ts/resolve@0.8.1
|
|
10
|
+
|
|
11
|
+
## 0.8.0
|
|
12
|
+
|
|
13
|
+
### Minor Changes
|
|
14
|
+
|
|
15
|
+
- d00bf4e: API mocking, the same under every runner. The new `@harnessed-ts/mock` holds one handler model and each driver registers the transport that intercepts requests under its runner: `page.route` under Playwright, request interception under Puppeteer, a request hook under TestCafe, one catch-all `cy.intercept` under Cypress, an agent injected by a WebDriver BiDi preload script under WebdriverIO, and `fetch`, XHR and `WebSocket` patched in the page (through `@mswjs/interceptors`, an optional peer) under Testing Library, Ember, Vitest browser mode and Storybook. Every driver has a `/mock` entry: `import { mock, json } from '@harnessed-ts/playwright/mock'`.
|
|
16
|
+
|
|
17
|
+
`mock(env, { scope, state, onUnhandled, openapi })` returns the mock for that env's network. Handlers come three ways — the fluent `api.get('/api/users/:id').once().delay(200).reply(…)`, MSW-shaped tables (`http.get`, `graphql.query`), and API harness classes (`@Api`, `@Get`, `@Post`…) overridable per route — and the newest matching handler answers. Builders cover JSON, text, HTML, XML, bytes, files, forms, server-sent events, NDJSON, chunked streams, every common status, RFC 9457 problem details, JSON:API and GraphQL results, network errors, aborts and hangs; `defineFactory` builds deterministic test data. A request in scope that nothing answers fails the test, naming it. Requests are logged with parsed bodies, `waitFor` waits for one, and `toHaveBeenRequested`, `toHaveBeenRequestedTimes` and `toHaveBeenRequestedWith` join every driver's matchers (`requested`/`requestedWith` for Chai, `assert.requests(route)` for QUnit). Mocks can be validated against an OpenAPI document, a GraphQL schema (`@harnessed-ts/mock/graphql`) or a Standard Schema, typed from openapi-typescript output with `typedApi`, replayed from a HAR (recorded under Playwright and Puppeteer), and built from existing MSW handlers. `api.ws()` mocks WebSockets everywhere but TestCafe; streams are delivered in pieces under the in-page runners and WebdriverIO, and whole elsewhere. `resetMocks()` ends every mock after a test; `@harnessed-ts/mock/vitest`, Ember's `setupMocks(hooks)`, Playwright's `withMocks(test)`, Cypress's support import and Storybook's preview do it for you.
|
|
18
|
+
|
|
19
|
+
`@harnessed-ts/core` adds `registerBeforeNavigate`, and `PageHarness.goto()` awaits it: a mock is intercepting before the page loads. A page may declare the mocks it always needs with `get mocks()`. Storybook stories declare theirs in `parameters.harnessed.mocks` (with `harnessed()` from `@harnessed-ts/storybook/mock`), Gherkin worlds expose `mocks`, and the conformance catalog gains a data view (in React and its Glimmer port) and `mockSpecs`, run by every runner.
|
|
20
|
+
|
|
21
|
+
`createApiStubs` in `@harnessed-ts/playwright` is now built on `mock()` and deprecated; it is removed in the next minor. `@harnessed-ts/eslint-plugin` adds `no-raw-intercept` and `await-mock-install`, and `@harnessed-ts/claude` documents mocking for each detected runner, with an API harness template.
|
|
22
|
+
|
|
23
|
+
### Patch Changes
|
|
24
|
+
|
|
25
|
+
- Updated dependencies [d00bf4e]
|
|
26
|
+
- @harnessed-ts/mock@0.8.0
|
|
27
|
+
- @harnessed-ts/core@0.8.0
|
|
28
|
+
- @harnessed-ts/resolve@0.8.0
|
|
29
|
+
|
|
3
30
|
## 0.7.0
|
|
4
31
|
|
|
5
32
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -25,6 +25,8 @@ relative path against the current page, or against `testcafe(t, { baseUrl })`.
|
|
|
25
25
|
There is no `/matchers` entry, because TestCafe asserts with `t.expect`. Await
|
|
26
26
|
the harness and assert on the value, or use `@harnessed-ts/chai`.
|
|
27
27
|
|
|
28
|
+
**Mocking:** `import { mock } from '@harnessed-ts/testcafe/mock'` mocks through a request hook on the test's controller. No streaming or WebSockets. See [Mocking APIs](https://github.com/joegaudet/harnessed#mocking-apis).
|
|
29
|
+
|
|
28
30
|
Full guide, the cross-driver guarantees, and the API: the
|
|
29
31
|
[harnessed README](https://github.com/joegaudet/harnessed#readme).
|
|
30
32
|
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { registerMockTransport } from '@harnessed-ts/mock';
|
|
2
|
+
import { RequestHook, RequestMock } from 'testcafe';
|
|
3
|
+
|
|
4
|
+
// src/driver-id.ts
|
|
5
|
+
var TESTCAFE_DRIVER = "testcafe";
|
|
6
|
+
function responseMockClass() {
|
|
7
|
+
const probe = RequestMock().onRequestTo(() => false).respond("");
|
|
8
|
+
return probe.mocks.values().next().value.constructor;
|
|
9
|
+
}
|
|
10
|
+
var UNREACHABLE = { hostname: "127.0.0.1", port: 9 };
|
|
11
|
+
var MockHook = class extends RequestHook {
|
|
12
|
+
#dispatcher;
|
|
13
|
+
#ResponseMock = responseMockClass();
|
|
14
|
+
disposed = false;
|
|
15
|
+
constructor(dispatcher) {
|
|
16
|
+
super(void 0, {});
|
|
17
|
+
this.#dispatcher = dispatcher;
|
|
18
|
+
}
|
|
19
|
+
async onRequest(event) {
|
|
20
|
+
if (this.disposed) return;
|
|
21
|
+
const request = event._requestInfo;
|
|
22
|
+
const raw = {
|
|
23
|
+
method: request.method.toUpperCase(),
|
|
24
|
+
url: request.url,
|
|
25
|
+
headers: request.headers,
|
|
26
|
+
body: request.body !== void 0 && request.body.length > 0 ? new Uint8Array(request.body) : null,
|
|
27
|
+
kind: request.isAjax ? "fetch" : "other"
|
|
28
|
+
};
|
|
29
|
+
const result = await this.#dispatcher.dispatch(raw);
|
|
30
|
+
if (result.kind === "passthrough") return;
|
|
31
|
+
if (result.kind === "error") {
|
|
32
|
+
const options = event.requestOptions;
|
|
33
|
+
options.hostname = UNREACHABLE.hostname;
|
|
34
|
+
options.host = `${UNREACHABLE.hostname}:${UNREACHABLE.port}`;
|
|
35
|
+
options.port = UNREACHABLE.port;
|
|
36
|
+
options.protocol = "http:";
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
const { reply } = result;
|
|
40
|
+
await event.setMock(
|
|
41
|
+
this.#ResponseMock.from({
|
|
42
|
+
body: reply.body === null ? "" : Buffer.from(reply.body),
|
|
43
|
+
statusCode: reply.status,
|
|
44
|
+
headers: reply.headers
|
|
45
|
+
})
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
async onResponse() {
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
async function install(t, dispatcher) {
|
|
52
|
+
const hook = new MockHook(dispatcher);
|
|
53
|
+
await t.addRequestHooks(hook);
|
|
54
|
+
return {
|
|
55
|
+
async dispose() {
|
|
56
|
+
hook.disposed = true;
|
|
57
|
+
await t.removeRequestHooks(hook).catch(() => {
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
registerMockTransport(TESTCAFE_DRIVER, {
|
|
63
|
+
// Buffered, and no sockets: TestCafe's proxy offers neither a streamed
|
|
64
|
+
// response nor a hook on WebSockets.
|
|
65
|
+
capabilities: { streaming: false, websockets: false, harRecord: false },
|
|
66
|
+
// Hooks are attached per test, through the test's own controller.
|
|
67
|
+
key: (env) => env.t,
|
|
68
|
+
install: (env, dispatcher) => install(env.t, dispatcher)
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
export { TESTCAFE_DRIVER };
|
|
72
|
+
//# sourceMappingURL=chunk-HA6QY24A.js.map
|
|
73
|
+
//# sourceMappingURL=chunk-HA6QY24A.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/driver-id.ts","../src/mock-transport.ts"],"names":[],"mappings":";;;;AACO,IAAM,eAAA,GAAkB;ACyC/B,SAAS,iBAAA,GAAuC;AAC9C,EAAA,MAAM,KAAA,GAAQ,aAAY,CACvB,WAAA,CAAY,MAAM,KAAK,CAAA,CACvB,QAAQ,EAAE,CAAA;AACb,EAAA,OAAO,MAAM,KAAA,CAAM,MAAA,EAAO,CAAE,IAAA,GAAO,KAAA,CAAO,WAAA;AAC5C;AAGA,IAAM,WAAA,GAAc,EAAE,QAAA,EAAU,WAAA,EAAa,MAAM,CAAA,EAAE;AAErD,IAAM,QAAA,GAAN,cAAuB,WAAA,CAAY;AAAA,EACxB,WAAA;AAAA,EACA,gBAAgB,iBAAA,EAAkB;AAAA,EAC3C,QAAA,GAAW,KAAA;AAAA,EAEX,YAAY,UAAA,EAAwB;AAClC,IAAA,KAAA,CAAM,MAAA,EAAW,EAAE,CAAA;AACnB,IAAA,IAAA,CAAK,WAAA,GAAc,UAAA;AAAA,EACrB;AAAA,EAEA,MAAe,UAAU,KAAA,EAA8B;AACrD,IAAA,IAAI,KAAK,QAAA,EAAU;AACnB,IAAA,MAAM,UAAW,KAAA,CAAuB,YAAA;AACxC,IAAA,MAAM,GAAA,GAAkB;AAAA,MACtB,MAAA,EAAQ,OAAA,CAAQ,MAAA,CAAO,WAAA,EAAY;AAAA,MACnC,KAAK,OAAA,CAAQ,GAAA;AAAA,MACb,SAAS,OAAA,CAAQ,OAAA;AAAA,MACjB,IAAA,EACE,OAAA,CAAQ,IAAA,KAAS,MAAA,IAAa,OAAA,CAAQ,I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A,GAAU;AACd,MAAA,IAAA,CAAK,QAAA,GAAW,IAAA;AAChB,MAAA,MAAM,CAAA,CAAE,kBAAA,CAAmB,IAAI,CAAA,CAAE,MAAM,MAAM;AAAA,MAE7C,CAAC,CAAA;AAAA,IACH;AAAA,GACF;AACF;AAEA,qBAAA,CAAsB,eAAA,EAAiB;AAAA;AAAA;AAAA,EAGrC,cAAc,EAAE,SAAA,EAAW,OAAO,UAAA,EAAY,KAAA,EAAO,WAAW,KAAA,EAAM;AAAA;AAAA,EAEtE,GAAA,EAAK,SAAQ,GAAA,CAAoB,CAAA;AAAA,EACjC,SAAS,CAAC,GAAA,EAAK,eAAe,OAAA,CAAS,GAAA,CAAoB,GAAG,UAAU;AAC1E,CAAC,CAAA","file":"chunk-HA6QY24A.js","sourcesContent":["/** Its own module so `env.ts` and `testcafe-query.ts` can share it without a cycle. */\nexport const TESTCAFE_DRIVER = 'testcafe'\n","import { registerMockTransport } from '@harnessed-ts/mock'\nimport type { Dispatcher, InstalledTransport, RawRequest } from '@harnessed-ts/mock'\nimport { RequestHook, RequestMock } from 'testcafe'\nimport { TESTCAFE_DRIVER } from './driver-id'\nimport type { TestCafeEnv } from './env'\n\n/**\n * The parts of hammerhead's request event this transport reads and writes.\n * `_requestInfo` is what TestCafe's own RequestLogger reads; there is no\n * public equivalent.\n */\ninterface RequestEvent {\n _requestInfo: {\n url: string\n method: string\n headers: Record<string, string>\n body?: Buffer\n isAjax: boolean\n }\n requestOptions: {\n hostname: string\n host: string\n port: number | string\n protocol: string\n path: string\n }\n setMock(mock: unknown): Promise<void>\n}\n\ninterface ResponseMockClass {\n from(init: {\n body: Buffer | string\n statusCode: number\n headers: Record<string, string>\n }): unknown\n}\n\n/**\n * hammerhead's ResponseMock, which TestCafe does not export. A RequestMock\n * builds one per rule, so one built here and read back gives the class without\n * depending on hammerhead directly.\n */\nfunction responseMockClass(): ResponseMockClass {\n const probe = RequestMock()\n .onRequestTo(() => false)\n .respond('') as unknown as { mocks: Map<string, object> }\n return probe.mocks.values().next().value!.constructor as unknown as ResponseMockClass\n}\n\n/** A port nothing listens on: sending a request there is how a network failure is staged. */\nconst UNREACHABLE = { hostname: '127.0.0.1', port: 9 }\n\nclass MockHook extends RequestHook {\n readonly #dispatcher: Dispatcher\n readonly #ResponseMock = responseMockClass()\n disposed = false\n\n constructor(dispatcher: Dispatcher) {\n super(undefined, {})\n this.#dispatcher = dispatcher\n }\n\n override async onRequest(event: object): Promise<void> {\n if (this.disposed) return\n const request = (event as RequestEvent)._requestInfo\n const raw: RawRequest = {\n method: request.method.toUpperCase(),\n url: request.url,\n headers: request.headers,\n body:\n request.body !== undefined && request.body.length > 0 ? new Uint8Array(request.body) : null,\n kind: request.isAjax ? 'fetch' : 'other',\n }\n const result = await this.#dispatcher.dispatch(raw)\n if (result.kind === 'passthrough') return\n if (result.kind === 'error') {\n // TestCafe can mock a response but not fail one, so the request is sent\n // where nothing answers — the browser sees the same network error.\n const options = (event as RequestEvent).requestOptions\n options.hostname = UNREACHABLE.hostname\n options.host = `${UNREACHABLE.hostname}:${UNREACHABLE.port}`\n options.port = UNREACHABLE.port\n options.protocol = 'http:'\n return\n }\n const { reply } = result\n await (event as RequestEvent).setMock(\n this.#ResponseMock.from({\n body: reply.body === null ? '' : Buffer.from(reply.body),\n statusCode: reply.status,\n headers: reply.headers,\n }),\n )\n }\n\n override async onResponse(): Promise<void> {}\n}\n\nasync function install(t: TestController, dispatcher: Dispatcher): Promise<InstalledTransport> {\n const hook = new MockHook(dispatcher)\n await t.addRequestHooks(hook)\n return {\n async dispose() {\n hook.disposed = true\n await t.removeRequestHooks(hook).catch(() => {\n // The test is over and took its hooks with it.\n })\n },\n }\n}\n\nregisterMockTransport(TESTCAFE_DRIVER, {\n // Buffered, and no sockets: TestCafe's proxy offers neither a streamed\n // response nor a hook on WebSockets.\n capabilities: { streaming: false, websockets: false, harRecord: false },\n // Hooks are attached per test, through the test's own controller.\n key: env => (env as TestCafeEnv).t,\n install: (env, dispatcher) => install((env as TestCafeEnv).t, dispatcher),\n})\n"]}
|
package/dist/env.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { EnvConfig } from '@harnessed-ts/core';
|
|
2
2
|
import { TESTCAFE_DRIVER } from './driver-id';
|
|
3
3
|
import './testcafe-query';
|
|
4
|
+
import './mock-transport';
|
|
4
5
|
export { TESTCAFE_DRIVER };
|
|
5
6
|
export interface TestCafeEnv extends EnvConfig {
|
|
6
7
|
readonly driver: typeof TESTCAFE_DRIVER;
|
package/dist/env.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../src/env.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAG7C,OAAO,kBAAkB,CAAA;AAEzB,OAAO,EAAE,eAAe,EAAE,CAAA;AAE1B,MAAM,WAAW,WAAY,SAAQ,SAAS;IAC5C,QAAQ,CAAC,MAAM,EAAE,OAAO,eAAe,CAAA;IACvC,kFAAkF;IAClF,QAAQ,CAAC,CAAC,EAAE,cAAc,CAAA;IAC1B;;;OAGG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAC1B;AAED,MAAM,WAAW,kBAAkB;IACjC,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB;AAED;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,cAAc,EAAE,OAAO,GAAE,kBAAuB,GAAG,WAAW,CAKzF"}
|
|
1
|
+
{"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../src/env.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAG7C,OAAO,kBAAkB,CAAA;AAEzB,OAAO,kBAAkB,CAAA;AAEzB,OAAO,EAAE,eAAe,EAAE,CAAA;AAE1B,MAAM,WAAW,WAAY,SAAQ,SAAS;IAC5C,QAAQ,CAAC,MAAM,EAAE,OAAO,eAAe,CAAA;IACvC,kFAAkF;IAClF,QAAQ,CAAC,CAAC,EAAE,cAAc,CAAA;IAC1B;;;OAGG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAC1B;AAED,MAAM,WAAW,kBAAkB;IACjC,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB;AAED;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,cAAc,EAAE,OAAO,GAAE,kBAAuB,GAAG,WAAW,CAKzF"}
|
package/dist/index.cjs
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
var testcafe$1 = require('testcafe');
|
|
4
4
|
var inject = require('@harnessed-ts/resolve/inject');
|
|
5
5
|
var core = require('@harnessed-ts/core');
|
|
6
|
+
var mock = require('@harnessed-ts/mock');
|
|
6
7
|
|
|
7
8
|
// src/driver-id.ts
|
|
8
9
|
var TESTCAFE_DRIVER = "testcafe";
|
|
@@ -758,6 +759,70 @@ core.registerNavigation(TESTCAFE_DRIVER, {
|
|
|
758
759
|
}
|
|
759
760
|
}
|
|
760
761
|
});
|
|
762
|
+
function responseMockClass() {
|
|
763
|
+
const probe = testcafe$1.RequestMock().onRequestTo(() => false).respond("");
|
|
764
|
+
return probe.mocks.values().next().value.constructor;
|
|
765
|
+
}
|
|
766
|
+
var UNREACHABLE = { hostname: "127.0.0.1", port: 9 };
|
|
767
|
+
var MockHook = class extends testcafe$1.RequestHook {
|
|
768
|
+
#dispatcher;
|
|
769
|
+
#ResponseMock = responseMockClass();
|
|
770
|
+
disposed = false;
|
|
771
|
+
constructor(dispatcher) {
|
|
772
|
+
super(void 0, {});
|
|
773
|
+
this.#dispatcher = dispatcher;
|
|
774
|
+
}
|
|
775
|
+
async onRequest(event) {
|
|
776
|
+
if (this.disposed) return;
|
|
777
|
+
const request = event._requestInfo;
|
|
778
|
+
const raw = {
|
|
779
|
+
method: request.method.toUpperCase(),
|
|
780
|
+
url: request.url,
|
|
781
|
+
headers: request.headers,
|
|
782
|
+
body: request.body !== void 0 && request.body.length > 0 ? new Uint8Array(request.body) : null,
|
|
783
|
+
kind: request.isAjax ? "fetch" : "other"
|
|
784
|
+
};
|
|
785
|
+
const result = await this.#dispatcher.dispatch(raw);
|
|
786
|
+
if (result.kind === "passthrough") return;
|
|
787
|
+
if (result.kind === "error") {
|
|
788
|
+
const options = event.requestOptions;
|
|
789
|
+
options.hostname = UNREACHABLE.hostname;
|
|
790
|
+
options.host = `${UNREACHABLE.hostname}:${UNREACHABLE.port}`;
|
|
791
|
+
options.port = UNREACHABLE.port;
|
|
792
|
+
options.protocol = "http:";
|
|
793
|
+
return;
|
|
794
|
+
}
|
|
795
|
+
const { reply } = result;
|
|
796
|
+
await event.setMock(
|
|
797
|
+
this.#ResponseMock.from({
|
|
798
|
+
body: reply.body === null ? "" : Buffer.from(reply.body),
|
|
799
|
+
statusCode: reply.status,
|
|
800
|
+
headers: reply.headers
|
|
801
|
+
})
|
|
802
|
+
);
|
|
803
|
+
}
|
|
804
|
+
async onResponse() {
|
|
805
|
+
}
|
|
806
|
+
};
|
|
807
|
+
async function install(t, dispatcher) {
|
|
808
|
+
const hook = new MockHook(dispatcher);
|
|
809
|
+
await t.addRequestHooks(hook);
|
|
810
|
+
return {
|
|
811
|
+
async dispose() {
|
|
812
|
+
hook.disposed = true;
|
|
813
|
+
await t.removeRequestHooks(hook).catch(() => {
|
|
814
|
+
});
|
|
815
|
+
}
|
|
816
|
+
};
|
|
817
|
+
}
|
|
818
|
+
mock.registerMockTransport(TESTCAFE_DRIVER, {
|
|
819
|
+
// Buffered, and no sockets: TestCafe's proxy offers neither a streamed
|
|
820
|
+
// response nor a hook on WebSockets.
|
|
821
|
+
capabilities: { streaming: false, websockets: false, harRecord: false },
|
|
822
|
+
// Hooks are attached per test, through the test's own controller.
|
|
823
|
+
key: (env) => env.t,
|
|
824
|
+
install: (env, dispatcher) => install(env.t, dispatcher)
|
|
825
|
+
});
|
|
761
826
|
|
|
762
827
|
// src/env.ts
|
|
763
828
|
function testcafe(t, options = {}) {
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/driver-id.ts","../src/errors.ts","../src/page-functions.ts","../src/session.ts","../src/keys.ts","../src/testcafe-query.ts","../src/env.ts"],"names":["reviveStrictViolation","ClientFunction","PAGE_API_GLOBAL","injectSource","Query","describeScope","checkTestIds","getConfig","timeoutFor","encodeSelector","harnessedTarget","TestCafeSelector","checkFileTarget","filesOnDisk","enabledFrom","checkedFrom","registerDriver","registerNavigation"],"mappings":";;;;;;;AACO,IAAM,eAAA,GAAkB;ACgB/B,IAAM,OAAA,GAAkC;AAAA,EACtC,GAAA,EAAK,oBAAA;AAAA,EACL,GAAA,EAAK,mBAAA;AAAA,EACL,GAAA,EAAK,sBAAA;AAAA,EACL,GAAA,EAAK,oBAAA;AAAA,EACL,GAAA,EAAK,0BAAA;AAAA,EACL,GAAA,EAAK,mCAAA;AAAA,EACL,GAAA,EAAK,uBAAA;AAAA,EACL,GAAA,EAAK,mCAAA;AAAA,EACL,GAAA,EAAK,sCAAA;AAAA,EACL,GAAA,EAAK,0CAAA;AAAA,EACL,GAAA,EAAK,iDAAA;AAAA,EACL,GAAA,EAAK,cAAA;AAAA,EACL,IAAA,EAAM;AACR,CAAA;AAEO,SAAS,UAAU,KAAA,EAAwB;AAChD,EAAA,IAAI,KAAA,YAAiB,KAAA,EAAO,OAAO,KAAA,CAAM,OAAA;AACzC,EAAA,MAAM,EAAE,MAAA,EAAO,GAAK,KAAA,IAAS,EAAC;AAC9B,EAAA,OAAO,OAAO,MAAA,KAAW,QAAA,GAAW,MAAA,GAAS,EAAA;AAC/C;AAWO,SAAS,OAAA,CAAQ,OAAgB,OAAA,EAAyB;AAC/D,EAAA,IAAI,KAAA,YAAiB,O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B,EAAE,QAAQ,eAAA,EAAiB,CAAA,EAAE,GAC7B,EAAE,MAAA,EAAQ,eAAA,EAAiB,CAAA,EAAG,OAAA,EAAS,QAAQ,OAAA,EAAQ;AAC7D","file":"index.cjs","sourcesContent":["/** Its own module so `env.ts` and `testcafe-query.ts` can share it without a cycle. */\nexport const TESTCAFE_DRIVER = 'testcafe'\n","import { reviveStrictViolation } from '@harnessed-ts/core'\n\n/** A TestCafe error is a plain object; `errMsg` is the page's own error, stringified. */\ninterface TestCafeError {\n code?: string\n errMsg?: string\n /** A JavaScript error the page itself raised. */\n errStack?: string\n /** TestCafe's own explanation, which some codes carry (why a node is invisible). */\n reason?: string\n}\n\n/**\n * What the TestCafe codes an action most often fails with mean, in a sentence.\n * TestCafe renders these only in its own reporter, so without this a failure\n * reads as nothing but a code.\n */\nconst REASONS: Record<string, string> = {\n E24: 'nothing matches it',\n E26: 'it is not visible',\n E27: 'it is not an element',\n E31: 'it is not editable',\n E36: 'TestCafe has no such key',\n E39: \"the iframe's content did not load\",\n E40: 'it is not an <iframe>',\n E42: \"the iframe's content did not load\",\n E43: 'the iframe it is in no longer exists',\n E44: 'the iframe it is in is no longer visible',\n E49: 'the page unloaded while TestCafe was reading it',\n E84: 'it timed out',\n E101: 'another element covers it',\n}\n\nexport function messageOf(error: unknown): string {\n if (error instanceof Error) return error.message\n const { errMsg } = (error ?? {}) as TestCafeError\n return typeof errMsg === 'string' ? errMsg : ''\n}\n\n/**\n * TestCafe rejects with plain objects. The specs, the page package and any\n * `catch` in a test expect an `Error` whose message is the cause — for an error\n * thrown in the page that is the resolver's own wording, so a strict-mode\n * violation reads the same here as under every other driver, and comes back as\n * core's `StrictModeViolation`.\n *\n * `context` says what was being attempted, as a verb phrase: `act on testId(x)`.\n */\nexport function toError(error: unknown, context?: string): Error {\n if (error instanceof Error) return error\n const { code, errMsg, errStack, reason } = (error ?? {}) as TestCafeError\n if (typeof errMsg === 'string') {\n return reviveStrictViolation(\n new Error(errMsg.replace(/^[A-Za-z]*Error: /, ''), { cause: error }),\n )\n }\n // Anything else is TestCafe's own failure, which it renders from a code; say\n // what the code means, and keep the code and the original object so its\n // report stays reachable.\n const what = context === undefined ? 'TestCafe failed' : `TestCafe could not ${context}`\n const known = code === undefined ? undefined : REASONS[code]\n const detail = typeof reason === 'string' && reason.trim() !== '' ? `: ${reason.trim()}` : ''\n const why = known === undefined ? '' : `: ${known}${detail}`\n const which = code === undefined ? '' : ` (TestCafe error ${code})`\n const page = typeof errStack === 'string' ? `: the page raised ${errStack.split('\\n')[0]}` : ''\n return new Error(`harnessed: ${what}${why}${which}${page}.`, { cause: error })\n}\n","import type { PageApi, PageApiOptions, WireSelector } from '@harnessed-ts/resolve/inject'\n\n/**\n * Code that runs in the browser, not in Node.\n *\n * TestCafe ships a client function to the page as its source text, so nothing\n * here may close over a module binding — every value it needs is an argument\n * or a dependency, and every helper is declared inside the function that uses\n * it. No `async` either: TestCafe refuses client functions that compile to a\n * regenerator, so waiting is written with `.then`.\n */\n\n/** Thrown in the page when the resolver is not there and no source came with the call. */\nexport const NOT_INJECTED = 'harnessed:not-injected'\n\n/** Every operation answered by one round trip through `pageCall`. */\nexport type PageOp =\n | 'count'\n | 'texts'\n | 'text'\n | 'value'\n | 'attribute'\n | 'enabled'\n | 'checked'\n | 'selected'\n | 'visible'\n | 'hidden'\n | 'resolve'\n | 'editable'\n | 'focus'\n | 'blur'\n | 'select'\n | 'box'\n | 'fileTarget'\n\n/**\n * How a single-target operation looks for its node. `now` answers at once,\n * with `absent` when nothing matches yet, so the driver polls from Node; `wait`\n * waits in the page for `options.timeout`, and is what the last poll uses so\n * that a target never found fails in the resolver's own words. `count` and\n * `texts` never wait in the page: they answer `absent` while their scope is\n * not on screen, whichever lookup is asked for.\n */\nexport type Lookup = 'now' | 'wait'\n\n/** What a page call answers with: the value, and the top-level URL it was read at. */\nexport interface PageResult {\n value: unknown\n href: string\n /** A `now` lookup, or a list's scope, found nothing to answer about yet. */\n absent?: true\n}\n\n/** What `select` takes: the values to pick, and the target named for its errors. */\nexport interface SelectArg {\n values: string[]\n target: string\n}\n\n/**\n * Whether a node can be typed into: `ok`, why not yet (`disabled`, `readonly`),\n * or — when it is not a text control at all — its tag, as `<div>`.\n */\nexport type Editable = 'ok' | 'disabled' | 'readonly' | `<${string}>`\n\n/**\n * One client function for every read: compiled once per test, called with the\n * operation as an argument.\n *\n * `source` is the resolver's injectable build, or `null`. A document that lacks\n * the resolver installs it from the source in the same round trip; without a\n * source it refuses, and the driver calls again with one. `new Function` rather\n * than `eval`: TestCafe rewrites `eval` to process the code it runs, which costs\n * several times what installing the build does.\n *\n * The resolver is looked up in the top-most window that has it, so a call made\n * while TestCafe is switched into an iframe still resolves from the page's own\n * document — the scope chain crosses frames itself, exactly as it does under\n * every other resolver-based driver.\n */\nexport function pageCall(\n name: string,\n source: string | null,\n op: PageOp,\n scope: WireSelector[],\n selector: WireSelector,\n options: PageApiOptions,\n arg: unknown,\n lookup: Lookup,\n): PageResult | Promise<PageResult> {\n let api: PageApi | null = null\n let home: Window = window\n let current: Window = window\n for (;;) {\n try {\n const found = (current as unknown as Record<string, PageApi | undefined>)[name]\n if (found !== undefined) {\n api = found\n home = current\n }\n } catch {\n // A cross-origin ancestor: the resolver could not cross into it anyway.\n break\n }\n if (current === current.parent) break\n current = current.parent\n }\n if (api === null) {\n // NOT_INJECTED, spelled out: page code cannot reach a module constant.\n if (source === null) throw new Error('harnessed:not-injected')\n // The build installs itself as a global of the window it runs in.\n new Function(source)()\n api = (window as unknown as Record<string, PageApi>)[name]\n home = window\n }\n const resolver: PageApi = api\n const href = home.location.href\n const done = (value: unknown): PageResult => ({ value, href })\n\n // The shared layout rule, judged in each element's own document, carried on\n // through every iframe the scope entered: a hidden frame hides its content.\n const isVisible = (element: Element): boolean => {\n let node: Element | null = element\n while (node !== null) {\n if (!resolver.visible(node)) return false\n const view: Window | null = node.ownerDocument.defaultView\n node = view === null || view === home ? null : view.frameElement\n }\n return true\n }\n\n // The single target now, for a yes/no question: `null` when it is not there,\n // including an index past the last match. Everything else the resolver\n // raises still throws — ambiguity, a frame that cannot be entered, a\n // selector it refuses — since none of them is an answer.\n const present = (): Element | null => {\n try {\n return resolver.oneNow(null, scope, selector, options)\n } catch (error) {\n const message = (error as { message?: unknown } | null)?.message\n if (typeof message === 'string' && /^harnessed: index \\d+ is out of range/.test(message)) {\n return null\n }\n throw error\n }\n }\n\n // A single target. `now` hands back `null` for \"not there yet\"; the driver\n // polls, so a wait never holds TestCafe's one command queue for long.\n const target = (): Promise<Element | null> =>\n lookup === 'now'\n ? Promise.resolve(resolver.oneNow(null, scope, selector, options))\n : resolver.one(null, scope, selector, options)\n const withTarget = (read: (node: Element) => unknown): Promise<PageResult> =>\n target().then(node => (node === null ? { value: null, href, absent: true } : done(read(node))))\n\n // Every match now, or `null` while a link of the scope is not on screen yet —\n // the driver polls that, as it does a single target. The last link is looked\n // up as the element it names, so \"absent\" is told apart from what\n // `allNow` folds into an empty list: an ambiguous or out-of-range link, which\n // holds nothing at once, as `count` says under every driver. A frame that\n // cannot be entered still throws.\n const list = (): Element[] | null => {\n if (scope.length > 0) {\n const last = Object.assign({}, scope[scope.length - 1], { frame: false })\n let link: Element | null\n try {\n link = resolver.oneNow(null, scope.slice(0, -1), last, options)\n } catch (error) {\n if ((error as { name?: string } | null)?.name === 'FrameEntryError') throw error\n return []\n }\n if (link === null) return null\n }\n // `nth` picks one match, or none: a list read through `nth()` is that one.\n return resolver.allNow(null, scope, selector, options)\n }\n const withList = (read: (matches: Element[]) => unknown): PageResult => {\n const matches = list()\n return matches === null ? { value: null, href, absent: true } : done(read(matches))\n }\n\n switch (op) {\n case 'count':\n return withList(matches => matches.length)\n case 'texts':\n return withList(matches => matches.map(node => (node.textContent ?? '').trim()))\n case 'visible': {\n const node = present()\n return done(node !== null && isVisible(node))\n }\n case 'hidden': {\n const node = present()\n return done(node === null || !isVisible(node))\n }\n case 'text':\n return withTarget(node => (node.textContent ?? '').trim())\n case 'value':\n return withTarget(node => (node as HTMLInputElement).value ?? '')\n case 'attribute':\n return withTarget(node => node.getAttribute(arg as string))\n case 'enabled':\n // `disabled` is inherited from an ancestor fieldset; `:disabled` sees that\n // where the element's own attribute does not.\n return withTarget(node => [\n (node as HTMLInputElement).disabled === true || node.closest(':disabled') !== null,\n node.getAttribute('aria-disabled'),\n ])\n case 'checked':\n return withTarget(node => [\n node.getAttribute('aria-checked'),\n Boolean((node as HTMLInputElement).checked),\n ])\n case 'selected':\n return withTarget(node =>\n Array.prototype.map.call(\n (node as HTMLSelectElement).selectedOptions ?? [],\n (option: HTMLOptionElement) => option.value,\n ),\n )\n case 'resolve':\n return withTarget(() => null)\n case 'fileTarget':\n return withTarget(node => resolver.fileTarget(node))\n case 'box':\n // Measured in the node's own document, then offset by each frame up to `home`.\n return withTarget(node => {\n const box = resolver.box(node)\n if (box === null) return { x: 0, y: 0, width: 0, height: 0 }\n let view: Window | null = node.ownerDocument.defaultView\n while (view !== null && view !== home) {\n const frame: Element | null = view.frameElement\n if (frame === null) break\n const origin = resolver.origin(frame)\n box.x += origin.x\n box.y += origin.y\n view = frame.ownerDocument.defaultView\n }\n return box\n })\n case 'editable':\n // TestCafe's typeText types into the first editable descendant of a\n // wrapper, and does nothing at all to a disabled or readonly control; both\n // are refused before it is asked. So is an <input> that takes no text — a\n // checkbox, a file — which Playwright's fill refuses too, and a control\n // `aria-disabled` marks, which `isEnabled()` reads as disabled.\n return withTarget((node): Editable => {\n const input = node.localName === 'input'\n const control = input || node.localName === 'textarea'\n if (!control && !(node as HTMLElement).isContentEditable) return `<${node.localName}>`\n if (input) {\n const type = (node as HTMLInputElement).type.toLowerCase()\n // Typed into, or set as a value: the types Playwright's fill takes.\n const fillable =\n /^(?:|email|number|password|search|tel|text|url|color|date|time|datetime|datetime-local|month|range|week)$/\n if (!fillable.test(type)) return `<input type=\"${type}\">`\n }\n if (control && node.matches(':disabled')) return 'disabled'\n if (node.getAttribute('aria-disabled') === 'true') return 'disabled'\n if (control && (node as HTMLInputElement).readOnly) return 'readonly'\n return 'ok'\n })\n case 'focus':\n return withTarget(node => {\n ;(node as HTMLElement).focus()\n return null\n })\n case 'blur':\n return withTarget(node => {\n ;(node as HTMLElement).blur()\n return null\n })\n case 'select':\n return withTarget(node => {\n const { values, target: named } = arg as SelectArg\n if (node.localName !== 'select') {\n throw new Error(\n `harnessed: selectOption() needs a <select>, but ${named} is a <${node.localName}>.`,\n )\n }\n const element = node as HTMLSelectElement\n const all: HTMLOptionElement[] = Array.prototype.slice.call(element.options)\n // By value first, then by label — what Playwright's selectOption matches.\n const picked = values.map(value => {\n const option =\n all.find(candidate => candidate.value === value) ??\n all.find(candidate => candidate.label === value)\n if (option === undefined) {\n throw new Error(`harnessed: no <option> of ${named} matches \"${value}\".`)\n }\n return option\n })\n if (!element.multiple && picked.length > 1) {\n throw new Error(\n `harnessed: selectOption() was given several values for ${named}, a single-select.`,\n )\n }\n // Replaces the selection, as Playwright does, rather than adding to it.\n for (const option of all) option.selected = picked.includes(option)\n const view = element.ownerDocument.defaultView ?? window\n element.dispatchEvent(new view.Event('input', { bubbles: true, composed: true }))\n element.dispatchEvent(new view.Event('change', { bubbles: true }))\n return null\n })\n }\n}\n\n/**\n * The node an action targets, for a TestCafe `Selector`. Synchronous, as a\n * selector's init function must be: \"not there yet\" is an empty list and\n * TestCafe's own retry does the waiting. An empty list rather than `null` keeps\n * the return within TestCafe's declared selector types.\n */\nexport function pickTarget(): Element[] {\n // Dependencies, declared for the type checker. TestCafe defines each one as a\n // variable in the function's scope before running it.\n const { name, scope, selector, options, control } = harnessedTarget\n let api: PageApi | null = null\n let current: Window = window\n for (;;) {\n try {\n const found = (current as unknown as Record<string, PageApi | undefined>)[name]\n if (found !== undefined) api = found\n } catch {\n break\n }\n if (current === current.parent) break\n current = current.parent\n }\n if (api === null) return []\n const node = api.oneNow(null, scope, selector, options)\n if (node === null) return []\n // An upload through a <label> acts on the input it labels.\n const labelled = control === true && node.localName === 'label'\n const target = labelled ? (node as HTMLLabelElement).control : node\n return target === null ? [] : [target]\n}\n\n/** The shape of `pickTarget`'s one dependency. */\nexport interface TargetDependency {\n name: string\n scope: WireSelector[]\n selector: WireSelector\n options: PageApiOptions\n /** Pick a label's control instead of the label. */\n control?: boolean\n}\n\ndeclare const harnessedTarget: TargetDependency\n\n/** The current top-level URL, without needing the resolver. */\nexport function currentHref(): string {\n return window.location.href\n}\n\n/** The browser's platform, which decides what `ControlOrMeta` presses. */\nexport function browserPlatform(): string {\n return window.navigator.platform\n}\n","import { ClientFunction } from 'testcafe'\nimport { injectSource, PAGE_API_GLOBAL } from '@harnessed-ts/resolve/inject'\nimport type { PageApiOptions, WireSelector } from '@harnessed-ts/resolve/inject'\nimport { messageOf, toError } from './errors'\nimport { browserPlatform, currentHref, NOT_INJECTED, pageCall } from './page-functions'\nimport type { Lookup, PageOp, PageResult } from './page-functions'\n\n/**\n * What the driver keeps per test. Keyed by the controller: TestCafe hands every\n * test its own, and everything here belongs to exactly one test.\n */\nexport interface Session {\n /**\n * The top-level URL as of the last call that touched the page. `currentUrl`\n * is synchronous and TestCafe can only read the page asynchronously, so every\n * round trip brings the URL back with it and every action and navigation\n * refreshes it afterwards.\n */\n href: string | undefined\n /**\n * One round trip through the shared resolver. Under a `now` lookup a\n * single-target operation answers `absent` rather than waiting for its node.\n */\n read(\n op: PageOp,\n scope: WireSelector[],\n selector: WireSelector,\n options: PageApiOptions,\n arg: unknown,\n lookup: Lookup,\n ): Promise<PageResult>\n /** Re-read the top-level URL; needs no resolver, so it is safe after a navigation. */\n locate(): Promise<string>\n /** The browser's `navigator.platform`, read once: it does not change mid-test. */\n platform(): Promise<string>\n /**\n * Runs an operation that may switch TestCafe into an iframe. Switching is\n * state on the controller, so two such operations must never interleave —\n * and nor may a plain action, whose selector would run in the wrong window.\n */\n exclusive<T>(run: () => Promise<T>): Promise<T>\n /** The page was replaced: the next call carries the resolver with it. */\n navigated(): void\n}\n\nconst sessions = new WeakMap<TestController, Session>()\n\n/**\n * The `t` exported by 'testcafe' is one shared proxy that looks up whichever\n * test is running when it is used. A client function bound to it does not\n * bind, and a session keyed by it would be shared by every test — so only the\n * controller a test function is handed, which carries its own test run, will do.\n */\nexport function assertOwnController(t: TestController): void {\n if (typeof (t as { testRun?: unknown }).testRun !== 'object') {\n throw new Error(\n \"harnessed: pass the test function's own t, not the one imported from 'testcafe': \" +\n \"test('…', async t => { … testcafe(t) … }).\",\n )\n }\n}\n\n/**\n * The resolver, as TestCafe sees it. Client functions are compiled when they are\n * created, so they are built once per test and take the per-call values as\n * arguments. `boundTestRun` ties them to the test explicitly: TestCafe's own\n * test-run tracking follows its promise patches, which native `await` in a\n * compiled library does not go through.\n */\nexport function sessionFor(t: TestController): Session {\n const existing = sessions.get(t)\n if (existing !== undefined) return existing\n assertOwnController(t)\n\n const call = ClientFunction(pageCall, { boundTestRun: t })\n const href = ClientFunction(currentHref, { boundTestRun: t })\n const readPlatform = ClientFunction(browserPlatform, { boundTestRun: t })\n let platform: string | undefined\n let queue: Promise<unknown> = Promise.resolve()\n // A session starts on a page the driver has not seen, so its first call\n // carries the resolver. After that the source is sent only when the page may\n // be a fresh document — after a navigation, or once the URL has changed — and\n // when a call finds the resolver missing anyway.\n let carrySource = true\n const seen = (url: string): void => {\n if (session.href !== undefined && url !== session.href) carrySource = true\n session.href = url\n }\n\n const session: Session = {\n href: undefined,\n async read(op, scope, selector, options, arg, lookup) {\n // The page answers with a value or a promise of one; awaiting flattens both.\n const run = async (source: string | null): Promise<PageResult> =>\n await call(PAGE_API_GLOBAL, source, op, scope, selector, options, arg, lookup)\n let result: PageResult\n try {\n result = await run(carrySource ? injectSource() : null)\n } catch (error) {\n if (!messageOf(error).includes(NOT_INJECTED)) throw toError(error)\n try {\n result = await run(injectSource())\n } catch (retried) {\n throw toError(retried)\n }\n }\n carrySource = false\n session.href = result.href\n return result\n },\n async locate() {\n let current: string\n try {\n current = await href()\n } catch (error) {\n throw toError(error)\n }\n seen(current)\n return current\n },\n async platform() {\n if (platform === undefined) {\n try {\n platform = await readPlatform()\n } catch (error) {\n throw toError(error)\n }\n }\n return platform\n },\n navigated() {\n carrySource = true\n },\n exclusive(run) {\n const next = queue.then(run, run)\n queue = next.catch(() => undefined)\n return next\n },\n }\n sessions.set(t, session)\n return session\n}\n","/**\n * Playwright key names, which the shared `press()` takes, onto TestCafe's\n * `pressKey` names. TestCafe lowercases its own and shortens a few; a printable\n * character passes through, except a space, which `pressKey` would read as a\n * separator between two keys.\n */\nconst NAMES: Record<string, string> = {\n ' ': 'space',\n Space: 'space',\n Enter: 'enter',\n Tab: 'tab',\n Backspace: 'backspace',\n Delete: 'delete',\n Escape: 'esc',\n Insert: 'ins',\n Home: 'home',\n End: 'end',\n PageUp: 'pageup',\n PageDown: 'pagedown',\n ArrowUp: 'up',\n ArrowDown: 'down',\n ArrowLeft: 'left',\n ArrowRight: 'right',\n Control: 'ctrl',\n Shift: 'shift',\n Alt: 'alt',\n Meta: 'meta',\n CapsLock: 'capslock',\n}\n\n/**\n * Every multi-character name TestCafe's `pressKey` accepts: its modifiers and\n * its special keys. Anything else it rejects with an opaque \"incorrect key\"\n * error, so a name outside this set is refused here first, with the key named.\n */\nconst SUPPORTED = new Set([\n 'alt',\n 'ctrl',\n 'meta',\n 'shift',\n 'backspace',\n 'capslock',\n 'delete',\n 'down',\n 'end',\n 'enter',\n 'esc',\n 'home',\n 'ins',\n 'left',\n 'pagedown',\n 'pageup',\n 'right',\n 'space',\n 'tab',\n 'up',\n])\n\n/** A chord's parts. A lone `+` is the plus key, and `Control++` holds Control over it. */\nfunction parts(key: string): string[] {\n if (key.length <= 1) return [key]\n const plus = key.endsWith('++')\n const split = (plus ? key.slice(0, -2) : key).split('+')\n return plus ? [...split, '+'] : split\n}\n\nfunction toPart(part: string, platform: string | undefined): string | undefined {\n if (part === 'ControlOrMeta') {\n return platform !== undefined && /^(?:Mac|iP)/.test(platform) ? 'meta' : 'ctrl'\n }\n const code = /^(?:Key([A-Z])|Digit(\\d))$/.exec(part)\n if (code !== null) return (code[1] ?? code[2]!).toLowerCase()\n const named = NAMES[part]\n if (named !== undefined) return named\n if (part.length === 1) return part\n return SUPPORTED.has(part) ? part : undefined\n}\n\n/**\n * `Control+Shift+ArrowLeft` → `ctrl+shift+left`, `ControlOrMeta+KeyA` →\n * `meta+a` in a browser on macOS. Throws before anything is pressed for a key\n * TestCafe has no way to send, such as a function key.\n *\n * `platform` is the browser's `navigator.platform`, which only `ControlOrMeta`\n * reads: the browser may run on another machine than the test runner.\n */\nexport function toTestCafeKey(key: string, platform?: string): string {\n return parts(key)\n .map(part => {\n const mapped = toPart(part, platform)\n if (mapped === undefined) {\n throw new Error(\n `harnessed: press() cannot send \"${key}\" under TestCafe, which has no \"${part}\" key.`,\n )\n }\n return mapped\n })\n .join('+')\n}\n","import { Selector as TestCafeSelector } from 'testcafe'\nimport { Query, registerDriver, registerNavigation } from '@harnessed-ts/core'\nimport type { BoundingBox, EnvConfig, FileTarget, Selector } from '@harnessed-ts/core'\nimport type { WaitOptions, WaitState } from '@harnessed-ts/core'\nimport {\n checkedFrom,\n checkFileTarget,\n checkTestIds,\n describeScope,\n enabledFrom,\n getConfig,\n timeoutFor,\n} from '@harnessed-ts/core'\nimport { encodeSelector, filesOnDisk, PAGE_API_GLOBAL } from '@harnessed-ts/resolve/inject'\nimport type { PageApiOptions } from '@harnessed-ts/resolve/inject'\nimport { TESTCAFE_DRIVER } from './driver-id'\nimport type { TestCafeEnv } from './env'\nimport { toError } from './errors'\nimport { toTestCafeKey } from './keys'\nimport { pickTarget } from './page-functions'\nimport type { Editable, PageOp, SelectArg, TargetDependency } from './page-functions'\nimport { sessionFor } from './session'\nimport type { Session } from './session'\n\n/** How often a wait re-asks the page. Each ask is one short round trip. */\nconst POLL_MS = 50\n\n/**\n * The last poll of a single-target read waits in the page this long, so that a\n * target never found fails in the resolver's own words.\n */\nconst LAST_WAIT_MS = POLL_MS\n\n/** Why a text control cannot be typed into yet. */\nconst NOT_EDITABLE: Record<'disabled' | 'readonly', string> = {\n disabled: 'it is disabled',\n readonly: 'it is readonly',\n}\n\n/** A frame link's own element: the iframe itself, not the document inside it. */\nfunction unframed(link: Selector): Selector {\n return { ...link, frame: undefined }\n}\n\nfunction delay(ms: number): Promise<void> {\n return new Promise(resolve => setTimeout(resolve, ms))\n}\n\n/**\n * TestCafe driver. Every lookup runs the shared resolver inside the page, so\n * role, label, strictness, absence and frame semantics are the dom driver's by\n * construction; TestCafe performs the actions.\n *\n * Reads are client functions that return values, which can cross into a\n * same-origin frame from the top-level window. Actions need a TestCafe\n * `Selector`, whose node must belong to the window TestCafe is switched into —\n * so an action under a frame switches into each iframe in turn, acts, and\n * always switches back.\n *\n * TestCafe runs one command at a time, so nothing here waits inside the page\n * for long: a wait held open there would block every other call until it\n * settled — including after a caller such as `isReady()` has stopped\n * listening. Single-target and list reads poll from Node instead.\n */\nexport class TestCafeQuery extends Query {\n constructor(\n private readonly t: TestController,\n scope: readonly Selector[],\n selector: Selector,\n ) {\n super(scope, selector)\n }\n\n protected override clone(selector: Selector): Query {\n return new TestCafeQuery(this.t, this.scope, selector)\n }\n\n private get session(): Session {\n return sessionFor(this.t)\n }\n\n private get described(): string {\n return describeScope(this.scope, this.selector)\n }\n\n /** Runtime config travels with every call: the page cannot see `configure()`. */\n private pageOptions(timeout?: number): PageApiOptions {\n // Refused here, so the page never folds a refusal into \"nothing there\".\n checkTestIds(this.scope, this.selector)\n return { testIdAttribute: getConfig().testIdAttribute, timeout: timeoutFor(timeout) }\n }\n\n /** One round trip, answered at once. */\n private async read<T>(op: PageOp, options?: WaitOptions, arg?: unknown): Promise<T> {\n const result = await this.session.read(\n op,\n this.scope.map(encodeSelector),\n encodeSelector(this.selector),\n this.pageOptions(options?.timeout),\n arg,\n 'now',\n )\n return result.value as T\n }\n\n /**\n * A list operation, polled from Node until its scope is there, as every\n * driver waits for the scope; the list itself answers at once. A scope that\n * never appears holds nothing, so the deadline answers `empty` rather than\n * failing.\n */\n private async readList<T>(op: 'count' | 'texts', empty: T): Promise<T> {\n const timeout = timeoutFor()\n const deadline = Date.now() + timeout\n const scope = this.scope.map(encodeSelector)\n const selector = encodeSelector(this.selector)\n for (;;) {\n const result = await this.session.read(\n op,\n scope,\n selector,\n this.pageOptions(timeout),\n undefined,\n 'now',\n )\n if (result.absent !== true) return result.value as T\n if (Date.now() >= deadline) return empty\n await delay(POLL_MS)\n }\n }\n\n /**\n * A single-target operation, polled from Node until its node is there. The\n * last poll waits briefly in the page, so a target that never appears fails\n * with the resolver's own message; a strict violation fails on the first.\n */\n private async readOne<T>(op: PageOp, options?: WaitOptions, arg?: unknown): Promise<T> {\n const timeout = timeoutFor(options?.timeout)\n const deadline = Date.now() + timeout\n const scope = this.scope.map(encodeSelector)\n const selector = encodeSelector(this.selector)\n for (;;) {\n const last = Date.now() >= deadline\n const result = await this.session.read(\n op,\n scope,\n selector,\n this.pageOptions(last ? LAST_WAIT_MS : timeout),\n arg,\n last ? 'wait' : 'now',\n )\n if (result.absent !== true) return result.value as T\n await delay(POLL_MS)\n }\n }\n\n /** A TestCafe selector for one link of the chain, resolved by the same resolver. */\n private selectorFor(\n scope: readonly Selector[],\n selector: Selector,\n timeout: number,\n control = false,\n ): ReturnType<typeof TestCafeSelector> {\n const harnessedTarget: TargetDependency = {\n name: PAGE_API_GLOBAL,\n scope: scope.map(encodeSelector),\n selector: encodeSelector(selector),\n options: this.pageOptions(timeout),\n control,\n }\n return TestCafeSelector(pickTarget, {\n dependencies: { harnessedTarget },\n boundTestRun: this.t,\n timeout,\n })\n }\n\n /**\n * Runs a TestCafe action against this query's node.\n *\n * The resolver answers first, from the page: that is what makes a strict\n * violation, a missing target or a frame marker on a non-iframe fail at once\n * with the shared wording. An error thrown inside a TestCafe selector is\n * instead retried until the selector times out, and a strict violation never\n * becomes a single match by waiting. `prepare` then refuses what TestCafe\n * would get silently wrong, within the same deadline. After that, TestCafe's\n * own selectors only have to wait for the node to be actionable — each frame\n * switch and the action given what is left of that one deadline, so the\n * whole operation fails within the caller's timeout.\n */\n private act(\n run: (target: ReturnType<typeof TestCafeSelector>, deadline: number) => Promise<unknown>,\n options?: WaitOptions,\n prepare?: (deadline: number, timeout: number) => Promise<void>,\n control = false,\n ): Promise<void> {\n return this.session.exclusive(async () => {\n const timeout = timeoutFor(options?.timeout)\n const deadline = Date.now() + timeout\n await this.readOne('resolve', { timeout })\n if (prepare !== undefined) await prepare(deadline, timeout)\n const remaining = (): number => Math.max(deadline - Date.now(), 0)\n const frames = this.scope.flatMap((link, index) => (link.frame === true ? [index] : []))\n try {\n for (const index of frames) {\n await this.t.switchToIframe(\n this.selectorFor(this.scope.slice(0, index), unframed(this.scope[index]!), remaining()),\n )\n }\n await run(this.selectorFor(this.scope, this.selector, remaining(), control), deadline)\n } catch (error) {\n throw toError(error, `act on ${this.described}`)\n } finally {\n if (frames.length > 0) await this.t.switchToMainWindow()\n }\n // An action can navigate; `currentUrl` must not report the page it left.\n await this.session.locate()\n })\n }\n\n /**\n * Waits until the target can be typed into, and refuses one that never can.\n * TestCafe's typeText would otherwise do nothing to a disabled or readonly\n * control, and type into the first editable descendant of a wrapper.\n */\n private async editable(action: 'fill' | 'clear', deadline: number, timeout: number) {\n for (;;) {\n const state = await this.readOne<Editable>('editable', {\n timeout: Math.max(deadline - Date.now(), 0),\n })\n if (state === 'ok') return\n if (state !== 'disabled' && state !== 'readonly') {\n throw new Error(\n `harnessed: ${action}() needs an <input>, <textarea> or [contenteditable] element, but ${this.described} is a ${state}.`,\n )\n }\n if (Date.now() >= deadline) {\n throw new Error(\n `harnessed: ${action}() could not edit ${this.described} within ${timeout}ms: ${NOT_EDITABLE[state]}.`,\n )\n }\n await delay(POLL_MS)\n }\n }\n\n // --- interactions -------------------------------------------------------\n\n override async click(options?: WaitOptions): Promise<void> {\n await this.act(target => this.t.click(target), options)\n }\n\n override async fill(value: string, options?: WaitOptions): Promise<void> {\n await this.replaceValue('fill', value, options)\n }\n\n override async clear(options?: WaitOptions): Promise<void> {\n await this.replaceValue('clear', '', options)\n }\n\n /**\n * Replaces the value, as Playwright's `fill()` does. `paste` sets the whole\n * value in one input event rather than typing character by character; an\n * empty value — which typeText refuses — selects what is there and deletes\n * it, so `fill('')` and `clear()` are one operation with one set of checks.\n */\n private async replaceValue(\n action: 'fill' | 'clear',\n value: string,\n options?: WaitOptions,\n ): Promise<void> {\n await this.act(\n target =>\n value === ''\n ? this.t.selectText(target).pressKey('delete')\n : this.t.typeText(target, value, { replace: true, paste: true }),\n options,\n (deadline, timeout) => this.editable(action, deadline, timeout),\n )\n }\n\n override async check(options?: WaitOptions): Promise<void> {\n if (!(await this.isChecked(options))) await this.click(options)\n }\n\n override async uncheck(options?: WaitOptions): Promise<void> {\n if (await this.isChecked(options)) await this.click(options)\n }\n\n /**\n * TestCafe has no select API, and driving a native dropdown by clicking is\n * platform-dependent. The selection is set in the page and `input` and\n * `change` dispatched — what Playwright's selectOption does — replacing any\n * existing selection of a multi-select. A change handler can navigate, so\n * this is an action like any other: it takes its turn, and re-reads the URL.\n */\n override async selectOption(value: string | string[], options?: WaitOptions): Promise<void> {\n const arg: SelectArg = {\n values: Array.isArray(value) ? value : [value],\n target: this.described,\n }\n await this.session.exclusive(async () => {\n await this.readOne('select', options, arg)\n await this.session.locate()\n })\n }\n\n /**\n * TestCafe sets files only from paths, so each File is written to disk first\n * (see `filesOnDisk`): the name and bytes arrive, and the type is inferred\n * from the extension.\n */\n override async upload(files: File | File[], options?: WaitOptions): Promise<void> {\n const list = Array.isArray(files) ? files : [files]\n let paths: string[] = []\n await this.act(\n target => this.t.setFilesToUpload(target, paths),\n options,\n async (deadline: number) => {\n const target = await this.readOne<FileTarget>('fileTarget', {\n timeout: Math.max(deadline - Date.now(), 0),\n })\n checkFileTarget(target, list.length, this.scope, this.selector)\n paths = await filesOnDisk(list)\n },\n true,\n )\n }\n\n override async hover(options?: WaitOptions): Promise<void> {\n await this.act(target => this.t.hover(target), options)\n }\n\n override async focus(options?: WaitOptions): Promise<void> {\n await this.readOne('focus', options)\n }\n\n override async blur(options?: WaitOptions): Promise<void> {\n await this.readOne('blur', options)\n }\n\n /**\n * Focuses the target first, as Playwright's press does; keys go to the\n * focused node. The key is checked before anything happens, and the focus\n * spends only what is left of the one timeout. `ControlOrMeta` follows the\n * browser's platform, which may not be the test runner's.\n */\n override async press(key: string, options?: WaitOptions): Promise<void> {\n const platform = key.includes('ControlOrMeta') ? await this.session.platform() : undefined\n const keys = toTestCafeKey(key, platform)\n await this.act(async (_target, deadline) => {\n await this.readOne('focus', { timeout: Math.max(deadline - Date.now(), 0) })\n await this.t.pressKey(keys)\n }, options)\n }\n\n // --- observations -------------------------------------------------------\n\n override async text(options?: WaitOptions): Promise<string> {\n return this.readOne<string>('text', options)\n }\n\n override async inputValue(options?: WaitOptions): Promise<string> {\n return this.readOne<string>('value', options)\n }\n\n override async attribute(name: string, options?: WaitOptions): Promise<string | null> {\n return this.readOne<string | null>('attribute', options, name)\n }\n\n override async boundingBox(options?: WaitOptions): Promise<BoundingBox> {\n return this.readOne<BoundingBox>('box', options)\n }\n\n /** Answers at once, as Playwright's does: an absent target is not visible. */\n override async isVisible(options?: WaitOptions): Promise<boolean> {\n return this.read<boolean>('visible', options)\n }\n\n override async isEnabled(options?: WaitOptions): Promise<boolean> {\n const [disabled, ariaDisabled] = await this.readOne<[boolean, string | null]>(\n 'enabled',\n options,\n )\n return enabledFrom(disabled, ariaDisabled)\n }\n\n override async isChecked(options?: WaitOptions): Promise<boolean> {\n const [aria, native] = await this.readOne<[string | null, boolean]>('checked', options)\n return checkedFrom(aria, native)\n }\n\n override async selectedOptions(options?: WaitOptions): Promise<string[]> {\n return this.readOne<string[]>('selected', options)\n }\n\n // --- waiting ------------------------------------------------------------\n\n /** Polls from Node rather than waiting inside the page, as every read here does. */\n override async waitFor(state: WaitState, options?: WaitOptions): Promise<void> {\n const timeout = timeoutFor(options?.timeout)\n const deadline = Date.now() + timeout\n for (;;) {\n if (await this.read<boolean>(state, { timeout })) return\n if (Date.now() >= deadline) {\n throw new Error(`harnessed: ${this.described} did not become ${state} within ${timeout}ms.`)\n }\n await delay(POLL_MS)\n }\n }\n\n /** Waits for the scope chain, as every driver does; the count itself answers at once. */\n override async count(): Promise<number> {\n return this.readList<number>('count', 0)\n }\n\n /** Every match read in one round trip, once the scope is there; trimmed to match `text()`. */\n override async texts(): Promise<string[]> {\n return this.readList<string[]>('texts', [])\n }\n}\n\nregisterDriver(TESTCAFE_DRIVER, (env: EnvConfig, scope, selector) => {\n return new TestCafeQuery((env as TestCafeEnv).t, scope, selector)\n})\n\n/**\n * This driver can navigate. A relative path resolves against the env's\n * `baseUrl` when it has one, and otherwise against the page the test is on.\n */\nregisterNavigation(TESTCAFE_DRIVER, {\n async goto(env, url) {\n const { t, baseUrl } = env as TestCafeEnv\n const session = sessionFor(t)\n const base = baseUrl ?? (await session.locate())\n let target: string\n try {\n target = new URL(url, base).href\n } catch {\n throw new Error(\n `harnessed: cannot resolve \"${url}\" against ${base}. Navigate to the app first, or pass ` +\n '`baseUrl` to testcafe(t, { baseUrl }).',\n )\n }\n try {\n await t.navigateTo(target)\n } catch (error) {\n throw toError(error, `navigate to ${target}`)\n } finally {\n // A new document, which has no resolver until one is sent.\n session.navigated()\n }\n await session.locate()\n },\n currentUrl(env) {\n const { href } = sessionFor((env as TestCafeEnv).t)\n if (href === undefined) {\n throw new Error(\n 'harnessed: the testcafe driver has not read the URL yet. TestCafe reads the page ' +\n 'asynchronously, so the URL is learned from goto() and from every harness call — ' +\n 'make one of those first.',\n )\n }\n return href\n },\n async waitForUrl(env, matches, timeout) {\n const session = sessionFor((env as TestCafeEnv).t)\n const deadline = Date.now() + timeout\n for (;;) {\n const href = await session.locate()\n if (matches(new URL(href))) return\n if (Date.now() >= deadline) {\n throw new Error(`harnessed: the URL did not match within ${timeout}ms; it is ${href}.`)\n }\n await delay(POLL_MS)\n }\n },\n})\n","/// <reference types=\"testcafe\" />\nimport type { EnvConfig } from '@harnessed-ts/core'\nimport { TESTCAFE_DRIVER } from './driver-id'\nimport { assertOwnController } from './session'\n// Side effect: constructing an env is the moment the driver has to be registered.\nimport './testcafe-query'\n\nexport { TESTCAFE_DRIVER }\n\nexport interface TestCafeEnv extends EnvConfig {\n readonly driver: typeof TESTCAFE_DRIVER\n /** The test's controller. Every action goes through it, so an env is per test. */\n readonly t: TestController\n /**\n * What a page's relative path resolves against in `goto()`. Without it, the\n * page the test is on — which is the fixture's page when a test starts.\n */\n readonly baseUrl?: string\n}\n\nexport interface TestCafeEnvOptions {\n baseUrl?: string\n}\n\n/**\n * Builds the env a harness is constructed with under TestCafe. `t` is the one\n * the test function is handed — not the shared `t` exported by 'testcafe',\n * which belongs to no one test.\n */\nexport function testcafe(t: TestController, options: TestCafeEnvOptions = {}): TestCafeEnv {\n assertOwnController(t)\n return options.baseUrl === undefined\n ? { driver: TESTCAFE_DRIVER, t }\n : { driver: TESTCAFE_DRIVER, t, baseUrl: options.baseUrl }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/driver-id.ts","../src/errors.ts","../src/page-functions.ts","../src/session.ts","../src/keys.ts","../src/testcafe-query.ts","../src/mock-transport.ts","../src/env.ts"],"names":["reviveStrictViolation","ClientFunction","PAGE_API_GLOBAL","injectSource","Query","describeScope","checkTestIds","getConfig","timeoutFor","encodeSelector","harnessedTarget","TestCafeSelector","checkFileTarget","filesOnDisk","enabledFrom","checkedFrom","registerDriver","registerNavigation","RequestMock","RequestHook","registerMockTransport"],"mappings":";;;;;;;;AACO,IAAM,eAAA,GAAkB;ACgB/B,IAAM,OAAA,GAAkC;AAAA,EACtC,GAAA,EAAK,oBAAA;AAAA,EACL,GAAA,EAAK,mBAAA;AAAA,EACL,GAAA,EAAK,sBAAA;AAAA,EACL,GAAA,EAAK,oBAAA;AAAA,EACL,GAAA,EAAK,0BAAA;AAAA,EACL,GAAA,EAAK,mCAAA;AAAA,EACL,GAAA,EAAK,uBAAA;AAAA,EACL,GAAA,EAAK,mCAAA;AAAA,EACL,GAAA,EAAK,sCAAA;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AAA;AAChB,MAAA,MAAM,CAAA,CAAE,kBAAA,CAAmB,IAAI,CAAA,CAAE,MAAM,MAAM;AAAA,MAE7C,CAAC,CAAA;AAAA,IACH;AAAA,GACF;AACF;AAEAC,0BAAA,CAAsB,eAAA,EAAiB;AAAA;AAAA;AAAA,EAGrC,cAAc,EAAE,SAAA,EAAW,OAAO,UAAA,EAAY,KAAA,EAAO,WAAW,KAAA,EAAM;AAAA;AAAA,EAEtE,GAAA,EAAK,SAAQ,GAAA,CAAoB,CAAA;AAAA,EACjC,SAAS,CAAC,GAAA,EAAK,eAAe,OAAA,CAAS,GAAA,CAAoB,GAAG,UAAU;AAC1E,CAAC,CAAA;;;ACvFM,SAAS,QAAA,CAAS,CAAA,EAAmB,OAAA,GAA8B,EAAC,EAAgB;AACzF,EAAA,mBAAA,CAAoB,CAAC,CAAA;AACrB,EAAA,OAAO,OAAA,CAAQ,OAAA,KAAY,MAAA,GACvB,EAAE,QAAQ,eAAA,EAAiB,CAAA,EAAE,GAC7B,EAAE,MAAA,EAAQ,eAAA,EAAiB,CAAA,EAAG,OAAA,EAAS,QAAQ,OAAA,EAAQ;AAC7D","file":"index.cjs","sourcesContent":["/** Its own module so `env.ts` and `testcafe-query.ts` can share it without a cycle. */\nexport const TESTCAFE_DRIVER = 'testcafe'\n","import { reviveStrictViolation } from '@harnessed-ts/core'\n\n/** A TestCafe error is a plain object; `errMsg` is the page's own error, stringified. */\ninterface TestCafeError {\n code?: string\n errMsg?: string\n /** A JavaScript error the page itself raised. */\n errStack?: string\n /** TestCafe's own explanation, which some codes carry (why a node is invisible). */\n reason?: string\n}\n\n/**\n * What the TestCafe codes an action most often fails with mean, in a sentence.\n * TestCafe renders these only in its own reporter, so without this a failure\n * reads as nothing but a code.\n */\nconst REASONS: Record<string, string> = {\n E24: 'nothing matches it',\n E26: 'it is not visible',\n E27: 'it is not an element',\n E31: 'it is not editable',\n E36: 'TestCafe has no such key',\n E39: \"the iframe's content did not load\",\n E40: 'it is not an <iframe>',\n E42: \"the iframe's content did not load\",\n E43: 'the iframe it is in no longer exists',\n E44: 'the iframe it is in is no longer visible',\n E49: 'the page unloaded while TestCafe was reading it',\n E84: 'it timed out',\n E101: 'another element covers it',\n}\n\nexport function messageOf(error: unknown): string {\n if (error instanceof Error) return error.message\n const { errMsg } = (error ?? {}) as TestCafeError\n return typeof errMsg === 'string' ? errMsg : ''\n}\n\n/**\n * TestCafe rejects with plain objects. The specs, the page package and any\n * `catch` in a test expect an `Error` whose message is the cause — for an error\n * thrown in the page that is the resolver's own wording, so a strict-mode\n * violation reads the same here as under every other driver, and comes back as\n * core's `StrictModeViolation`.\n *\n * `context` says what was being attempted, as a verb phrase: `act on testId(x)`.\n */\nexport function toError(error: unknown, context?: string): Error {\n if (error instanceof Error) return error\n const { code, errMsg, errStack, reason } = (error ?? {}) as TestCafeError\n if (typeof errMsg === 'string') {\n return reviveStrictViolation(\n new Error(errMsg.replace(/^[A-Za-z]*Error: /, ''), { cause: error }),\n )\n }\n // Anything else is TestCafe's own failure, which it renders from a code; say\n // what the code means, and keep the code and the original object so its\n // report stays reachable.\n const what = context === undefined ? 'TestCafe failed' : `TestCafe could not ${context}`\n const known = code === undefined ? undefined : REASONS[code]\n const detail = typeof reason === 'string' && reason.trim() !== '' ? `: ${reason.trim()}` : ''\n const why = known === undefined ? '' : `: ${known}${detail}`\n const which = code === undefined ? '' : ` (TestCafe error ${code})`\n const page = typeof errStack === 'string' ? `: the page raised ${errStack.split('\\n')[0]}` : ''\n return new Error(`harnessed: ${what}${why}${which}${page}.`, { cause: error })\n}\n","import type { PageApi, PageApiOptions, WireSelector } from '@harnessed-ts/resolve/inject'\n\n/**\n * Code that runs in the browser, not in Node.\n *\n * TestCafe ships a client function to the page as its source text, so nothing\n * here may close over a module binding — every value it needs is an argument\n * or a dependency, and every helper is declared inside the function that uses\n * it. No `async` either: TestCafe refuses client functions that compile to a\n * regenerator, so waiting is written with `.then`.\n */\n\n/** Thrown in the page when the resolver is not there and no source came with the call. */\nexport const NOT_INJECTED = 'harnessed:not-injected'\n\n/** Every operation answered by one round trip through `pageCall`. */\nexport type PageOp =\n | 'count'\n | 'texts'\n | 'text'\n | 'value'\n | 'attribute'\n | 'enabled'\n | 'checked'\n | 'selected'\n | 'visible'\n | 'hidden'\n | 'resolve'\n | 'editable'\n | 'focus'\n | 'blur'\n | 'select'\n | 'box'\n | 'fileTarget'\n\n/**\n * How a single-target operation looks for its node. `now` answers at once,\n * with `absent` when nothing matches yet, so the driver polls from Node; `wait`\n * waits in the page for `options.timeout`, and is what the last poll uses so\n * that a target never found fails in the resolver's own words. `count` and\n * `texts` never wait in the page: they answer `absent` while their scope is\n * not on screen, whichever lookup is asked for.\n */\nexport type Lookup = 'now' | 'wait'\n\n/** What a page call answers with: the value, and the top-level URL it was read at. */\nexport interface PageResult {\n value: unknown\n href: string\n /** A `now` lookup, or a list's scope, found nothing to answer about yet. */\n absent?: true\n}\n\n/** What `select` takes: the values to pick, and the target named for its errors. */\nexport interface SelectArg {\n values: string[]\n target: string\n}\n\n/**\n * Whether a node can be typed into: `ok`, why not yet (`disabled`, `readonly`),\n * or — when it is not a text control at all — its tag, as `<div>`.\n */\nexport type Editable = 'ok' | 'disabled' | 'readonly' | `<${string}>`\n\n/**\n * One client function for every read: compiled once per test, called with the\n * operation as an argument.\n *\n * `source` is the resolver's injectable build, or `null`. A document that lacks\n * the resolver installs it from the source in the same round trip; without a\n * source it refuses, and the driver calls again with one. `new Function` rather\n * than `eval`: TestCafe rewrites `eval` to process the code it runs, which costs\n * several times what installing the build does.\n *\n * The resolver is looked up in the top-most window that has it, so a call made\n * while TestCafe is switched into an iframe still resolves from the page's own\n * document — the scope chain crosses frames itself, exactly as it does under\n * every other resolver-based driver.\n */\nexport function pageCall(\n name: string,\n source: string | null,\n op: PageOp,\n scope: WireSelector[],\n selector: WireSelector,\n options: PageApiOptions,\n arg: unknown,\n lookup: Lookup,\n): PageResult | Promise<PageResult> {\n let api: PageApi | null = null\n let home: Window = window\n let current: Window = window\n for (;;) {\n try {\n const found = (current as unknown as Record<string, PageApi | undefined>)[name]\n if (found !== undefined) {\n api = found\n home = current\n }\n } catch {\n // A cross-origin ancestor: the resolver could not cross into it anyway.\n break\n }\n if (current === current.parent) break\n current = current.parent\n }\n if (api === null) {\n // NOT_INJECTED, spelled out: page code cannot reach a module constant.\n if (source === null) throw new Error('harnessed:not-injected')\n // The build installs itself as a global of the window it runs in.\n new Function(source)()\n api = (window as unknown as Record<string, PageApi>)[name]\n home = window\n }\n const resolver: PageApi = api\n const href = home.location.href\n const done = (value: unknown): PageResult => ({ value, href })\n\n // The shared layout rule, judged in each element's own document, carried on\n // through every iframe the scope entered: a hidden frame hides its content.\n const isVisible = (element: Element): boolean => {\n let node: Element | null = element\n while (node !== null) {\n if (!resolver.visible(node)) return false\n const view: Window | null = node.ownerDocument.defaultView\n node = view === null || view === home ? null : view.frameElement\n }\n return true\n }\n\n // The single target now, for a yes/no question: `null` when it is not there,\n // including an index past the last match. Everything else the resolver\n // raises still throws — ambiguity, a frame that cannot be entered, a\n // selector it refuses — since none of them is an answer.\n const present = (): Element | null => {\n try {\n return resolver.oneNow(null, scope, selector, options)\n } catch (error) {\n const message = (error as { message?: unknown } | null)?.message\n if (typeof message === 'string' && /^harnessed: index \\d+ is out of range/.test(message)) {\n return null\n }\n throw error\n }\n }\n\n // A single target. `now` hands back `null` for \"not there yet\"; the driver\n // polls, so a wait never holds TestCafe's one command queue for long.\n const target = (): Promise<Element | null> =>\n lookup === 'now'\n ? Promise.resolve(resolver.oneNow(null, scope, selector, options))\n : resolver.one(null, scope, selector, options)\n const withTarget = (read: (node: Element) => unknown): Promise<PageResult> =>\n target().then(node => (node === null ? { value: null, href, absent: true } : done(read(node))))\n\n // Every match now, or `null` while a link of the scope is not on screen yet —\n // the driver polls that, as it does a single target. The last link is looked\n // up as the element it names, so \"absent\" is told apart from what\n // `allNow` folds into an empty list: an ambiguous or out-of-range link, which\n // holds nothing at once, as `count` says under every driver. A frame that\n // cannot be entered still throws.\n const list = (): Element[] | null => {\n if (scope.length > 0) {\n const last = Object.assign({}, scope[scope.length - 1], { frame: false })\n let link: Element | null\n try {\n link = resolver.oneNow(null, scope.slice(0, -1), last, options)\n } catch (error) {\n if ((error as { name?: string } | null)?.name === 'FrameEntryError') throw error\n return []\n }\n if (link === null) return null\n }\n // `nth` picks one match, or none: a list read through `nth()` is that one.\n return resolver.allNow(null, scope, selector, options)\n }\n const withList = (read: (matches: Element[]) => unknown): PageResult => {\n const matches = list()\n return matches === null ? { value: null, href, absent: true } : done(read(matches))\n }\n\n switch (op) {\n case 'count':\n return withList(matches => matches.length)\n case 'texts':\n return withList(matches => matches.map(node => (node.textContent ?? '').trim()))\n case 'visible': {\n const node = present()\n return done(node !== null && isVisible(node))\n }\n case 'hidden': {\n const node = present()\n return done(node === null || !isVisible(node))\n }\n case 'text':\n return withTarget(node => (node.textContent ?? '').trim())\n case 'value':\n return withTarget(node => (node as HTMLInputElement).value ?? '')\n case 'attribute':\n return withTarget(node => node.getAttribute(arg as string))\n case 'enabled':\n // `disabled` is inherited from an ancestor fieldset; `:disabled` sees that\n // where the element's own attribute does not.\n return withTarget(node => [\n (node as HTMLInputElement).disabled === true || node.closest(':disabled') !== null,\n node.getAttribute('aria-disabled'),\n ])\n case 'checked':\n return withTarget(node => [\n node.getAttribute('aria-checked'),\n Boolean((node as HTMLInputElement).checked),\n ])\n case 'selected':\n return withTarget(node =>\n Array.prototype.map.call(\n (node as HTMLSelectElement).selectedOptions ?? [],\n (option: HTMLOptionElement) => option.value,\n ),\n )\n case 'resolve':\n return withTarget(() => null)\n case 'fileTarget':\n return withTarget(node => resolver.fileTarget(node))\n case 'box':\n // Measured in the node's own document, then offset by each frame up to `home`.\n return withTarget(node => {\n const box = resolver.box(node)\n if (box === null) return { x: 0, y: 0, width: 0, height: 0 }\n let view: Window | null = node.ownerDocument.defaultView\n while (view !== null && view !== home) {\n const frame: Element | null = view.frameElement\n if (frame === null) break\n const origin = resolver.origin(frame)\n box.x += origin.x\n box.y += origin.y\n view = frame.ownerDocument.defaultView\n }\n return box\n })\n case 'editable':\n // TestCafe's typeText types into the first editable descendant of a\n // wrapper, and does nothing at all to a disabled or readonly control; both\n // are refused before it is asked. So is an <input> that takes no text — a\n // checkbox, a file — which Playwright's fill refuses too, and a control\n // `aria-disabled` marks, which `isEnabled()` reads as disabled.\n return withTarget((node): Editable => {\n const input = node.localName === 'input'\n const control = input || node.localName === 'textarea'\n if (!control && !(node as HTMLElement).isContentEditable) return `<${node.localName}>`\n if (input) {\n const type = (node as HTMLInputElement).type.toLowerCase()\n // Typed into, or set as a value: the types Playwright's fill takes.\n const fillable =\n /^(?:|email|number|password|search|tel|text|url|color|date|time|datetime|datetime-local|month|range|week)$/\n if (!fillable.test(type)) return `<input type=\"${type}\">`\n }\n if (control && node.matches(':disabled')) return 'disabled'\n if (node.getAttribute('aria-disabled') === 'true') return 'disabled'\n if (control && (node as HTMLInputElement).readOnly) return 'readonly'\n return 'ok'\n })\n case 'focus':\n return withTarget(node => {\n ;(node as HTMLElement).focus()\n return null\n })\n case 'blur':\n return withTarget(node => {\n ;(node as HTMLElement).blur()\n return null\n })\n case 'select':\n return withTarget(node => {\n const { values, target: named } = arg as SelectArg\n if (node.localName !== 'select') {\n throw new Error(\n `harnessed: selectOption() needs a <select>, but ${named} is a <${node.localName}>.`,\n )\n }\n const element = node as HTMLSelectElement\n const all: HTMLOptionElement[] = Array.prototype.slice.call(element.options)\n // By value first, then by label — what Playwright's selectOption matches.\n const picked = values.map(value => {\n const option =\n all.find(candidate => candidate.value === value) ??\n all.find(candidate => candidate.label === value)\n if (option === undefined) {\n throw new Error(`harnessed: no <option> of ${named} matches \"${value}\".`)\n }\n return option\n })\n if (!element.multiple && picked.length > 1) {\n throw new Error(\n `harnessed: selectOption() was given several values for ${named}, a single-select.`,\n )\n }\n // Replaces the selection, as Playwright does, rather than adding to it.\n for (const option of all) option.selected = picked.includes(option)\n const view = element.ownerDocument.defaultView ?? window\n element.dispatchEvent(new view.Event('input', { bubbles: true, composed: true }))\n element.dispatchEvent(new view.Event('change', { bubbles: true }))\n return null\n })\n }\n}\n\n/**\n * The node an action targets, for a TestCafe `Selector`. Synchronous, as a\n * selector's init function must be: \"not there yet\" is an empty list and\n * TestCafe's own retry does the waiting. An empty list rather than `null` keeps\n * the return within TestCafe's declared selector types.\n */\nexport function pickTarget(): Element[] {\n // Dependencies, declared for the type checker. TestCafe defines each one as a\n // variable in the function's scope before running it.\n const { name, scope, selector, options, control } = harnessedTarget\n let api: PageApi | null = null\n let current: Window = window\n for (;;) {\n try {\n const found = (current as unknown as Record<string, PageApi | undefined>)[name]\n if (found !== undefined) api = found\n } catch {\n break\n }\n if (current === current.parent) break\n current = current.parent\n }\n if (api === null) return []\n const node = api.oneNow(null, scope, selector, options)\n if (node === null) return []\n // An upload through a <label> acts on the input it labels.\n const labelled = control === true && node.localName === 'label'\n const target = labelled ? (node as HTMLLabelElement).control : node\n return target === null ? [] : [target]\n}\n\n/** The shape of `pickTarget`'s one dependency. */\nexport interface TargetDependency {\n name: string\n scope: WireSelector[]\n selector: WireSelector\n options: PageApiOptions\n /** Pick a label's control instead of the label. */\n control?: boolean\n}\n\ndeclare const harnessedTarget: TargetDependency\n\n/** The current top-level URL, without needing the resolver. */\nexport function currentHref(): string {\n return window.location.href\n}\n\n/** The browser's platform, which decides what `ControlOrMeta` presses. */\nexport function browserPlatform(): string {\n return window.navigator.platform\n}\n","import { ClientFunction } from 'testcafe'\nimport { injectSource, PAGE_API_GLOBAL } from '@harnessed-ts/resolve/inject'\nimport type { PageApiOptions, WireSelector } from '@harnessed-ts/resolve/inject'\nimport { messageOf, toError } from './errors'\nimport { browserPlatform, currentHref, NOT_INJECTED, pageCall } from './page-functions'\nimport type { Lookup, PageOp, PageResult } from './page-functions'\n\n/**\n * What the driver keeps per test. Keyed by the controller: TestCafe hands every\n * test its own, and everything here belongs to exactly one test.\n */\nexport interface Session {\n /**\n * The top-level URL as of the last call that touched the page. `currentUrl`\n * is synchronous and TestCafe can only read the page asynchronously, so every\n * round trip brings the URL back with it and every action and navigation\n * refreshes it afterwards.\n */\n href: string | undefined\n /**\n * One round trip through the shared resolver. Under a `now` lookup a\n * single-target operation answers `absent` rather than waiting for its node.\n */\n read(\n op: PageOp,\n scope: WireSelector[],\n selector: WireSelector,\n options: PageApiOptions,\n arg: unknown,\n lookup: Lookup,\n ): Promise<PageResult>\n /** Re-read the top-level URL; needs no resolver, so it is safe after a navigation. */\n locate(): Promise<string>\n /** The browser's `navigator.platform`, read once: it does not change mid-test. */\n platform(): Promise<string>\n /**\n * Runs an operation that may switch TestCafe into an iframe. Switching is\n * state on the controller, so two such operations must never interleave —\n * and nor may a plain action, whose selector would run in the wrong window.\n */\n exclusive<T>(run: () => Promise<T>): Promise<T>\n /** The page was replaced: the next call carries the resolver with it. */\n navigated(): void\n}\n\nconst sessions = new WeakMap<TestController, Session>()\n\n/**\n * The `t` exported by 'testcafe' is one shared proxy that looks up whichever\n * test is running when it is used. A client function bound to it does not\n * bind, and a session keyed by it would be shared by every test — so only the\n * controller a test function is handed, which carries its own test run, will do.\n */\nexport function assertOwnController(t: TestController): void {\n if (typeof (t as { testRun?: unknown }).testRun !== 'object') {\n throw new Error(\n \"harnessed: pass the test function's own t, not the one imported from 'testcafe': \" +\n \"test('…', async t => { … testcafe(t) … }).\",\n )\n }\n}\n\n/**\n * The resolver, as TestCafe sees it. Client functions are compiled when they are\n * created, so they are built once per test and take the per-call values as\n * arguments. `boundTestRun` ties them to the test explicitly: TestCafe's own\n * test-run tracking follows its promise patches, which native `await` in a\n * compiled library does not go through.\n */\nexport function sessionFor(t: TestController): Session {\n const existing = sessions.get(t)\n if (existing !== undefined) return existing\n assertOwnController(t)\n\n const call = ClientFunction(pageCall, { boundTestRun: t })\n const href = ClientFunction(currentHref, { boundTestRun: t })\n const readPlatform = ClientFunction(browserPlatform, { boundTestRun: t })\n let platform: string | undefined\n let queue: Promise<unknown> = Promise.resolve()\n // A session starts on a page the driver has not seen, so its first call\n // carries the resolver. After that the source is sent only when the page may\n // be a fresh document — after a navigation, or once the URL has changed — and\n // when a call finds the resolver missing anyway.\n let carrySource = true\n const seen = (url: string): void => {\n if (session.href !== undefined && url !== session.href) carrySource = true\n session.href = url\n }\n\n const session: Session = {\n href: undefined,\n async read(op, scope, selector, options, arg, lookup) {\n // The page answers with a value or a promise of one; awaiting flattens both.\n const run = async (source: string | null): Promise<PageResult> =>\n await call(PAGE_API_GLOBAL, source, op, scope, selector, options, arg, lookup)\n let result: PageResult\n try {\n result = await run(carrySource ? injectSource() : null)\n } catch (error) {\n if (!messageOf(error).includes(NOT_INJECTED)) throw toError(error)\n try {\n result = await run(injectSource())\n } catch (retried) {\n throw toError(retried)\n }\n }\n carrySource = false\n session.href = result.href\n return result\n },\n async locate() {\n let current: string\n try {\n current = await href()\n } catch (error) {\n throw toError(error)\n }\n seen(current)\n return current\n },\n async platform() {\n if (platform === undefined) {\n try {\n platform = await readPlatform()\n } catch (error) {\n throw toError(error)\n }\n }\n return platform\n },\n navigated() {\n carrySource = true\n },\n exclusive(run) {\n const next = queue.then(run, run)\n queue = next.catch(() => undefined)\n return next\n },\n }\n sessions.set(t, session)\n return session\n}\n","/**\n * Playwright key names, which the shared `press()` takes, onto TestCafe's\n * `pressKey` names. TestCafe lowercases its own and shortens a few; a printable\n * character passes through, except a space, which `pressKey` would read as a\n * separator between two keys.\n */\nconst NAMES: Record<string, string> = {\n ' ': 'space',\n Space: 'space',\n Enter: 'enter',\n Tab: 'tab',\n Backspace: 'backspace',\n Delete: 'delete',\n Escape: 'esc',\n Insert: 'ins',\n Home: 'home',\n End: 'end',\n PageUp: 'pageup',\n PageDown: 'pagedown',\n ArrowUp: 'up',\n ArrowDown: 'down',\n ArrowLeft: 'left',\n ArrowRight: 'right',\n Control: 'ctrl',\n Shift: 'shift',\n Alt: 'alt',\n Meta: 'meta',\n CapsLock: 'capslock',\n}\n\n/**\n * Every multi-character name TestCafe's `pressKey` accepts: its modifiers and\n * its special keys. Anything else it rejects with an opaque \"incorrect key\"\n * error, so a name outside this set is refused here first, with the key named.\n */\nconst SUPPORTED = new Set([\n 'alt',\n 'ctrl',\n 'meta',\n 'shift',\n 'backspace',\n 'capslock',\n 'delete',\n 'down',\n 'end',\n 'enter',\n 'esc',\n 'home',\n 'ins',\n 'left',\n 'pagedown',\n 'pageup',\n 'right',\n 'space',\n 'tab',\n 'up',\n])\n\n/** A chord's parts. A lone `+` is the plus key, and `Control++` holds Control over it. */\nfunction parts(key: string): string[] {\n if (key.length <= 1) return [key]\n const plus = key.endsWith('++')\n const split = (plus ? key.slice(0, -2) : key).split('+')\n return plus ? [...split, '+'] : split\n}\n\nfunction toPart(part: string, platform: string | undefined): string | undefined {\n if (part === 'ControlOrMeta') {\n return platform !== undefined && /^(?:Mac|iP)/.test(platform) ? 'meta' : 'ctrl'\n }\n const code = /^(?:Key([A-Z])|Digit(\\d))$/.exec(part)\n if (code !== null) return (code[1] ?? code[2]!).toLowerCase()\n const named = NAMES[part]\n if (named !== undefined) return named\n if (part.length === 1) return part\n return SUPPORTED.has(part) ? part : undefined\n}\n\n/**\n * `Control+Shift+ArrowLeft` → `ctrl+shift+left`, `ControlOrMeta+KeyA` →\n * `meta+a` in a browser on macOS. Throws before anything is pressed for a key\n * TestCafe has no way to send, such as a function key.\n *\n * `platform` is the browser's `navigator.platform`, which only `ControlOrMeta`\n * reads: the browser may run on another machine than the test runner.\n */\nexport function toTestCafeKey(key: string, platform?: string): string {\n return parts(key)\n .map(part => {\n const mapped = toPart(part, platform)\n if (mapped === undefined) {\n throw new Error(\n `harnessed: press() cannot send \"${key}\" under TestCafe, which has no \"${part}\" key.`,\n )\n }\n return mapped\n })\n .join('+')\n}\n","import { Selector as TestCafeSelector } from 'testcafe'\nimport { Query, registerDriver, registerNavigation } from '@harnessed-ts/core'\nimport type { BoundingBox, EnvConfig, FileTarget, Selector } from '@harnessed-ts/core'\nimport type { WaitOptions, WaitState } from '@harnessed-ts/core'\nimport {\n checkedFrom,\n checkFileTarget,\n checkTestIds,\n describeScope,\n enabledFrom,\n getConfig,\n timeoutFor,\n} from '@harnessed-ts/core'\nimport { encodeSelector, filesOnDisk, PAGE_API_GLOBAL } from '@harnessed-ts/resolve/inject'\nimport type { PageApiOptions } from '@harnessed-ts/resolve/inject'\nimport { TESTCAFE_DRIVER } from './driver-id'\nimport type { TestCafeEnv } from './env'\nimport { toError } from './errors'\nimport { toTestCafeKey } from './keys'\nimport { pickTarget } from './page-functions'\nimport type { Editable, PageOp, SelectArg, TargetDependency } from './page-functions'\nimport { sessionFor } from './session'\nimport type { Session } from './session'\n\n/** How often a wait re-asks the page. Each ask is one short round trip. */\nconst POLL_MS = 50\n\n/**\n * The last poll of a single-target read waits in the page this long, so that a\n * target never found fails in the resolver's own words.\n */\nconst LAST_WAIT_MS = POLL_MS\n\n/** Why a text control cannot be typed into yet. */\nconst NOT_EDITABLE: Record<'disabled' | 'readonly', string> = {\n disabled: 'it is disabled',\n readonly: 'it is readonly',\n}\n\n/** A frame link's own element: the iframe itself, not the document inside it. */\nfunction unframed(link: Selector): Selector {\n return { ...link, frame: undefined }\n}\n\nfunction delay(ms: number): Promise<void> {\n return new Promise(resolve => setTimeout(resolve, ms))\n}\n\n/**\n * TestCafe driver. Every lookup runs the shared resolver inside the page, so\n * role, label, strictness, absence and frame semantics are the dom driver's by\n * construction; TestCafe performs the actions.\n *\n * Reads are client functions that return values, which can cross into a\n * same-origin frame from the top-level window. Actions need a TestCafe\n * `Selector`, whose node must belong to the window TestCafe is switched into —\n * so an action under a frame switches into each iframe in turn, acts, and\n * always switches back.\n *\n * TestCafe runs one command at a time, so nothing here waits inside the page\n * for long: a wait held open there would block every other call until it\n * settled — including after a caller such as `isReady()` has stopped\n * listening. Single-target and list reads poll from Node instead.\n */\nexport class TestCafeQuery extends Query {\n constructor(\n private readonly t: TestController,\n scope: readonly Selector[],\n selector: Selector,\n ) {\n super(scope, selector)\n }\n\n protected override clone(selector: Selector): Query {\n return new TestCafeQuery(this.t, this.scope, selector)\n }\n\n private get session(): Session {\n return sessionFor(this.t)\n }\n\n private get described(): string {\n return describeScope(this.scope, this.selector)\n }\n\n /** Runtime config travels with every call: the page cannot see `configure()`. */\n private pageOptions(timeout?: number): PageApiOptions {\n // Refused here, so the page never folds a refusal into \"nothing there\".\n checkTestIds(this.scope, this.selector)\n return { testIdAttribute: getConfig().testIdAttribute, timeout: timeoutFor(timeout) }\n }\n\n /** One round trip, answered at once. */\n private async read<T>(op: PageOp, options?: WaitOptions, arg?: unknown): Promise<T> {\n const result = await this.session.read(\n op,\n this.scope.map(encodeSelector),\n encodeSelector(this.selector),\n this.pageOptions(options?.timeout),\n arg,\n 'now',\n )\n return result.value as T\n }\n\n /**\n * A list operation, polled from Node until its scope is there, as every\n * driver waits for the scope; the list itself answers at once. A scope that\n * never appears holds nothing, so the deadline answers `empty` rather than\n * failing.\n */\n private async readList<T>(op: 'count' | 'texts', empty: T): Promise<T> {\n const timeout = timeoutFor()\n const deadline = Date.now() + timeout\n const scope = this.scope.map(encodeSelector)\n const selector = encodeSelector(this.selector)\n for (;;) {\n const result = await this.session.read(\n op,\n scope,\n selector,\n this.pageOptions(timeout),\n undefined,\n 'now',\n )\n if (result.absent !== true) return result.value as T\n if (Date.now() >= deadline) return empty\n await delay(POLL_MS)\n }\n }\n\n /**\n * A single-target operation, polled from Node until its node is there. The\n * last poll waits briefly in the page, so a target that never appears fails\n * with the resolver's own message; a strict violation fails on the first.\n */\n private async readOne<T>(op: PageOp, options?: WaitOptions, arg?: unknown): Promise<T> {\n const timeout = timeoutFor(options?.timeout)\n const deadline = Date.now() + timeout\n const scope = this.scope.map(encodeSelector)\n const selector = encodeSelector(this.selector)\n for (;;) {\n const last = Date.now() >= deadline\n const result = await this.session.read(\n op,\n scope,\n selector,\n this.pageOptions(last ? LAST_WAIT_MS : timeout),\n arg,\n last ? 'wait' : 'now',\n )\n if (result.absent !== true) return result.value as T\n await delay(POLL_MS)\n }\n }\n\n /** A TestCafe selector for one link of the chain, resolved by the same resolver. */\n private selectorFor(\n scope: readonly Selector[],\n selector: Selector,\n timeout: number,\n control = false,\n ): ReturnType<typeof TestCafeSelector> {\n const harnessedTarget: TargetDependency = {\n name: PAGE_API_GLOBAL,\n scope: scope.map(encodeSelector),\n selector: encodeSelector(selector),\n options: this.pageOptions(timeout),\n control,\n }\n return TestCafeSelector(pickTarget, {\n dependencies: { harnessedTarget },\n boundTestRun: this.t,\n timeout,\n })\n }\n\n /**\n * Runs a TestCafe action against this query's node.\n *\n * The resolver answers first, from the page: that is what makes a strict\n * violation, a missing target or a frame marker on a non-iframe fail at once\n * with the shared wording. An error thrown inside a TestCafe selector is\n * instead retried until the selector times out, and a strict violation never\n * becomes a single match by waiting. `prepare` then refuses what TestCafe\n * would get silently wrong, within the same deadline. After that, TestCafe's\n * own selectors only have to wait for the node to be actionable — each frame\n * switch and the action given what is left of that one deadline, so the\n * whole operation fails within the caller's timeout.\n */\n private act(\n run: (target: ReturnType<typeof TestCafeSelector>, deadline: number) => Promise<unknown>,\n options?: WaitOptions,\n prepare?: (deadline: number, timeout: number) => Promise<void>,\n control = false,\n ): Promise<void> {\n return this.session.exclusive(async () => {\n const timeout = timeoutFor(options?.timeout)\n const deadline = Date.now() + timeout\n await this.readOne('resolve', { timeout })\n if (prepare !== undefined) await prepare(deadline, timeout)\n const remaining = (): number => Math.max(deadline - Date.now(), 0)\n const frames = this.scope.flatMap((link, index) => (link.frame === true ? [index] : []))\n try {\n for (const index of frames) {\n await this.t.switchToIframe(\n this.selectorFor(this.scope.slice(0, index), unframed(this.scope[index]!), remaining()),\n )\n }\n await run(this.selectorFor(this.scope, this.selector, remaining(), control), deadline)\n } catch (error) {\n throw toError(error, `act on ${this.described}`)\n } finally {\n if (frames.length > 0) await this.t.switchToMainWindow()\n }\n // An action can navigate; `currentUrl` must not report the page it left.\n await this.session.locate()\n })\n }\n\n /**\n * Waits until the target can be typed into, and refuses one that never can.\n * TestCafe's typeText would otherwise do nothing to a disabled or readonly\n * control, and type into the first editable descendant of a wrapper.\n */\n private async editable(action: 'fill' | 'clear', deadline: number, timeout: number) {\n for (;;) {\n const state = await this.readOne<Editable>('editable', {\n timeout: Math.max(deadline - Date.now(), 0),\n })\n if (state === 'ok') return\n if (state !== 'disabled' && state !== 'readonly') {\n throw new Error(\n `harnessed: ${action}() needs an <input>, <textarea> or [contenteditable] element, but ${this.described} is a ${state}.`,\n )\n }\n if (Date.now() >= deadline) {\n throw new Error(\n `harnessed: ${action}() could not edit ${this.described} within ${timeout}ms: ${NOT_EDITABLE[state]}.`,\n )\n }\n await delay(POLL_MS)\n }\n }\n\n // --- interactions -------------------------------------------------------\n\n override async click(options?: WaitOptions): Promise<void> {\n await this.act(target => this.t.click(target), options)\n }\n\n override async fill(value: string, options?: WaitOptions): Promise<void> {\n await this.replaceValue('fill', value, options)\n }\n\n override async clear(options?: WaitOptions): Promise<void> {\n await this.replaceValue('clear', '', options)\n }\n\n /**\n * Replaces the value, as Playwright's `fill()` does. `paste` sets the whole\n * value in one input event rather than typing character by character; an\n * empty value — which typeText refuses — selects what is there and deletes\n * it, so `fill('')` and `clear()` are one operation with one set of checks.\n */\n private async replaceValue(\n action: 'fill' | 'clear',\n value: string,\n options?: WaitOptions,\n ): Promise<void> {\n await this.act(\n target =>\n value === ''\n ? this.t.selectText(target).pressKey('delete')\n : this.t.typeText(target, value, { replace: true, paste: true }),\n options,\n (deadline, timeout) => this.editable(action, deadline, timeout),\n )\n }\n\n override async check(options?: WaitOptions): Promise<void> {\n if (!(await this.isChecked(options))) await this.click(options)\n }\n\n override async uncheck(options?: WaitOptions): Promise<void> {\n if (await this.isChecked(options)) await this.click(options)\n }\n\n /**\n * TestCafe has no select API, and driving a native dropdown by clicking is\n * platform-dependent. The selection is set in the page and `input` and\n * `change` dispatched — what Playwright's selectOption does — replacing any\n * existing selection of a multi-select. A change handler can navigate, so\n * this is an action like any other: it takes its turn, and re-reads the URL.\n */\n override async selectOption(value: string | string[], options?: WaitOptions): Promise<void> {\n const arg: SelectArg = {\n values: Array.isArray(value) ? value : [value],\n target: this.described,\n }\n await this.session.exclusive(async () => {\n await this.readOne('select', options, arg)\n await this.session.locate()\n })\n }\n\n /**\n * TestCafe sets files only from paths, so each File is written to disk first\n * (see `filesOnDisk`): the name and bytes arrive, and the type is inferred\n * from the extension.\n */\n override async upload(files: File | File[], options?: WaitOptions): Promise<void> {\n const list = Array.isArray(files) ? files : [files]\n let paths: string[] = []\n await this.act(\n target => this.t.setFilesToUpload(target, paths),\n options,\n async (deadline: number) => {\n const target = await this.readOne<FileTarget>('fileTarget', {\n timeout: Math.max(deadline - Date.now(), 0),\n })\n checkFileTarget(target, list.length, this.scope, this.selector)\n paths = await filesOnDisk(list)\n },\n true,\n )\n }\n\n override async hover(options?: WaitOptions): Promise<void> {\n await this.act(target => this.t.hover(target), options)\n }\n\n override async focus(options?: WaitOptions): Promise<void> {\n await this.readOne('focus', options)\n }\n\n override async blur(options?: WaitOptions): Promise<void> {\n await this.readOne('blur', options)\n }\n\n /**\n * Focuses the target first, as Playwright's press does; keys go to the\n * focused node. The key is checked before anything happens, and the focus\n * spends only what is left of the one timeout. `ControlOrMeta` follows the\n * browser's platform, which may not be the test runner's.\n */\n override async press(key: string, options?: WaitOptions): Promise<void> {\n const platform = key.includes('ControlOrMeta') ? await this.session.platform() : undefined\n const keys = toTestCafeKey(key, platform)\n await this.act(async (_target, deadline) => {\n await this.readOne('focus', { timeout: Math.max(deadline - Date.now(), 0) })\n await this.t.pressKey(keys)\n }, options)\n }\n\n // --- observations -------------------------------------------------------\n\n override async text(options?: WaitOptions): Promise<string> {\n return this.readOne<string>('text', options)\n }\n\n override async inputValue(options?: WaitOptions): Promise<string> {\n return this.readOne<string>('value', options)\n }\n\n override async attribute(name: string, options?: WaitOptions): Promise<string | null> {\n return this.readOne<string | null>('attribute', options, name)\n }\n\n override async boundingBox(options?: WaitOptions): Promise<BoundingBox> {\n return this.readOne<BoundingBox>('box', options)\n }\n\n /** Answers at once, as Playwright's does: an absent target is not visible. */\n override async isVisible(options?: WaitOptions): Promise<boolean> {\n return this.read<boolean>('visible', options)\n }\n\n override async isEnabled(options?: WaitOptions): Promise<boolean> {\n const [disabled, ariaDisabled] = await this.readOne<[boolean, string | null]>(\n 'enabled',\n options,\n )\n return enabledFrom(disabled, ariaDisabled)\n }\n\n override async isChecked(options?: WaitOptions): Promise<boolean> {\n const [aria, native] = await this.readOne<[string | null, boolean]>('checked', options)\n return checkedFrom(aria, native)\n }\n\n override async selectedOptions(options?: WaitOptions): Promise<string[]> {\n return this.readOne<string[]>('selected', options)\n }\n\n // --- waiting ------------------------------------------------------------\n\n /** Polls from Node rather than waiting inside the page, as every read here does. */\n override async waitFor(state: WaitState, options?: WaitOptions): Promise<void> {\n const timeout = timeoutFor(options?.timeout)\n const deadline = Date.now() + timeout\n for (;;) {\n if (await this.read<boolean>(state, { timeout })) return\n if (Date.now() >= deadline) {\n throw new Error(`harnessed: ${this.described} did not become ${state} within ${timeout}ms.`)\n }\n await delay(POLL_MS)\n }\n }\n\n /** Waits for the scope chain, as every driver does; the count itself answers at once. */\n override async count(): Promise<number> {\n return this.readList<number>('count', 0)\n }\n\n /** Every match read in one round trip, once the scope is there; trimmed to match `text()`. */\n override async texts(): Promise<string[]> {\n return this.readList<string[]>('texts', [])\n }\n}\n\nregisterDriver(TESTCAFE_DRIVER, (env: EnvConfig, scope, selector) => {\n return new TestCafeQuery((env as TestCafeEnv).t, scope, selector)\n})\n\n/**\n * This driver can navigate. A relative path resolves against the env's\n * `baseUrl` when it has one, and otherwise against the page the test is on.\n */\nregisterNavigation(TESTCAFE_DRIVER, {\n async goto(env, url) {\n const { t, baseUrl } = env as TestCafeEnv\n const session = sessionFor(t)\n const base = baseUrl ?? (await session.locate())\n let target: string\n try {\n target = new URL(url, base).href\n } catch {\n throw new Error(\n `harnessed: cannot resolve \"${url}\" against ${base}. Navigate to the app first, or pass ` +\n '`baseUrl` to testcafe(t, { baseUrl }).',\n )\n }\n try {\n await t.navigateTo(target)\n } catch (error) {\n throw toError(error, `navigate to ${target}`)\n } finally {\n // A new document, which has no resolver until one is sent.\n session.navigated()\n }\n await session.locate()\n },\n currentUrl(env) {\n const { href } = sessionFor((env as TestCafeEnv).t)\n if (href === undefined) {\n throw new Error(\n 'harnessed: the testcafe driver has not read the URL yet. TestCafe reads the page ' +\n 'asynchronously, so the URL is learned from goto() and from every harness call — ' +\n 'make one of those first.',\n )\n }\n return href\n },\n async waitForUrl(env, matches, timeout) {\n const session = sessionFor((env as TestCafeEnv).t)\n const deadline = Date.now() + timeout\n for (;;) {\n const href = await session.locate()\n if (matches(new URL(href))) return\n if (Date.now() >= deadline) {\n throw new Error(`harnessed: the URL did not match within ${timeout}ms; it is ${href}.`)\n }\n await delay(POLL_MS)\n }\n },\n})\n","import { registerMockTransport } from '@harnessed-ts/mock'\nimport type { Dispatcher, InstalledTransport, RawRequest } from '@harnessed-ts/mock'\nimport { RequestHook, RequestMock } from 'testcafe'\nimport { TESTCAFE_DRIVER } from './driver-id'\nimport type { TestCafeEnv } from './env'\n\n/**\n * The parts of hammerhead's request event this transport reads and writes.\n * `_requestInfo` is what TestCafe's own RequestLogger reads; there is no\n * public equivalent.\n */\ninterface RequestEvent {\n _requestInfo: {\n url: string\n method: string\n headers: Record<string, string>\n body?: Buffer\n isAjax: boolean\n }\n requestOptions: {\n hostname: string\n host: string\n port: number | string\n protocol: string\n path: string\n }\n setMock(mock: unknown): Promise<void>\n}\n\ninterface ResponseMockClass {\n from(init: {\n body: Buffer | string\n statusCode: number\n headers: Record<string, string>\n }): unknown\n}\n\n/**\n * hammerhead's ResponseMock, which TestCafe does not export. A RequestMock\n * builds one per rule, so one built here and read back gives the class without\n * depending on hammerhead directly.\n */\nfunction responseMockClass(): ResponseMockClass {\n const probe = RequestMock()\n .onRequestTo(() => false)\n .respond('') as unknown as { mocks: Map<string, object> }\n return probe.mocks.values().next().value!.constructor as unknown as ResponseMockClass\n}\n\n/** A port nothing listens on: sending a request there is how a network failure is staged. */\nconst UNREACHABLE = { hostname: '127.0.0.1', port: 9 }\n\nclass MockHook extends RequestHook {\n readonly #dispatcher: Dispatcher\n readonly #ResponseMock = responseMockClass()\n disposed = false\n\n constructor(dispatcher: Dispatcher) {\n super(undefined, {})\n this.#dispatcher = dispatcher\n }\n\n override async onRequest(event: object): Promise<void> {\n if (this.disposed) return\n const request = (event as RequestEvent)._requestInfo\n const raw: RawRequest = {\n method: request.method.toUpperCase(),\n url: request.url,\n headers: request.headers,\n body:\n request.body !== undefined && request.body.length > 0 ? new Uint8Array(request.body) : null,\n kind: request.isAjax ? 'fetch' : 'other',\n }\n const result = await this.#dispatcher.dispatch(raw)\n if (result.kind === 'passthrough') return\n if (result.kind === 'error') {\n // TestCafe can mock a response but not fail one, so the request is sent\n // where nothing answers — the browser sees the same network error.\n const options = (event as RequestEvent).requestOptions\n options.hostname = UNREACHABLE.hostname\n options.host = `${UNREACHABLE.hostname}:${UNREACHABLE.port}`\n options.port = UNREACHABLE.port\n options.protocol = 'http:'\n return\n }\n const { reply } = result\n await (event as RequestEvent).setMock(\n this.#ResponseMock.from({\n body: reply.body === null ? '' : Buffer.from(reply.body),\n statusCode: reply.status,\n headers: reply.headers,\n }),\n )\n }\n\n override async onResponse(): Promise<void> {}\n}\n\nasync function install(t: TestController, dispatcher: Dispatcher): Promise<InstalledTransport> {\n const hook = new MockHook(dispatcher)\n await t.addRequestHooks(hook)\n return {\n async dispose() {\n hook.disposed = true\n await t.removeRequestHooks(hook).catch(() => {\n // The test is over and took its hooks with it.\n })\n },\n }\n}\n\nregisterMockTransport(TESTCAFE_DRIVER, {\n // Buffered, and no sockets: TestCafe's proxy offers neither a streamed\n // response nor a hook on WebSockets.\n capabilities: { streaming: false, websockets: false, harRecord: false },\n // Hooks are attached per test, through the test's own controller.\n key: env => (env as TestCafeEnv).t,\n install: (env, dispatcher) => install((env as TestCafeEnv).t, dispatcher),\n})\n","/// <reference types=\"testcafe\" />\nimport type { EnvConfig } from '@harnessed-ts/core'\nimport { TESTCAFE_DRIVER } from './driver-id'\nimport { assertOwnController } from './session'\n// Side effect: constructing an env is the moment the driver has to be registered.\nimport './testcafe-query'\n// And its mock transport, so `mock(testcafe(t))` works without a second import.\nimport './mock-transport'\n\nexport { TESTCAFE_DRIVER }\n\nexport interface TestCafeEnv extends EnvConfig {\n readonly driver: typeof TESTCAFE_DRIVER\n /** The test's controller. Every action goes through it, so an env is per test. */\n readonly t: TestController\n /**\n * What a page's relative path resolves against in `goto()`. Without it, the\n * page the test is on — which is the fixture's page when a test starts.\n */\n readonly baseUrl?: string\n}\n\nexport interface TestCafeEnvOptions {\n baseUrl?: string\n}\n\n/**\n * Builds the env a harness is constructed with under TestCafe. `t` is the one\n * the test function is handed — not the shared `t` exported by 'testcafe',\n * which belongs to no one test.\n */\nexport function testcafe(t: TestController, options: TestCafeEnvOptions = {}): TestCafeEnv {\n assertOwnController(t)\n return options.baseUrl === undefined\n ? { driver: TESTCAFE_DRIVER, t }\n : { driver: TESTCAFE_DRIVER, t, baseUrl: options.baseUrl }\n}\n"]}
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import { TESTCAFE_DRIVER } from './chunk-HA6QY24A.js';
|
|
2
|
+
export { TESTCAFE_DRIVER } from './chunk-HA6QY24A.js';
|
|
1
3
|
import { Selector, ClientFunction } from 'testcafe';
|
|
2
4
|
import { encodeSelector, PAGE_API_GLOBAL, filesOnDisk, injectSource } from '@harnessed-ts/resolve/inject';
|
|
3
5
|
import { registerDriver, registerNavigation, Query, describeScope, checkTestIds, timeoutFor, getConfig, checkFileTarget, enabledFrom, checkedFrom, reviveStrictViolation } from '@harnessed-ts/core';
|
|
4
6
|
|
|
5
|
-
// src/driver-id.ts
|
|
6
|
-
var TESTCAFE_DRIVER = "testcafe";
|
|
7
7
|
var REASONS = {
|
|
8
8
|
E24: "nothing matches it",
|
|
9
9
|
E26: "it is not visible",
|
|
@@ -763,6 +763,6 @@ function testcafe(t, options = {}) {
|
|
|
763
763
|
return options.baseUrl === void 0 ? { driver: TESTCAFE_DRIVER, t } : { driver: TESTCAFE_DRIVER, t, baseUrl: options.baseUrl };
|
|
764
764
|
}
|
|
765
765
|
|
|
766
|
-
export {
|
|
766
|
+
export { TestCafeQuery, testcafe };
|
|
767
767
|
//# sourceMappingURL=index.js.map
|
|
768
768
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/driver-id.ts","../src/errors.ts","../src/page-functions.ts","../src/session.ts","../src/keys.ts","../src/testcafe-query.ts","../src/env.ts"],"names":["harnessedTarget","PAGE_API_GLOBAL","TestCafeSelector"],"mappings":";;;;;AACO,IAAM,eAAA,GAAkB;ACgB/B,IAAM,OAAA,GAAkC;AAAA,EACtC,GAAA,EAAK,oBAAA;AAAA,EACL,GAAA,EAAK,mBAAA;AAAA,EACL,GAAA,EAAK,sBAAA;AAAA,EACL,GAAA,EAAK,oBAAA;AAAA,EACL,GAAA,EAAK,0BAAA;AAAA,EACL,GAAA,EAAK,mCAAA;AAAA,EACL,GAAA,EAAK,uBAAA;AAAA,EACL,GAAA,EAAK,mCAAA;AAAA,EACL,GAAA,EAAK,sCAAA;AAAA,EACL,GAAA,EAAK,0CAAA;AAAA,EACL,GAAA,EAAK,iDAAA;AAAA,EACL,GAAA,EAAK,cAAA;AAAA,EACL,IAAA,EAAM;AACR,CAAA;AAEO,SAAS,UAAU,KAAA,EAAwB;AAChD,EAAA,IAAI,KAAA,YAAiB,KAAA,EAAO,OAAO,KAAA,CAAM,OAAA;AACzC,EAAA,MAAM,EAAE,MAAA,EAAO,GAAK,KAAA,IAAS,EAAC;AAC9B,EAAA,OAAO,OAAO,MAAA,KAAW,QAAA,GAAW,MAAA,GAAS,EAAA;AAC/C;AAWO,SAAS,OAAA,CAAQ,OAAgB,OAAA,EAAyB;AAC/D,EAAA,IAAI,KAAA,YAAiB,OAAO,OAAO,KAA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B,CAAA,EAAG,OAAA,EAAS,QAAQ,OAAA,EAAQ;AAC7D","file":"index.js","sourcesContent":["/** Its own module so `env.ts` and `testcafe-query.ts` can share it without a cycle. */\nexport const TESTCAFE_DRIVER = 'testcafe'\n","import { reviveStrictViolation } from '@harnessed-ts/core'\n\n/** A TestCafe error is a plain object; `errMsg` is the page's own error, stringified. */\ninterface TestCafeError {\n code?: string\n errMsg?: string\n /** A JavaScript error the page itself raised. */\n errStack?: string\n /** TestCafe's own explanation, which some codes carry (why a node is invisible). */\n reason?: string\n}\n\n/**\n * What the TestCafe codes an action most often fails with mean, in a sentence.\n * TestCafe renders these only in its own reporter, so without this a failure\n * reads as nothing but a code.\n */\nconst REASONS: Record<string, string> = {\n E24: 'nothing matches it',\n E26: 'it is not visible',\n E27: 'it is not an element',\n E31: 'it is not editable',\n E36: 'TestCafe has no such key',\n E39: \"the iframe's content did not load\",\n E40: 'it is not an <iframe>',\n E42: \"the iframe's content did not load\",\n E43: 'the iframe it is in no longer exists',\n E44: 'the iframe it is in is no longer visible',\n E49: 'the page unloaded while TestCafe was reading it',\n E84: 'it timed out',\n E101: 'another element covers it',\n}\n\nexport function messageOf(error: unknown): string {\n if (error instanceof Error) return error.message\n const { errMsg } = (error ?? {}) as TestCafeError\n return typeof errMsg === 'string' ? errMsg : ''\n}\n\n/**\n * TestCafe rejects with plain objects. The specs, the page package and any\n * `catch` in a test expect an `Error` whose message is the cause — for an error\n * thrown in the page that is the resolver's own wording, so a strict-mode\n * violation reads the same here as under every other driver, and comes back as\n * core's `StrictModeViolation`.\n *\n * `context` says what was being attempted, as a verb phrase: `act on testId(x)`.\n */\nexport function toError(error: unknown, context?: string): Error {\n if (error instanceof Error) return error\n const { code, errMsg, errStack, reason } = (error ?? {}) as TestCafeError\n if (typeof errMsg === 'string') {\n return reviveStrictViolation(\n new Error(errMsg.replace(/^[A-Za-z]*Error: /, ''), { cause: error }),\n )\n }\n // Anything else is TestCafe's own failure, which it renders from a code; say\n // what the code means, and keep the code and the original object so its\n // report stays reachable.\n const what = context === undefined ? 'TestCafe failed' : `TestCafe could not ${context}`\n const known = code === undefined ? undefined : REASONS[code]\n const detail = typeof reason === 'string' && reason.trim() !== '' ? `: ${reason.trim()}` : ''\n const why = known === undefined ? '' : `: ${known}${detail}`\n const which = code === undefined ? '' : ` (TestCafe error ${code})`\n const page = typeof errStack === 'string' ? `: the page raised ${errStack.split('\\n')[0]}` : ''\n return new Error(`harnessed: ${what}${why}${which}${page}.`, { cause: error })\n}\n","import type { PageApi, PageApiOptions, WireSelector } from '@harnessed-ts/resolve/inject'\n\n/**\n * Code that runs in the browser, not in Node.\n *\n * TestCafe ships a client function to the page as its source text, so nothing\n * here may close over a module binding — every value it needs is an argument\n * or a dependency, and every helper is declared inside the function that uses\n * it. No `async` either: TestCafe refuses client functions that compile to a\n * regenerator, so waiting is written with `.then`.\n */\n\n/** Thrown in the page when the resolver is not there and no source came with the call. */\nexport const NOT_INJECTED = 'harnessed:not-injected'\n\n/** Every operation answered by one round trip through `pageCall`. */\nexport type PageOp =\n | 'count'\n | 'texts'\n | 'text'\n | 'value'\n | 'attribute'\n | 'enabled'\n | 'checked'\n | 'selected'\n | 'visible'\n | 'hidden'\n | 'resolve'\n | 'editable'\n | 'focus'\n | 'blur'\n | 'select'\n | 'box'\n | 'fileTarget'\n\n/**\n * How a single-target operation looks for its node. `now` answers at once,\n * with `absent` when nothing matches yet, so the driver polls from Node; `wait`\n * waits in the page for `options.timeout`, and is what the last poll uses so\n * that a target never found fails in the resolver's own words. `count` and\n * `texts` never wait in the page: they answer `absent` while their scope is\n * not on screen, whichever lookup is asked for.\n */\nexport type Lookup = 'now' | 'wait'\n\n/** What a page call answers with: the value, and the top-level URL it was read at. */\nexport interface PageResult {\n value: unknown\n href: string\n /** A `now` lookup, or a list's scope, found nothing to answer about yet. */\n absent?: true\n}\n\n/** What `select` takes: the values to pick, and the target named for its errors. */\nexport interface SelectArg {\n values: string[]\n target: string\n}\n\n/**\n * Whether a node can be typed into: `ok`, why not yet (`disabled`, `readonly`),\n * or — when it is not a text control at all — its tag, as `<div>`.\n */\nexport type Editable = 'ok' | 'disabled' | 'readonly' | `<${string}>`\n\n/**\n * One client function for every read: compiled once per test, called with the\n * operation as an argument.\n *\n * `source` is the resolver's injectable build, or `null`. A document that lacks\n * the resolver installs it from the source in the same round trip; without a\n * source it refuses, and the driver calls again with one. `new Function` rather\n * than `eval`: TestCafe rewrites `eval` to process the code it runs, which costs\n * several times what installing the build does.\n *\n * The resolver is looked up in the top-most window that has it, so a call made\n * while TestCafe is switched into an iframe still resolves from the page's own\n * document — the scope chain crosses frames itself, exactly as it does under\n * every other resolver-based driver.\n */\nexport function pageCall(\n name: string,\n source: string | null,\n op: PageOp,\n scope: WireSelector[],\n selector: WireSelector,\n options: PageApiOptions,\n arg: unknown,\n lookup: Lookup,\n): PageResult | Promise<PageResult> {\n let api: PageApi | null = null\n let home: Window = window\n let current: Window = window\n for (;;) {\n try {\n const found = (current as unknown as Record<string, PageApi | undefined>)[name]\n if (found !== undefined) {\n api = found\n home = current\n }\n } catch {\n // A cross-origin ancestor: the resolver could not cross into it anyway.\n break\n }\n if (current === current.parent) break\n current = current.parent\n }\n if (api === null) {\n // NOT_INJECTED, spelled out: page code cannot reach a module constant.\n if (source === null) throw new Error('harnessed:not-injected')\n // The build installs itself as a global of the window it runs in.\n new Function(source)()\n api = (window as unknown as Record<string, PageApi>)[name]\n home = window\n }\n const resolver: PageApi = api\n const href = home.location.href\n const done = (value: unknown): PageResult => ({ value, href })\n\n // The shared layout rule, judged in each element's own document, carried on\n // through every iframe the scope entered: a hidden frame hides its content.\n const isVisible = (element: Element): boolean => {\n let node: Element | null = element\n while (node !== null) {\n if (!resolver.visible(node)) return false\n const view: Window | null = node.ownerDocument.defaultView\n node = view === null || view === home ? null : view.frameElement\n }\n return true\n }\n\n // The single target now, for a yes/no question: `null` when it is not there,\n // including an index past the last match. Everything else the resolver\n // raises still throws — ambiguity, a frame that cannot be entered, a\n // selector it refuses — since none of them is an answer.\n const present = (): Element | null => {\n try {\n return resolver.oneNow(null, scope, selector, options)\n } catch (error) {\n const message = (error as { message?: unknown } | null)?.message\n if (typeof message === 'string' && /^harnessed: index \\d+ is out of range/.test(message)) {\n return null\n }\n throw error\n }\n }\n\n // A single target. `now` hands back `null` for \"not there yet\"; the driver\n // polls, so a wait never holds TestCafe's one command queue for long.\n const target = (): Promise<Element | null> =>\n lookup === 'now'\n ? Promise.resolve(resolver.oneNow(null, scope, selector, options))\n : resolver.one(null, scope, selector, options)\n const withTarget = (read: (node: Element) => unknown): Promise<PageResult> =>\n target().then(node => (node === null ? { value: null, href, absent: true } : done(read(node))))\n\n // Every match now, or `null` while a link of the scope is not on screen yet —\n // the driver polls that, as it does a single target. The last link is looked\n // up as the element it names, so \"absent\" is told apart from what\n // `allNow` folds into an empty list: an ambiguous or out-of-range link, which\n // holds nothing at once, as `count` says under every driver. A frame that\n // cannot be entered still throws.\n const list = (): Element[] | null => {\n if (scope.length > 0) {\n const last = Object.assign({}, scope[scope.length - 1], { frame: false })\n let link: Element | null\n try {\n link = resolver.oneNow(null, scope.slice(0, -1), last, options)\n } catch (error) {\n if ((error as { name?: string } | null)?.name === 'FrameEntryError') throw error\n return []\n }\n if (link === null) return null\n }\n // `nth` picks one match, or none: a list read through `nth()` is that one.\n return resolver.allNow(null, scope, selector, options)\n }\n const withList = (read: (matches: Element[]) => unknown): PageResult => {\n const matches = list()\n return matches === null ? { value: null, href, absent: true } : done(read(matches))\n }\n\n switch (op) {\n case 'count':\n return withList(matches => matches.length)\n case 'texts':\n return withList(matches => matches.map(node => (node.textContent ?? '').trim()))\n case 'visible': {\n const node = present()\n return done(node !== null && isVisible(node))\n }\n case 'hidden': {\n const node = present()\n return done(node === null || !isVisible(node))\n }\n case 'text':\n return withTarget(node => (node.textContent ?? '').trim())\n case 'value':\n return withTarget(node => (node as HTMLInputElement).value ?? '')\n case 'attribute':\n return withTarget(node => node.getAttribute(arg as string))\n case 'enabled':\n // `disabled` is inherited from an ancestor fieldset; `:disabled` sees that\n // where the element's own attribute does not.\n return withTarget(node => [\n (node as HTMLInputElement).disabled === true || node.closest(':disabled') !== null,\n node.getAttribute('aria-disabled'),\n ])\n case 'checked':\n return withTarget(node => [\n node.getAttribute('aria-checked'),\n Boolean((node as HTMLInputElement).checked),\n ])\n case 'selected':\n return withTarget(node =>\n Array.prototype.map.call(\n (node as HTMLSelectElement).selectedOptions ?? [],\n (option: HTMLOptionElement) => option.value,\n ),\n )\n case 'resolve':\n return withTarget(() => null)\n case 'fileTarget':\n return withTarget(node => resolver.fileTarget(node))\n case 'box':\n // Measured in the node's own document, then offset by each frame up to `home`.\n return withTarget(node => {\n const box = resolver.box(node)\n if (box === null) return { x: 0, y: 0, width: 0, height: 0 }\n let view: Window | null = node.ownerDocument.defaultView\n while (view !== null && view !== home) {\n const frame: Element | null = view.frameElement\n if (frame === null) break\n const origin = resolver.origin(frame)\n box.x += origin.x\n box.y += origin.y\n view = frame.ownerDocument.defaultView\n }\n return box\n })\n case 'editable':\n // TestCafe's typeText types into the first editable descendant of a\n // wrapper, and does nothing at all to a disabled or readonly control; both\n // are refused before it is asked. So is an <input> that takes no text — a\n // checkbox, a file — which Playwright's fill refuses too, and a control\n // `aria-disabled` marks, which `isEnabled()` reads as disabled.\n return withTarget((node): Editable => {\n const input = node.localName === 'input'\n const control = input || node.localName === 'textarea'\n if (!control && !(node as HTMLElement).isContentEditable) return `<${node.localName}>`\n if (input) {\n const type = (node as HTMLInputElement).type.toLowerCase()\n // Typed into, or set as a value: the types Playwright's fill takes.\n const fillable =\n /^(?:|email|number|password|search|tel|text|url|color|date|time|datetime|datetime-local|month|range|week)$/\n if (!fillable.test(type)) return `<input type=\"${type}\">`\n }\n if (control && node.matches(':disabled')) return 'disabled'\n if (node.getAttribute('aria-disabled') === 'true') return 'disabled'\n if (control && (node as HTMLInputElement).readOnly) return 'readonly'\n return 'ok'\n })\n case 'focus':\n return withTarget(node => {\n ;(node as HTMLElement).focus()\n return null\n })\n case 'blur':\n return withTarget(node => {\n ;(node as HTMLElement).blur()\n return null\n })\n case 'select':\n return withTarget(node => {\n const { values, target: named } = arg as SelectArg\n if (node.localName !== 'select') {\n throw new Error(\n `harnessed: selectOption() needs a <select>, but ${named} is a <${node.localName}>.`,\n )\n }\n const element = node as HTMLSelectElement\n const all: HTMLOptionElement[] = Array.prototype.slice.call(element.options)\n // By value first, then by label — what Playwright's selectOption matches.\n const picked = values.map(value => {\n const option =\n all.find(candidate => candidate.value === value) ??\n all.find(candidate => candidate.label === value)\n if (option === undefined) {\n throw new Error(`harnessed: no <option> of ${named} matches \"${value}\".`)\n }\n return option\n })\n if (!element.multiple && picked.length > 1) {\n throw new Error(\n `harnessed: selectOption() was given several values for ${named}, a single-select.`,\n )\n }\n // Replaces the selection, as Playwright does, rather than adding to it.\n for (const option of all) option.selected = picked.includes(option)\n const view = element.ownerDocument.defaultView ?? window\n element.dispatchEvent(new view.Event('input', { bubbles: true, composed: true }))\n element.dispatchEvent(new view.Event('change', { bubbles: true }))\n return null\n })\n }\n}\n\n/**\n * The node an action targets, for a TestCafe `Selector`. Synchronous, as a\n * selector's init function must be: \"not there yet\" is an empty list and\n * TestCafe's own retry does the waiting. An empty list rather than `null` keeps\n * the return within TestCafe's declared selector types.\n */\nexport function pickTarget(): Element[] {\n // Dependencies, declared for the type checker. TestCafe defines each one as a\n // variable in the function's scope before running it.\n const { name, scope, selector, options, control } = harnessedTarget\n let api: PageApi | null = null\n let current: Window = window\n for (;;) {\n try {\n const found = (current as unknown as Record<string, PageApi | undefined>)[name]\n if (found !== undefined) api = found\n } catch {\n break\n }\n if (current === current.parent) break\n current = current.parent\n }\n if (api === null) return []\n const node = api.oneNow(null, scope, selector, options)\n if (node === null) return []\n // An upload through a <label> acts on the input it labels.\n const labelled = control === true && node.localName === 'label'\n const target = labelled ? (node as HTMLLabelElement).control : node\n return target === null ? [] : [target]\n}\n\n/** The shape of `pickTarget`'s one dependency. */\nexport interface TargetDependency {\n name: string\n scope: WireSelector[]\n selector: WireSelector\n options: PageApiOptions\n /** Pick a label's control instead of the label. */\n control?: boolean\n}\n\ndeclare const harnessedTarget: TargetDependency\n\n/** The current top-level URL, without needing the resolver. */\nexport function currentHref(): string {\n return window.location.href\n}\n\n/** The browser's platform, which decides what `ControlOrMeta` presses. */\nexport function browserPlatform(): string {\n return window.navigator.platform\n}\n","import { ClientFunction } from 'testcafe'\nimport { injectSource, PAGE_API_GLOBAL } from '@harnessed-ts/resolve/inject'\nimport type { PageApiOptions, WireSelector } from '@harnessed-ts/resolve/inject'\nimport { messageOf, toError } from './errors'\nimport { browserPlatform, currentHref, NOT_INJECTED, pageCall } from './page-functions'\nimport type { Lookup, PageOp, PageResult } from './page-functions'\n\n/**\n * What the driver keeps per test. Keyed by the controller: TestCafe hands every\n * test its own, and everything here belongs to exactly one test.\n */\nexport interface Session {\n /**\n * The top-level URL as of the last call that touched the page. `currentUrl`\n * is synchronous and TestCafe can only read the page asynchronously, so every\n * round trip brings the URL back with it and every action and navigation\n * refreshes it afterwards.\n */\n href: string | undefined\n /**\n * One round trip through the shared resolver. Under a `now` lookup a\n * single-target operation answers `absent` rather than waiting for its node.\n */\n read(\n op: PageOp,\n scope: WireSelector[],\n selector: WireSelector,\n options: PageApiOptions,\n arg: unknown,\n lookup: Lookup,\n ): Promise<PageResult>\n /** Re-read the top-level URL; needs no resolver, so it is safe after a navigation. */\n locate(): Promise<string>\n /** The browser's `navigator.platform`, read once: it does not change mid-test. */\n platform(): Promise<string>\n /**\n * Runs an operation that may switch TestCafe into an iframe. Switching is\n * state on the controller, so two such operations must never interleave —\n * and nor may a plain action, whose selector would run in the wrong window.\n */\n exclusive<T>(run: () => Promise<T>): Promise<T>\n /** The page was replaced: the next call carries the resolver with it. */\n navigated(): void\n}\n\nconst sessions = new WeakMap<TestController, Session>()\n\n/**\n * The `t` exported by 'testcafe' is one shared proxy that looks up whichever\n * test is running when it is used. A client function bound to it does not\n * bind, and a session keyed by it would be shared by every test — so only the\n * controller a test function is handed, which carries its own test run, will do.\n */\nexport function assertOwnController(t: TestController): void {\n if (typeof (t as { testRun?: unknown }).testRun !== 'object') {\n throw new Error(\n \"harnessed: pass the test function's own t, not the one imported from 'testcafe': \" +\n \"test('…', async t => { … testcafe(t) … }).\",\n )\n }\n}\n\n/**\n * The resolver, as TestCafe sees it. Client functions are compiled when they are\n * created, so they are built once per test and take the per-call values as\n * arguments. `boundTestRun` ties them to the test explicitly: TestCafe's own\n * test-run tracking follows its promise patches, which native `await` in a\n * compiled library does not go through.\n */\nexport function sessionFor(t: TestController): Session {\n const existing = sessions.get(t)\n if (existing !== undefined) return existing\n assertOwnController(t)\n\n const call = ClientFunction(pageCall, { boundTestRun: t })\n const href = ClientFunction(currentHref, { boundTestRun: t })\n const readPlatform = ClientFunction(browserPlatform, { boundTestRun: t })\n let platform: string | undefined\n let queue: Promise<unknown> = Promise.resolve()\n // A session starts on a page the driver has not seen, so its first call\n // carries the resolver. After that the source is sent only when the page may\n // be a fresh document — after a navigation, or once the URL has changed — and\n // when a call finds the resolver missing anyway.\n let carrySource = true\n const seen = (url: string): void => {\n if (session.href !== undefined && url !== session.href) carrySource = true\n session.href = url\n }\n\n const session: Session = {\n href: undefined,\n async read(op, scope, selector, options, arg, lookup) {\n // The page answers with a value or a promise of one; awaiting flattens both.\n const run = async (source: string | null): Promise<PageResult> =>\n await call(PAGE_API_GLOBAL, source, op, scope, selector, options, arg, lookup)\n let result: PageResult\n try {\n result = await run(carrySource ? injectSource() : null)\n } catch (error) {\n if (!messageOf(error).includes(NOT_INJECTED)) throw toError(error)\n try {\n result = await run(injectSource())\n } catch (retried) {\n throw toError(retried)\n }\n }\n carrySource = false\n session.href = result.href\n return result\n },\n async locate() {\n let current: string\n try {\n current = await href()\n } catch (error) {\n throw toError(error)\n }\n seen(current)\n return current\n },\n async platform() {\n if (platform === undefined) {\n try {\n platform = await readPlatform()\n } catch (error) {\n throw toError(error)\n }\n }\n return platform\n },\n navigated() {\n carrySource = true\n },\n exclusive(run) {\n const next = queue.then(run, run)\n queue = next.catch(() => undefined)\n return next\n },\n }\n sessions.set(t, session)\n return session\n}\n","/**\n * Playwright key names, which the shared `press()` takes, onto TestCafe's\n * `pressKey` names. TestCafe lowercases its own and shortens a few; a printable\n * character passes through, except a space, which `pressKey` would read as a\n * separator between two keys.\n */\nconst NAMES: Record<string, string> = {\n ' ': 'space',\n Space: 'space',\n Enter: 'enter',\n Tab: 'tab',\n Backspace: 'backspace',\n Delete: 'delete',\n Escape: 'esc',\n Insert: 'ins',\n Home: 'home',\n End: 'end',\n PageUp: 'pageup',\n PageDown: 'pagedown',\n ArrowUp: 'up',\n ArrowDown: 'down',\n ArrowLeft: 'left',\n ArrowRight: 'right',\n Control: 'ctrl',\n Shift: 'shift',\n Alt: 'alt',\n Meta: 'meta',\n CapsLock: 'capslock',\n}\n\n/**\n * Every multi-character name TestCafe's `pressKey` accepts: its modifiers and\n * its special keys. Anything else it rejects with an opaque \"incorrect key\"\n * error, so a name outside this set is refused here first, with the key named.\n */\nconst SUPPORTED = new Set([\n 'alt',\n 'ctrl',\n 'meta',\n 'shift',\n 'backspace',\n 'capslock',\n 'delete',\n 'down',\n 'end',\n 'enter',\n 'esc',\n 'home',\n 'ins',\n 'left',\n 'pagedown',\n 'pageup',\n 'right',\n 'space',\n 'tab',\n 'up',\n])\n\n/** A chord's parts. A lone `+` is the plus key, and `Control++` holds Control over it. */\nfunction parts(key: string): string[] {\n if (key.length <= 1) return [key]\n const plus = key.endsWith('++')\n const split = (plus ? key.slice(0, -2) : key).split('+')\n return plus ? [...split, '+'] : split\n}\n\nfunction toPart(part: string, platform: string | undefined): string | undefined {\n if (part === 'ControlOrMeta') {\n return platform !== undefined && /^(?:Mac|iP)/.test(platform) ? 'meta' : 'ctrl'\n }\n const code = /^(?:Key([A-Z])|Digit(\\d))$/.exec(part)\n if (code !== null) return (code[1] ?? code[2]!).toLowerCase()\n const named = NAMES[part]\n if (named !== undefined) return named\n if (part.length === 1) return part\n return SUPPORTED.has(part) ? part : undefined\n}\n\n/**\n * `Control+Shift+ArrowLeft` → `ctrl+shift+left`, `ControlOrMeta+KeyA` →\n * `meta+a` in a browser on macOS. Throws before anything is pressed for a key\n * TestCafe has no way to send, such as a function key.\n *\n * `platform` is the browser's `navigator.platform`, which only `ControlOrMeta`\n * reads: the browser may run on another machine than the test runner.\n */\nexport function toTestCafeKey(key: string, platform?: string): string {\n return parts(key)\n .map(part => {\n const mapped = toPart(part, platform)\n if (mapped === undefined) {\n throw new Error(\n `harnessed: press() cannot send \"${key}\" under TestCafe, which has no \"${part}\" key.`,\n )\n }\n return mapped\n })\n .join('+')\n}\n","import { Selector as TestCafeSelector } from 'testcafe'\nimport { Query, registerDriver, registerNavigation } from '@harnessed-ts/core'\nimport type { BoundingBox, EnvConfig, FileTarget, Selector } from '@harnessed-ts/core'\nimport type { WaitOptions, WaitState } from '@harnessed-ts/core'\nimport {\n checkedFrom,\n checkFileTarget,\n checkTestIds,\n describeScope,\n enabledFrom,\n getConfig,\n timeoutFor,\n} from '@harnessed-ts/core'\nimport { encodeSelector, filesOnDisk, PAGE_API_GLOBAL } from '@harnessed-ts/resolve/inject'\nimport type { PageApiOptions } from '@harnessed-ts/resolve/inject'\nimport { TESTCAFE_DRIVER } from './driver-id'\nimport type { TestCafeEnv } from './env'\nimport { toError } from './errors'\nimport { toTestCafeKey } from './keys'\nimport { pickTarget } from './page-functions'\nimport type { Editable, PageOp, SelectArg, TargetDependency } from './page-functions'\nimport { sessionFor } from './session'\nimport type { Session } from './session'\n\n/** How often a wait re-asks the page. Each ask is one short round trip. */\nconst POLL_MS = 50\n\n/**\n * The last poll of a single-target read waits in the page this long, so that a\n * target never found fails in the resolver's own words.\n */\nconst LAST_WAIT_MS = POLL_MS\n\n/** Why a text control cannot be typed into yet. */\nconst NOT_EDITABLE: Record<'disabled' | 'readonly', string> = {\n disabled: 'it is disabled',\n readonly: 'it is readonly',\n}\n\n/** A frame link's own element: the iframe itself, not the document inside it. */\nfunction unframed(link: Selector): Selector {\n return { ...link, frame: undefined }\n}\n\nfunction delay(ms: number): Promise<void> {\n return new Promise(resolve => setTimeout(resolve, ms))\n}\n\n/**\n * TestCafe driver. Every lookup runs the shared resolver inside the page, so\n * role, label, strictness, absence and frame semantics are the dom driver's by\n * construction; TestCafe performs the actions.\n *\n * Reads are client functions that return values, which can cross into a\n * same-origin frame from the top-level window. Actions need a TestCafe\n * `Selector`, whose node must belong to the window TestCafe is switched into —\n * so an action under a frame switches into each iframe in turn, acts, and\n * always switches back.\n *\n * TestCafe runs one command at a time, so nothing here waits inside the page\n * for long: a wait held open there would block every other call until it\n * settled — including after a caller such as `isReady()` has stopped\n * listening. Single-target and list reads poll from Node instead.\n */\nexport class TestCafeQuery extends Query {\n constructor(\n private readonly t: TestController,\n scope: readonly Selector[],\n selector: Selector,\n ) {\n super(scope, selector)\n }\n\n protected override clone(selector: Selector): Query {\n return new TestCafeQuery(this.t, this.scope, selector)\n }\n\n private get session(): Session {\n return sessionFor(this.t)\n }\n\n private get described(): string {\n return describeScope(this.scope, this.selector)\n }\n\n /** Runtime config travels with every call: the page cannot see `configure()`. */\n private pageOptions(timeout?: number): PageApiOptions {\n // Refused here, so the page never folds a refusal into \"nothing there\".\n checkTestIds(this.scope, this.selector)\n return { testIdAttribute: getConfig().testIdAttribute, timeout: timeoutFor(timeout) }\n }\n\n /** One round trip, answered at once. */\n private async read<T>(op: PageOp, options?: WaitOptions, arg?: unknown): Promise<T> {\n const result = await this.session.read(\n op,\n this.scope.map(encodeSelector),\n encodeSelector(this.selector),\n this.pageOptions(options?.timeout),\n arg,\n 'now',\n )\n return result.value as T\n }\n\n /**\n * A list operation, polled from Node until its scope is there, as every\n * driver waits for the scope; the list itself answers at once. A scope that\n * never appears holds nothing, so the deadline answers `empty` rather than\n * failing.\n */\n private async readList<T>(op: 'count' | 'texts', empty: T): Promise<T> {\n const timeout = timeoutFor()\n const deadline = Date.now() + timeout\n const scope = this.scope.map(encodeSelector)\n const selector = encodeSelector(this.selector)\n for (;;) {\n const result = await this.session.read(\n op,\n scope,\n selector,\n this.pageOptions(timeout),\n undefined,\n 'now',\n )\n if (result.absent !== true) return result.value as T\n if (Date.now() >= deadline) return empty\n await delay(POLL_MS)\n }\n }\n\n /**\n * A single-target operation, polled from Node until its node is there. The\n * last poll waits briefly in the page, so a target that never appears fails\n * with the resolver's own message; a strict violation fails on the first.\n */\n private async readOne<T>(op: PageOp, options?: WaitOptions, arg?: unknown): Promise<T> {\n const timeout = timeoutFor(options?.timeout)\n const deadline = Date.now() + timeout\n const scope = this.scope.map(encodeSelector)\n const selector = encodeSelector(this.selector)\n for (;;) {\n const last = Date.now() >= deadline\n const result = await this.session.read(\n op,\n scope,\n selector,\n this.pageOptions(last ? LAST_WAIT_MS : timeout),\n arg,\n last ? 'wait' : 'now',\n )\n if (result.absent !== true) return result.value as T\n await delay(POLL_MS)\n }\n }\n\n /** A TestCafe selector for one link of the chain, resolved by the same resolver. */\n private selectorFor(\n scope: readonly Selector[],\n selector: Selector,\n timeout: number,\n control = false,\n ): ReturnType<typeof TestCafeSelector> {\n const harnessedTarget: TargetDependency = {\n name: PAGE_API_GLOBAL,\n scope: scope.map(encodeSelector),\n selector: encodeSelector(selector),\n options: this.pageOptions(timeout),\n control,\n }\n return TestCafeSelector(pickTarget, {\n dependencies: { harnessedTarget },\n boundTestRun: this.t,\n timeout,\n })\n }\n\n /**\n * Runs a TestCafe action against this query's node.\n *\n * The resolver answers first, from the page: that is what makes a strict\n * violation, a missing target or a frame marker on a non-iframe fail at once\n * with the shared wording. An error thrown inside a TestCafe selector is\n * instead retried until the selector times out, and a strict violation never\n * becomes a single match by waiting. `prepare` then refuses what TestCafe\n * would get silently wrong, within the same deadline. After that, TestCafe's\n * own selectors only have to wait for the node to be actionable — each frame\n * switch and the action given what is left of that one deadline, so the\n * whole operation fails within the caller's timeout.\n */\n private act(\n run: (target: ReturnType<typeof TestCafeSelector>, deadline: number) => Promise<unknown>,\n options?: WaitOptions,\n prepare?: (deadline: number, timeout: number) => Promise<void>,\n control = false,\n ): Promise<void> {\n return this.session.exclusive(async () => {\n const timeout = timeoutFor(options?.timeout)\n const deadline = Date.now() + timeout\n await this.readOne('resolve', { timeout })\n if (prepare !== undefined) await prepare(deadline, timeout)\n const remaining = (): number => Math.max(deadline - Date.now(), 0)\n const frames = this.scope.flatMap((link, index) => (link.frame === true ? [index] : []))\n try {\n for (const index of frames) {\n await this.t.switchToIframe(\n this.selectorFor(this.scope.slice(0, index), unframed(this.scope[index]!), remaining()),\n )\n }\n await run(this.selectorFor(this.scope, this.selector, remaining(), control), deadline)\n } catch (error) {\n throw toError(error, `act on ${this.described}`)\n } finally {\n if (frames.length > 0) await this.t.switchToMainWindow()\n }\n // An action can navigate; `currentUrl` must not report the page it left.\n await this.session.locate()\n })\n }\n\n /**\n * Waits until the target can be typed into, and refuses one that never can.\n * TestCafe's typeText would otherwise do nothing to a disabled or readonly\n * control, and type into the first editable descendant of a wrapper.\n */\n private async editable(action: 'fill' | 'clear', deadline: number, timeout: number) {\n for (;;) {\n const state = await this.readOne<Editable>('editable', {\n timeout: Math.max(deadline - Date.now(), 0),\n })\n if (state === 'ok') return\n if (state !== 'disabled' && state !== 'readonly') {\n throw new Error(\n `harnessed: ${action}() needs an <input>, <textarea> or [contenteditable] element, but ${this.described} is a ${state}.`,\n )\n }\n if (Date.now() >= deadline) {\n throw new Error(\n `harnessed: ${action}() could not edit ${this.described} within ${timeout}ms: ${NOT_EDITABLE[state]}.`,\n )\n }\n await delay(POLL_MS)\n }\n }\n\n // --- interactions -------------------------------------------------------\n\n override async click(options?: WaitOptions): Promise<void> {\n await this.act(target => this.t.click(target), options)\n }\n\n override async fill(value: string, options?: WaitOptions): Promise<void> {\n await this.replaceValue('fill', value, options)\n }\n\n override async clear(options?: WaitOptions): Promise<void> {\n await this.replaceValue('clear', '', options)\n }\n\n /**\n * Replaces the value, as Playwright's `fill()` does. `paste` sets the whole\n * value in one input event rather than typing character by character; an\n * empty value — which typeText refuses — selects what is there and deletes\n * it, so `fill('')` and `clear()` are one operation with one set of checks.\n */\n private async replaceValue(\n action: 'fill' | 'clear',\n value: string,\n options?: WaitOptions,\n ): Promise<void> {\n await this.act(\n target =>\n value === ''\n ? this.t.selectText(target).pressKey('delete')\n : this.t.typeText(target, value, { replace: true, paste: true }),\n options,\n (deadline, timeout) => this.editable(action, deadline, timeout),\n )\n }\n\n override async check(options?: WaitOptions): Promise<void> {\n if (!(await this.isChecked(options))) await this.click(options)\n }\n\n override async uncheck(options?: WaitOptions): Promise<void> {\n if (await this.isChecked(options)) await this.click(options)\n }\n\n /**\n * TestCafe has no select API, and driving a native dropdown by clicking is\n * platform-dependent. The selection is set in the page and `input` and\n * `change` dispatched — what Playwright's selectOption does — replacing any\n * existing selection of a multi-select. A change handler can navigate, so\n * this is an action like any other: it takes its turn, and re-reads the URL.\n */\n override async selectOption(value: string | string[], options?: WaitOptions): Promise<void> {\n const arg: SelectArg = {\n values: Array.isArray(value) ? value : [value],\n target: this.described,\n }\n await this.session.exclusive(async () => {\n await this.readOne('select', options, arg)\n await this.session.locate()\n })\n }\n\n /**\n * TestCafe sets files only from paths, so each File is written to disk first\n * (see `filesOnDisk`): the name and bytes arrive, and the type is inferred\n * from the extension.\n */\n override async upload(files: File | File[], options?: WaitOptions): Promise<void> {\n const list = Array.isArray(files) ? files : [files]\n let paths: string[] = []\n await this.act(\n target => this.t.setFilesToUpload(target, paths),\n options,\n async (deadline: number) => {\n const target = await this.readOne<FileTarget>('fileTarget', {\n timeout: Math.max(deadline - Date.now(), 0),\n })\n checkFileTarget(target, list.length, this.scope, this.selector)\n paths = await filesOnDisk(list)\n },\n true,\n )\n }\n\n override async hover(options?: WaitOptions): Promise<void> {\n await this.act(target => this.t.hover(target), options)\n }\n\n override async focus(options?: WaitOptions): Promise<void> {\n await this.readOne('focus', options)\n }\n\n override async blur(options?: WaitOptions): Promise<void> {\n await this.readOne('blur', options)\n }\n\n /**\n * Focuses the target first, as Playwright's press does; keys go to the\n * focused node. The key is checked before anything happens, and the focus\n * spends only what is left of the one timeout. `ControlOrMeta` follows the\n * browser's platform, which may not be the test runner's.\n */\n override async press(key: string, options?: WaitOptions): Promise<void> {\n const platform = key.includes('ControlOrMeta') ? await this.session.platform() : undefined\n const keys = toTestCafeKey(key, platform)\n await this.act(async (_target, deadline) => {\n await this.readOne('focus', { timeout: Math.max(deadline - Date.now(), 0) })\n await this.t.pressKey(keys)\n }, options)\n }\n\n // --- observations -------------------------------------------------------\n\n override async text(options?: WaitOptions): Promise<string> {\n return this.readOne<string>('text', options)\n }\n\n override async inputValue(options?: WaitOptions): Promise<string> {\n return this.readOne<string>('value', options)\n }\n\n override async attribute(name: string, options?: WaitOptions): Promise<string | null> {\n return this.readOne<string | null>('attribute', options, name)\n }\n\n override async boundingBox(options?: WaitOptions): Promise<BoundingBox> {\n return this.readOne<BoundingBox>('box', options)\n }\n\n /** Answers at once, as Playwright's does: an absent target is not visible. */\n override async isVisible(options?: WaitOptions): Promise<boolean> {\n return this.read<boolean>('visible', options)\n }\n\n override async isEnabled(options?: WaitOptions): Promise<boolean> {\n const [disabled, ariaDisabled] = await this.readOne<[boolean, string | null]>(\n 'enabled',\n options,\n )\n return enabledFrom(disabled, ariaDisabled)\n }\n\n override async isChecked(options?: WaitOptions): Promise<boolean> {\n const [aria, native] = await this.readOne<[string | null, boolean]>('checked', options)\n return checkedFrom(aria, native)\n }\n\n override async selectedOptions(options?: WaitOptions): Promise<string[]> {\n return this.readOne<string[]>('selected', options)\n }\n\n // --- waiting ------------------------------------------------------------\n\n /** Polls from Node rather than waiting inside the page, as every read here does. */\n override async waitFor(state: WaitState, options?: WaitOptions): Promise<void> {\n const timeout = timeoutFor(options?.timeout)\n const deadline = Date.now() + timeout\n for (;;) {\n if (await this.read<boolean>(state, { timeout })) return\n if (Date.now() >= deadline) {\n throw new Error(`harnessed: ${this.described} did not become ${state} within ${timeout}ms.`)\n }\n await delay(POLL_MS)\n }\n }\n\n /** Waits for the scope chain, as every driver does; the count itself answers at once. */\n override async count(): Promise<number> {\n return this.readList<number>('count', 0)\n }\n\n /** Every match read in one round trip, once the scope is there; trimmed to match `text()`. */\n override async texts(): Promise<string[]> {\n return this.readList<string[]>('texts', [])\n }\n}\n\nregisterDriver(TESTCAFE_DRIVER, (env: EnvConfig, scope, selector) => {\n return new TestCafeQuery((env as TestCafeEnv).t, scope, selector)\n})\n\n/**\n * This driver can navigate. A relative path resolves against the env's\n * `baseUrl` when it has one, and otherwise against the page the test is on.\n */\nregisterNavigation(TESTCAFE_DRIVER, {\n async goto(env, url) {\n const { t, baseUrl } = env as TestCafeEnv\n const session = sessionFor(t)\n const base = baseUrl ?? (await session.locate())\n let target: string\n try {\n target = new URL(url, base).href\n } catch {\n throw new Error(\n `harnessed: cannot resolve \"${url}\" against ${base}. Navigate to the app first, or pass ` +\n '`baseUrl` to testcafe(t, { baseUrl }).',\n )\n }\n try {\n await t.navigateTo(target)\n } catch (error) {\n throw toError(error, `navigate to ${target}`)\n } finally {\n // A new document, which has no resolver until one is sent.\n session.navigated()\n }\n await session.locate()\n },\n currentUrl(env) {\n const { href } = sessionFor((env as TestCafeEnv).t)\n if (href === undefined) {\n throw new Error(\n 'harnessed: the testcafe driver has not read the URL yet. TestCafe reads the page ' +\n 'asynchronously, so the URL is learned from goto() and from every harness call — ' +\n 'make one of those first.',\n )\n }\n return href\n },\n async waitForUrl(env, matches, timeout) {\n const session = sessionFor((env as TestCafeEnv).t)\n const deadline = Date.now() + timeout\n for (;;) {\n const href = await session.locate()\n if (matches(new URL(href))) return\n if (Date.now() >= deadline) {\n throw new Error(`harnessed: the URL did not match within ${timeout}ms; it is ${href}.`)\n }\n await delay(POLL_MS)\n }\n },\n})\n","/// <reference types=\"testcafe\" />\nimport type { EnvConfig } from '@harnessed-ts/core'\nimport { TESTCAFE_DRIVER } from './driver-id'\nimport { assertOwnController } from './session'\n// Side effect: constructing an env is the moment the driver has to be registered.\nimport './testcafe-query'\n\nexport { TESTCAFE_DRIVER }\n\nexport interface TestCafeEnv extends EnvConfig {\n readonly driver: typeof TESTCAFE_DRIVER\n /** The test's controller. Every action goes through it, so an env is per test. */\n readonly t: TestController\n /**\n * What a page's relative path resolves against in `goto()`. Without it, the\n * page the test is on — which is the fixture's page when a test starts.\n */\n readonly baseUrl?: string\n}\n\nexport interface TestCafeEnvOptions {\n baseUrl?: string\n}\n\n/**\n * Builds the env a harness is constructed with under TestCafe. `t` is the one\n * the test function is handed — not the shared `t` exported by 'testcafe',\n * which belongs to no one test.\n */\nexport function testcafe(t: TestController, options: TestCafeEnvOptions = {}): TestCafeEnv {\n assertOwnController(t)\n return options.baseUrl === undefined\n ? { driver: TESTCAFE_DRIVER, t }\n : { driver: TESTCAFE_DRIVER, t, baseUrl: options.baseUrl }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/errors.ts","../src/page-functions.ts","../src/session.ts","../src/keys.ts","../src/testcafe-query.ts","../src/env.ts"],"names":["harnessedTarget","PAGE_API_GLOBAL","TestCafeSelector"],"mappings":";;;;;;AAiBA,IAAM,OAAA,GAAkC;AAAA,EACtC,GAAA,EAAK,oBAAA;AAAA,EACL,GAAA,EAAK,mBAAA;AAAA,EACL,GAAA,EAAK,sBAAA;AAAA,EACL,GAAA,EAAK,oBAAA;AAAA,EACL,GAAA,EAAK,0BAAA;AAAA,EACL,GAAA,EAAK,mCAAA;AAAA,EACL,GAAA,EAAK,uBAAA;AAAA,EACL,GAAA,EAAK,mCAAA;AAAA,EACL,GAAA,EAAK,sCAAA;AAAA,EACL,GAAA,EAAK,0CAAA;AAAA,EACL,GAAA,EAAK,iDAAA;AAAA,EACL,GAAA,EAAK,cAAA;AAAA,EACL,IAAA,EAAM;AACR,CAAA;AAEO,SAAS,UAAU,KAAA,EAAwB;AAChD,EAAA,IAAI,KAAA,YAAiB,KAAA,EAAO,OAAO,KAAA,CAAM,OAAA;AACzC,EAAA,MAAM,EAAE,MAAA,EAAO,GAAK,KAAA,IAAS,EAA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;AACzF,EAAA,mBAAA,CAAoB,CAAC,CAAA;AACrB,EAAA,OAAO,OAAA,CAAQ,OAAA,KAAY,MAAA,GACvB,EAAE,QAAQ,eAAA,EAAiB,CAAA,EAAE,GAC7B,EAAE,MAAA,EAAQ,eAAA,EAAiB,CAAA,EAAG,OAAA,EAAS,QAAQ,OAAA,EAAQ;AAC7D","file":"index.js","sourcesContent":["import { reviveStrictViolation } from '@harnessed-ts/core'\n\n/** A TestCafe error is a plain object; `errMsg` is the page's own error, stringified. */\ninterface TestCafeError {\n code?: string\n errMsg?: string\n /** A JavaScript error the page itself raised. */\n errStack?: string\n /** TestCafe's own explanation, which some codes carry (why a node is invisible). */\n reason?: string\n}\n\n/**\n * What the TestCafe codes an action most often fails with mean, in a sentence.\n * TestCafe renders these only in its own reporter, so without this a failure\n * reads as nothing but a code.\n */\nconst REASONS: Record<string, string> = {\n E24: 'nothing matches it',\n E26: 'it is not visible',\n E27: 'it is not an element',\n E31: 'it is not editable',\n E36: 'TestCafe has no such key',\n E39: \"the iframe's content did not load\",\n E40: 'it is not an <iframe>',\n E42: \"the iframe's content did not load\",\n E43: 'the iframe it is in no longer exists',\n E44: 'the iframe it is in is no longer visible',\n E49: 'the page unloaded while TestCafe was reading it',\n E84: 'it timed out',\n E101: 'another element covers it',\n}\n\nexport function messageOf(error: unknown): string {\n if (error instanceof Error) return error.message\n const { errMsg } = (error ?? {}) as TestCafeError\n return typeof errMsg === 'string' ? errMsg : ''\n}\n\n/**\n * TestCafe rejects with plain objects. The specs, the page package and any\n * `catch` in a test expect an `Error` whose message is the cause — for an error\n * thrown in the page that is the resolver's own wording, so a strict-mode\n * violation reads the same here as under every other driver, and comes back as\n * core's `StrictModeViolation`.\n *\n * `context` says what was being attempted, as a verb phrase: `act on testId(x)`.\n */\nexport function toError(error: unknown, context?: string): Error {\n if (error instanceof Error) return error\n const { code, errMsg, errStack, reason } = (error ?? {}) as TestCafeError\n if (typeof errMsg === 'string') {\n return reviveStrictViolation(\n new Error(errMsg.replace(/^[A-Za-z]*Error: /, ''), { cause: error }),\n )\n }\n // Anything else is TestCafe's own failure, which it renders from a code; say\n // what the code means, and keep the code and the original object so its\n // report stays reachable.\n const what = context === undefined ? 'TestCafe failed' : `TestCafe could not ${context}`\n const known = code === undefined ? undefined : REASONS[code]\n const detail = typeof reason === 'string' && reason.trim() !== '' ? `: ${reason.trim()}` : ''\n const why = known === undefined ? '' : `: ${known}${detail}`\n const which = code === undefined ? '' : ` (TestCafe error ${code})`\n const page = typeof errStack === 'string' ? `: the page raised ${errStack.split('\\n')[0]}` : ''\n return new Error(`harnessed: ${what}${why}${which}${page}.`, { cause: error })\n}\n","import type { PageApi, PageApiOptions, WireSelector } from '@harnessed-ts/resolve/inject'\n\n/**\n * Code that runs in the browser, not in Node.\n *\n * TestCafe ships a client function to the page as its source text, so nothing\n * here may close over a module binding — every value it needs is an argument\n * or a dependency, and every helper is declared inside the function that uses\n * it. No `async` either: TestCafe refuses client functions that compile to a\n * regenerator, so waiting is written with `.then`.\n */\n\n/** Thrown in the page when the resolver is not there and no source came with the call. */\nexport const NOT_INJECTED = 'harnessed:not-injected'\n\n/** Every operation answered by one round trip through `pageCall`. */\nexport type PageOp =\n | 'count'\n | 'texts'\n | 'text'\n | 'value'\n | 'attribute'\n | 'enabled'\n | 'checked'\n | 'selected'\n | 'visible'\n | 'hidden'\n | 'resolve'\n | 'editable'\n | 'focus'\n | 'blur'\n | 'select'\n | 'box'\n | 'fileTarget'\n\n/**\n * How a single-target operation looks for its node. `now` answers at once,\n * with `absent` when nothing matches yet, so the driver polls from Node; `wait`\n * waits in the page for `options.timeout`, and is what the last poll uses so\n * that a target never found fails in the resolver's own words. `count` and\n * `texts` never wait in the page: they answer `absent` while their scope is\n * not on screen, whichever lookup is asked for.\n */\nexport type Lookup = 'now' | 'wait'\n\n/** What a page call answers with: the value, and the top-level URL it was read at. */\nexport interface PageResult {\n value: unknown\n href: string\n /** A `now` lookup, or a list's scope, found nothing to answer about yet. */\n absent?: true\n}\n\n/** What `select` takes: the values to pick, and the target named for its errors. */\nexport interface SelectArg {\n values: string[]\n target: string\n}\n\n/**\n * Whether a node can be typed into: `ok`, why not yet (`disabled`, `readonly`),\n * or — when it is not a text control at all — its tag, as `<div>`.\n */\nexport type Editable = 'ok' | 'disabled' | 'readonly' | `<${string}>`\n\n/**\n * One client function for every read: compiled once per test, called with the\n * operation as an argument.\n *\n * `source` is the resolver's injectable build, or `null`. A document that lacks\n * the resolver installs it from the source in the same round trip; without a\n * source it refuses, and the driver calls again with one. `new Function` rather\n * than `eval`: TestCafe rewrites `eval` to process the code it runs, which costs\n * several times what installing the build does.\n *\n * The resolver is looked up in the top-most window that has it, so a call made\n * while TestCafe is switched into an iframe still resolves from the page's own\n * document — the scope chain crosses frames itself, exactly as it does under\n * every other resolver-based driver.\n */\nexport function pageCall(\n name: string,\n source: string | null,\n op: PageOp,\n scope: WireSelector[],\n selector: WireSelector,\n options: PageApiOptions,\n arg: unknown,\n lookup: Lookup,\n): PageResult | Promise<PageResult> {\n let api: PageApi | null = null\n let home: Window = window\n let current: Window = window\n for (;;) {\n try {\n const found = (current as unknown as Record<string, PageApi | undefined>)[name]\n if (found !== undefined) {\n api = found\n home = current\n }\n } catch {\n // A cross-origin ancestor: the resolver could not cross into it anyway.\n break\n }\n if (current === current.parent) break\n current = current.parent\n }\n if (api === null) {\n // NOT_INJECTED, spelled out: page code cannot reach a module constant.\n if (source === null) throw new Error('harnessed:not-injected')\n // The build installs itself as a global of the window it runs in.\n new Function(source)()\n api = (window as unknown as Record<string, PageApi>)[name]\n home = window\n }\n const resolver: PageApi = api\n const href = home.location.href\n const done = (value: unknown): PageResult => ({ value, href })\n\n // The shared layout rule, judged in each element's own document, carried on\n // through every iframe the scope entered: a hidden frame hides its content.\n const isVisible = (element: Element): boolean => {\n let node: Element | null = element\n while (node !== null) {\n if (!resolver.visible(node)) return false\n const view: Window | null = node.ownerDocument.defaultView\n node = view === null || view === home ? null : view.frameElement\n }\n return true\n }\n\n // The single target now, for a yes/no question: `null` when it is not there,\n // including an index past the last match. Everything else the resolver\n // raises still throws — ambiguity, a frame that cannot be entered, a\n // selector it refuses — since none of them is an answer.\n const present = (): Element | null => {\n try {\n return resolver.oneNow(null, scope, selector, options)\n } catch (error) {\n const message = (error as { message?: unknown } | null)?.message\n if (typeof message === 'string' && /^harnessed: index \\d+ is out of range/.test(message)) {\n return null\n }\n throw error\n }\n }\n\n // A single target. `now` hands back `null` for \"not there yet\"; the driver\n // polls, so a wait never holds TestCafe's one command queue for long.\n const target = (): Promise<Element | null> =>\n lookup === 'now'\n ? Promise.resolve(resolver.oneNow(null, scope, selector, options))\n : resolver.one(null, scope, selector, options)\n const withTarget = (read: (node: Element) => unknown): Promise<PageResult> =>\n target().then(node => (node === null ? { value: null, href, absent: true } : done(read(node))))\n\n // Every match now, or `null` while a link of the scope is not on screen yet —\n // the driver polls that, as it does a single target. The last link is looked\n // up as the element it names, so \"absent\" is told apart from what\n // `allNow` folds into an empty list: an ambiguous or out-of-range link, which\n // holds nothing at once, as `count` says under every driver. A frame that\n // cannot be entered still throws.\n const list = (): Element[] | null => {\n if (scope.length > 0) {\n const last = Object.assign({}, scope[scope.length - 1], { frame: false })\n let link: Element | null\n try {\n link = resolver.oneNow(null, scope.slice(0, -1), last, options)\n } catch (error) {\n if ((error as { name?: string } | null)?.name === 'FrameEntryError') throw error\n return []\n }\n if (link === null) return null\n }\n // `nth` picks one match, or none: a list read through `nth()` is that one.\n return resolver.allNow(null, scope, selector, options)\n }\n const withList = (read: (matches: Element[]) => unknown): PageResult => {\n const matches = list()\n return matches === null ? { value: null, href, absent: true } : done(read(matches))\n }\n\n switch (op) {\n case 'count':\n return withList(matches => matches.length)\n case 'texts':\n return withList(matches => matches.map(node => (node.textContent ?? '').trim()))\n case 'visible': {\n const node = present()\n return done(node !== null && isVisible(node))\n }\n case 'hidden': {\n const node = present()\n return done(node === null || !isVisible(node))\n }\n case 'text':\n return withTarget(node => (node.textContent ?? '').trim())\n case 'value':\n return withTarget(node => (node as HTMLInputElement).value ?? '')\n case 'attribute':\n return withTarget(node => node.getAttribute(arg as string))\n case 'enabled':\n // `disabled` is inherited from an ancestor fieldset; `:disabled` sees that\n // where the element's own attribute does not.\n return withTarget(node => [\n (node as HTMLInputElement).disabled === true || node.closest(':disabled') !== null,\n node.getAttribute('aria-disabled'),\n ])\n case 'checked':\n return withTarget(node => [\n node.getAttribute('aria-checked'),\n Boolean((node as HTMLInputElement).checked),\n ])\n case 'selected':\n return withTarget(node =>\n Array.prototype.map.call(\n (node as HTMLSelectElement).selectedOptions ?? [],\n (option: HTMLOptionElement) => option.value,\n ),\n )\n case 'resolve':\n return withTarget(() => null)\n case 'fileTarget':\n return withTarget(node => resolver.fileTarget(node))\n case 'box':\n // Measured in the node's own document, then offset by each frame up to `home`.\n return withTarget(node => {\n const box = resolver.box(node)\n if (box === null) return { x: 0, y: 0, width: 0, height: 0 }\n let view: Window | null = node.ownerDocument.defaultView\n while (view !== null && view !== home) {\n const frame: Element | null = view.frameElement\n if (frame === null) break\n const origin = resolver.origin(frame)\n box.x += origin.x\n box.y += origin.y\n view = frame.ownerDocument.defaultView\n }\n return box\n })\n case 'editable':\n // TestCafe's typeText types into the first editable descendant of a\n // wrapper, and does nothing at all to a disabled or readonly control; both\n // are refused before it is asked. So is an <input> that takes no text — a\n // checkbox, a file — which Playwright's fill refuses too, and a control\n // `aria-disabled` marks, which `isEnabled()` reads as disabled.\n return withTarget((node): Editable => {\n const input = node.localName === 'input'\n const control = input || node.localName === 'textarea'\n if (!control && !(node as HTMLElement).isContentEditable) return `<${node.localName}>`\n if (input) {\n const type = (node as HTMLInputElement).type.toLowerCase()\n // Typed into, or set as a value: the types Playwright's fill takes.\n const fillable =\n /^(?:|email|number|password|search|tel|text|url|color|date|time|datetime|datetime-local|month|range|week)$/\n if (!fillable.test(type)) return `<input type=\"${type}\">`\n }\n if (control && node.matches(':disabled')) return 'disabled'\n if (node.getAttribute('aria-disabled') === 'true') return 'disabled'\n if (control && (node as HTMLInputElement).readOnly) return 'readonly'\n return 'ok'\n })\n case 'focus':\n return withTarget(node => {\n ;(node as HTMLElement).focus()\n return null\n })\n case 'blur':\n return withTarget(node => {\n ;(node as HTMLElement).blur()\n return null\n })\n case 'select':\n return withTarget(node => {\n const { values, target: named } = arg as SelectArg\n if (node.localName !== 'select') {\n throw new Error(\n `harnessed: selectOption() needs a <select>, but ${named} is a <${node.localName}>.`,\n )\n }\n const element = node as HTMLSelectElement\n const all: HTMLOptionElement[] = Array.prototype.slice.call(element.options)\n // By value first, then by label — what Playwright's selectOption matches.\n const picked = values.map(value => {\n const option =\n all.find(candidate => candidate.value === value) ??\n all.find(candidate => candidate.label === value)\n if (option === undefined) {\n throw new Error(`harnessed: no <option> of ${named} matches \"${value}\".`)\n }\n return option\n })\n if (!element.multiple && picked.length > 1) {\n throw new Error(\n `harnessed: selectOption() was given several values for ${named}, a single-select.`,\n )\n }\n // Replaces the selection, as Playwright does, rather than adding to it.\n for (const option of all) option.selected = picked.includes(option)\n const view = element.ownerDocument.defaultView ?? window\n element.dispatchEvent(new view.Event('input', { bubbles: true, composed: true }))\n element.dispatchEvent(new view.Event('change', { bubbles: true }))\n return null\n })\n }\n}\n\n/**\n * The node an action targets, for a TestCafe `Selector`. Synchronous, as a\n * selector's init function must be: \"not there yet\" is an empty list and\n * TestCafe's own retry does the waiting. An empty list rather than `null` keeps\n * the return within TestCafe's declared selector types.\n */\nexport function pickTarget(): Element[] {\n // Dependencies, declared for the type checker. TestCafe defines each one as a\n // variable in the function's scope before running it.\n const { name, scope, selector, options, control } = harnessedTarget\n let api: PageApi | null = null\n let current: Window = window\n for (;;) {\n try {\n const found = (current as unknown as Record<string, PageApi | undefined>)[name]\n if (found !== undefined) api = found\n } catch {\n break\n }\n if (current === current.parent) break\n current = current.parent\n }\n if (api === null) return []\n const node = api.oneNow(null, scope, selector, options)\n if (node === null) return []\n // An upload through a <label> acts on the input it labels.\n const labelled = control === true && node.localName === 'label'\n const target = labelled ? (node as HTMLLabelElement).control : node\n return target === null ? [] : [target]\n}\n\n/** The shape of `pickTarget`'s one dependency. */\nexport interface TargetDependency {\n name: string\n scope: WireSelector[]\n selector: WireSelector\n options: PageApiOptions\n /** Pick a label's control instead of the label. */\n control?: boolean\n}\n\ndeclare const harnessedTarget: TargetDependency\n\n/** The current top-level URL, without needing the resolver. */\nexport function currentHref(): string {\n return window.location.href\n}\n\n/** The browser's platform, which decides what `ControlOrMeta` presses. */\nexport function browserPlatform(): string {\n return window.navigator.platform\n}\n","import { ClientFunction } from 'testcafe'\nimport { injectSource, PAGE_API_GLOBAL } from '@harnessed-ts/resolve/inject'\nimport type { PageApiOptions, WireSelector } from '@harnessed-ts/resolve/inject'\nimport { messageOf, toError } from './errors'\nimport { browserPlatform, currentHref, NOT_INJECTED, pageCall } from './page-functions'\nimport type { Lookup, PageOp, PageResult } from './page-functions'\n\n/**\n * What the driver keeps per test. Keyed by the controller: TestCafe hands every\n * test its own, and everything here belongs to exactly one test.\n */\nexport interface Session {\n /**\n * The top-level URL as of the last call that touched the page. `currentUrl`\n * is synchronous and TestCafe can only read the page asynchronously, so every\n * round trip brings the URL back with it and every action and navigation\n * refreshes it afterwards.\n */\n href: string | undefined\n /**\n * One round trip through the shared resolver. Under a `now` lookup a\n * single-target operation answers `absent` rather than waiting for its node.\n */\n read(\n op: PageOp,\n scope: WireSelector[],\n selector: WireSelector,\n options: PageApiOptions,\n arg: unknown,\n lookup: Lookup,\n ): Promise<PageResult>\n /** Re-read the top-level URL; needs no resolver, so it is safe after a navigation. */\n locate(): Promise<string>\n /** The browser's `navigator.platform`, read once: it does not change mid-test. */\n platform(): Promise<string>\n /**\n * Runs an operation that may switch TestCafe into an iframe. Switching is\n * state on the controller, so two such operations must never interleave —\n * and nor may a plain action, whose selector would run in the wrong window.\n */\n exclusive<T>(run: () => Promise<T>): Promise<T>\n /** The page was replaced: the next call carries the resolver with it. */\n navigated(): void\n}\n\nconst sessions = new WeakMap<TestController, Session>()\n\n/**\n * The `t` exported by 'testcafe' is one shared proxy that looks up whichever\n * test is running when it is used. A client function bound to it does not\n * bind, and a session keyed by it would be shared by every test — so only the\n * controller a test function is handed, which carries its own test run, will do.\n */\nexport function assertOwnController(t: TestController): void {\n if (typeof (t as { testRun?: unknown }).testRun !== 'object') {\n throw new Error(\n \"harnessed: pass the test function's own t, not the one imported from 'testcafe': \" +\n \"test('…', async t => { … testcafe(t) … }).\",\n )\n }\n}\n\n/**\n * The resolver, as TestCafe sees it. Client functions are compiled when they are\n * created, so they are built once per test and take the per-call values as\n * arguments. `boundTestRun` ties them to the test explicitly: TestCafe's own\n * test-run tracking follows its promise patches, which native `await` in a\n * compiled library does not go through.\n */\nexport function sessionFor(t: TestController): Session {\n const existing = sessions.get(t)\n if (existing !== undefined) return existing\n assertOwnController(t)\n\n const call = ClientFunction(pageCall, { boundTestRun: t })\n const href = ClientFunction(currentHref, { boundTestRun: t })\n const readPlatform = ClientFunction(browserPlatform, { boundTestRun: t })\n let platform: string | undefined\n let queue: Promise<unknown> = Promise.resolve()\n // A session starts on a page the driver has not seen, so its first call\n // carries the resolver. After that the source is sent only when the page may\n // be a fresh document — after a navigation, or once the URL has changed — and\n // when a call finds the resolver missing anyway.\n let carrySource = true\n const seen = (url: string): void => {\n if (session.href !== undefined && url !== session.href) carrySource = true\n session.href = url\n }\n\n const session: Session = {\n href: undefined,\n async read(op, scope, selector, options, arg, lookup) {\n // The page answers with a value or a promise of one; awaiting flattens both.\n const run = async (source: string | null): Promise<PageResult> =>\n await call(PAGE_API_GLOBAL, source, op, scope, selector, options, arg, lookup)\n let result: PageResult\n try {\n result = await run(carrySource ? injectSource() : null)\n } catch (error) {\n if (!messageOf(error).includes(NOT_INJECTED)) throw toError(error)\n try {\n result = await run(injectSource())\n } catch (retried) {\n throw toError(retried)\n }\n }\n carrySource = false\n session.href = result.href\n return result\n },\n async locate() {\n let current: string\n try {\n current = await href()\n } catch (error) {\n throw toError(error)\n }\n seen(current)\n return current\n },\n async platform() {\n if (platform === undefined) {\n try {\n platform = await readPlatform()\n } catch (error) {\n throw toError(error)\n }\n }\n return platform\n },\n navigated() {\n carrySource = true\n },\n exclusive(run) {\n const next = queue.then(run, run)\n queue = next.catch(() => undefined)\n return next\n },\n }\n sessions.set(t, session)\n return session\n}\n","/**\n * Playwright key names, which the shared `press()` takes, onto TestCafe's\n * `pressKey` names. TestCafe lowercases its own and shortens a few; a printable\n * character passes through, except a space, which `pressKey` would read as a\n * separator between two keys.\n */\nconst NAMES: Record<string, string> = {\n ' ': 'space',\n Space: 'space',\n Enter: 'enter',\n Tab: 'tab',\n Backspace: 'backspace',\n Delete: 'delete',\n Escape: 'esc',\n Insert: 'ins',\n Home: 'home',\n End: 'end',\n PageUp: 'pageup',\n PageDown: 'pagedown',\n ArrowUp: 'up',\n ArrowDown: 'down',\n ArrowLeft: 'left',\n ArrowRight: 'right',\n Control: 'ctrl',\n Shift: 'shift',\n Alt: 'alt',\n Meta: 'meta',\n CapsLock: 'capslock',\n}\n\n/**\n * Every multi-character name TestCafe's `pressKey` accepts: its modifiers and\n * its special keys. Anything else it rejects with an opaque \"incorrect key\"\n * error, so a name outside this set is refused here first, with the key named.\n */\nconst SUPPORTED = new Set([\n 'alt',\n 'ctrl',\n 'meta',\n 'shift',\n 'backspace',\n 'capslock',\n 'delete',\n 'down',\n 'end',\n 'enter',\n 'esc',\n 'home',\n 'ins',\n 'left',\n 'pagedown',\n 'pageup',\n 'right',\n 'space',\n 'tab',\n 'up',\n])\n\n/** A chord's parts. A lone `+` is the plus key, and `Control++` holds Control over it. */\nfunction parts(key: string): string[] {\n if (key.length <= 1) return [key]\n const plus = key.endsWith('++')\n const split = (plus ? key.slice(0, -2) : key).split('+')\n return plus ? [...split, '+'] : split\n}\n\nfunction toPart(part: string, platform: string | undefined): string | undefined {\n if (part === 'ControlOrMeta') {\n return platform !== undefined && /^(?:Mac|iP)/.test(platform) ? 'meta' : 'ctrl'\n }\n const code = /^(?:Key([A-Z])|Digit(\\d))$/.exec(part)\n if (code !== null) return (code[1] ?? code[2]!).toLowerCase()\n const named = NAMES[part]\n if (named !== undefined) return named\n if (part.length === 1) return part\n return SUPPORTED.has(part) ? part : undefined\n}\n\n/**\n * `Control+Shift+ArrowLeft` → `ctrl+shift+left`, `ControlOrMeta+KeyA` →\n * `meta+a` in a browser on macOS. Throws before anything is pressed for a key\n * TestCafe has no way to send, such as a function key.\n *\n * `platform` is the browser's `navigator.platform`, which only `ControlOrMeta`\n * reads: the browser may run on another machine than the test runner.\n */\nexport function toTestCafeKey(key: string, platform?: string): string {\n return parts(key)\n .map(part => {\n const mapped = toPart(part, platform)\n if (mapped === undefined) {\n throw new Error(\n `harnessed: press() cannot send \"${key}\" under TestCafe, which has no \"${part}\" key.`,\n )\n }\n return mapped\n })\n .join('+')\n}\n","import { Selector as TestCafeSelector } from 'testcafe'\nimport { Query, registerDriver, registerNavigation } from '@harnessed-ts/core'\nimport type { BoundingBox, EnvConfig, FileTarget, Selector } from '@harnessed-ts/core'\nimport type { WaitOptions, WaitState } from '@harnessed-ts/core'\nimport {\n checkedFrom,\n checkFileTarget,\n checkTestIds,\n describeScope,\n enabledFrom,\n getConfig,\n timeoutFor,\n} from '@harnessed-ts/core'\nimport { encodeSelector, filesOnDisk, PAGE_API_GLOBAL } from '@harnessed-ts/resolve/inject'\nimport type { PageApiOptions } from '@harnessed-ts/resolve/inject'\nimport { TESTCAFE_DRIVER } from './driver-id'\nimport type { TestCafeEnv } from './env'\nimport { toError } from './errors'\nimport { toTestCafeKey } from './keys'\nimport { pickTarget } from './page-functions'\nimport type { Editable, PageOp, SelectArg, TargetDependency } from './page-functions'\nimport { sessionFor } from './session'\nimport type { Session } from './session'\n\n/** How often a wait re-asks the page. Each ask is one short round trip. */\nconst POLL_MS = 50\n\n/**\n * The last poll of a single-target read waits in the page this long, so that a\n * target never found fails in the resolver's own words.\n */\nconst LAST_WAIT_MS = POLL_MS\n\n/** Why a text control cannot be typed into yet. */\nconst NOT_EDITABLE: Record<'disabled' | 'readonly', string> = {\n disabled: 'it is disabled',\n readonly: 'it is readonly',\n}\n\n/** A frame link's own element: the iframe itself, not the document inside it. */\nfunction unframed(link: Selector): Selector {\n return { ...link, frame: undefined }\n}\n\nfunction delay(ms: number): Promise<void> {\n return new Promise(resolve => setTimeout(resolve, ms))\n}\n\n/**\n * TestCafe driver. Every lookup runs the shared resolver inside the page, so\n * role, label, strictness, absence and frame semantics are the dom driver's by\n * construction; TestCafe performs the actions.\n *\n * Reads are client functions that return values, which can cross into a\n * same-origin frame from the top-level window. Actions need a TestCafe\n * `Selector`, whose node must belong to the window TestCafe is switched into —\n * so an action under a frame switches into each iframe in turn, acts, and\n * always switches back.\n *\n * TestCafe runs one command at a time, so nothing here waits inside the page\n * for long: a wait held open there would block every other call until it\n * settled — including after a caller such as `isReady()` has stopped\n * listening. Single-target and list reads poll from Node instead.\n */\nexport class TestCafeQuery extends Query {\n constructor(\n private readonly t: TestController,\n scope: readonly Selector[],\n selector: Selector,\n ) {\n super(scope, selector)\n }\n\n protected override clone(selector: Selector): Query {\n return new TestCafeQuery(this.t, this.scope, selector)\n }\n\n private get session(): Session {\n return sessionFor(this.t)\n }\n\n private get described(): string {\n return describeScope(this.scope, this.selector)\n }\n\n /** Runtime config travels with every call: the page cannot see `configure()`. */\n private pageOptions(timeout?: number): PageApiOptions {\n // Refused here, so the page never folds a refusal into \"nothing there\".\n checkTestIds(this.scope, this.selector)\n return { testIdAttribute: getConfig().testIdAttribute, timeout: timeoutFor(timeout) }\n }\n\n /** One round trip, answered at once. */\n private async read<T>(op: PageOp, options?: WaitOptions, arg?: unknown): Promise<T> {\n const result = await this.session.read(\n op,\n this.scope.map(encodeSelector),\n encodeSelector(this.selector),\n this.pageOptions(options?.timeout),\n arg,\n 'now',\n )\n return result.value as T\n }\n\n /**\n * A list operation, polled from Node until its scope is there, as every\n * driver waits for the scope; the list itself answers at once. A scope that\n * never appears holds nothing, so the deadline answers `empty` rather than\n * failing.\n */\n private async readList<T>(op: 'count' | 'texts', empty: T): Promise<T> {\n const timeout = timeoutFor()\n const deadline = Date.now() + timeout\n const scope = this.scope.map(encodeSelector)\n const selector = encodeSelector(this.selector)\n for (;;) {\n const result = await this.session.read(\n op,\n scope,\n selector,\n this.pageOptions(timeout),\n undefined,\n 'now',\n )\n if (result.absent !== true) return result.value as T\n if (Date.now() >= deadline) return empty\n await delay(POLL_MS)\n }\n }\n\n /**\n * A single-target operation, polled from Node until its node is there. The\n * last poll waits briefly in the page, so a target that never appears fails\n * with the resolver's own message; a strict violation fails on the first.\n */\n private async readOne<T>(op: PageOp, options?: WaitOptions, arg?: unknown): Promise<T> {\n const timeout = timeoutFor(options?.timeout)\n const deadline = Date.now() + timeout\n const scope = this.scope.map(encodeSelector)\n const selector = encodeSelector(this.selector)\n for (;;) {\n const last = Date.now() >= deadline\n const result = await this.session.read(\n op,\n scope,\n selector,\n this.pageOptions(last ? LAST_WAIT_MS : timeout),\n arg,\n last ? 'wait' : 'now',\n )\n if (result.absent !== true) return result.value as T\n await delay(POLL_MS)\n }\n }\n\n /** A TestCafe selector for one link of the chain, resolved by the same resolver. */\n private selectorFor(\n scope: readonly Selector[],\n selector: Selector,\n timeout: number,\n control = false,\n ): ReturnType<typeof TestCafeSelector> {\n const harnessedTarget: TargetDependency = {\n name: PAGE_API_GLOBAL,\n scope: scope.map(encodeSelector),\n selector: encodeSelector(selector),\n options: this.pageOptions(timeout),\n control,\n }\n return TestCafeSelector(pickTarget, {\n dependencies: { harnessedTarget },\n boundTestRun: this.t,\n timeout,\n })\n }\n\n /**\n * Runs a TestCafe action against this query's node.\n *\n * The resolver answers first, from the page: that is what makes a strict\n * violation, a missing target or a frame marker on a non-iframe fail at once\n * with the shared wording. An error thrown inside a TestCafe selector is\n * instead retried until the selector times out, and a strict violation never\n * becomes a single match by waiting. `prepare` then refuses what TestCafe\n * would get silently wrong, within the same deadline. After that, TestCafe's\n * own selectors only have to wait for the node to be actionable — each frame\n * switch and the action given what is left of that one deadline, so the\n * whole operation fails within the caller's timeout.\n */\n private act(\n run: (target: ReturnType<typeof TestCafeSelector>, deadline: number) => Promise<unknown>,\n options?: WaitOptions,\n prepare?: (deadline: number, timeout: number) => Promise<void>,\n control = false,\n ): Promise<void> {\n return this.session.exclusive(async () => {\n const timeout = timeoutFor(options?.timeout)\n const deadline = Date.now() + timeout\n await this.readOne('resolve', { timeout })\n if (prepare !== undefined) await prepare(deadline, timeout)\n const remaining = (): number => Math.max(deadline - Date.now(), 0)\n const frames = this.scope.flatMap((link, index) => (link.frame === true ? [index] : []))\n try {\n for (const index of frames) {\n await this.t.switchToIframe(\n this.selectorFor(this.scope.slice(0, index), unframed(this.scope[index]!), remaining()),\n )\n }\n await run(this.selectorFor(this.scope, this.selector, remaining(), control), deadline)\n } catch (error) {\n throw toError(error, `act on ${this.described}`)\n } finally {\n if (frames.length > 0) await this.t.switchToMainWindow()\n }\n // An action can navigate; `currentUrl` must not report the page it left.\n await this.session.locate()\n })\n }\n\n /**\n * Waits until the target can be typed into, and refuses one that never can.\n * TestCafe's typeText would otherwise do nothing to a disabled or readonly\n * control, and type into the first editable descendant of a wrapper.\n */\n private async editable(action: 'fill' | 'clear', deadline: number, timeout: number) {\n for (;;) {\n const state = await this.readOne<Editable>('editable', {\n timeout: Math.max(deadline - Date.now(), 0),\n })\n if (state === 'ok') return\n if (state !== 'disabled' && state !== 'readonly') {\n throw new Error(\n `harnessed: ${action}() needs an <input>, <textarea> or [contenteditable] element, but ${this.described} is a ${state}.`,\n )\n }\n if (Date.now() >= deadline) {\n throw new Error(\n `harnessed: ${action}() could not edit ${this.described} within ${timeout}ms: ${NOT_EDITABLE[state]}.`,\n )\n }\n await delay(POLL_MS)\n }\n }\n\n // --- interactions -------------------------------------------------------\n\n override async click(options?: WaitOptions): Promise<void> {\n await this.act(target => this.t.click(target), options)\n }\n\n override async fill(value: string, options?: WaitOptions): Promise<void> {\n await this.replaceValue('fill', value, options)\n }\n\n override async clear(options?: WaitOptions): Promise<void> {\n await this.replaceValue('clear', '', options)\n }\n\n /**\n * Replaces the value, as Playwright's `fill()` does. `paste` sets the whole\n * value in one input event rather than typing character by character; an\n * empty value — which typeText refuses — selects what is there and deletes\n * it, so `fill('')` and `clear()` are one operation with one set of checks.\n */\n private async replaceValue(\n action: 'fill' | 'clear',\n value: string,\n options?: WaitOptions,\n ): Promise<void> {\n await this.act(\n target =>\n value === ''\n ? this.t.selectText(target).pressKey('delete')\n : this.t.typeText(target, value, { replace: true, paste: true }),\n options,\n (deadline, timeout) => this.editable(action, deadline, timeout),\n )\n }\n\n override async check(options?: WaitOptions): Promise<void> {\n if (!(await this.isChecked(options))) await this.click(options)\n }\n\n override async uncheck(options?: WaitOptions): Promise<void> {\n if (await this.isChecked(options)) await this.click(options)\n }\n\n /**\n * TestCafe has no select API, and driving a native dropdown by clicking is\n * platform-dependent. The selection is set in the page and `input` and\n * `change` dispatched — what Playwright's selectOption does — replacing any\n * existing selection of a multi-select. A change handler can navigate, so\n * this is an action like any other: it takes its turn, and re-reads the URL.\n */\n override async selectOption(value: string | string[], options?: WaitOptions): Promise<void> {\n const arg: SelectArg = {\n values: Array.isArray(value) ? value : [value],\n target: this.described,\n }\n await this.session.exclusive(async () => {\n await this.readOne('select', options, arg)\n await this.session.locate()\n })\n }\n\n /**\n * TestCafe sets files only from paths, so each File is written to disk first\n * (see `filesOnDisk`): the name and bytes arrive, and the type is inferred\n * from the extension.\n */\n override async upload(files: File | File[], options?: WaitOptions): Promise<void> {\n const list = Array.isArray(files) ? files : [files]\n let paths: string[] = []\n await this.act(\n target => this.t.setFilesToUpload(target, paths),\n options,\n async (deadline: number) => {\n const target = await this.readOne<FileTarget>('fileTarget', {\n timeout: Math.max(deadline - Date.now(), 0),\n })\n checkFileTarget(target, list.length, this.scope, this.selector)\n paths = await filesOnDisk(list)\n },\n true,\n )\n }\n\n override async hover(options?: WaitOptions): Promise<void> {\n await this.act(target => this.t.hover(target), options)\n }\n\n override async focus(options?: WaitOptions): Promise<void> {\n await this.readOne('focus', options)\n }\n\n override async blur(options?: WaitOptions): Promise<void> {\n await this.readOne('blur', options)\n }\n\n /**\n * Focuses the target first, as Playwright's press does; keys go to the\n * focused node. The key is checked before anything happens, and the focus\n * spends only what is left of the one timeout. `ControlOrMeta` follows the\n * browser's platform, which may not be the test runner's.\n */\n override async press(key: string, options?: WaitOptions): Promise<void> {\n const platform = key.includes('ControlOrMeta') ? await this.session.platform() : undefined\n const keys = toTestCafeKey(key, platform)\n await this.act(async (_target, deadline) => {\n await this.readOne('focus', { timeout: Math.max(deadline - Date.now(), 0) })\n await this.t.pressKey(keys)\n }, options)\n }\n\n // --- observations -------------------------------------------------------\n\n override async text(options?: WaitOptions): Promise<string> {\n return this.readOne<string>('text', options)\n }\n\n override async inputValue(options?: WaitOptions): Promise<string> {\n return this.readOne<string>('value', options)\n }\n\n override async attribute(name: string, options?: WaitOptions): Promise<string | null> {\n return this.readOne<string | null>('attribute', options, name)\n }\n\n override async boundingBox(options?: WaitOptions): Promise<BoundingBox> {\n return this.readOne<BoundingBox>('box', options)\n }\n\n /** Answers at once, as Playwright's does: an absent target is not visible. */\n override async isVisible(options?: WaitOptions): Promise<boolean> {\n return this.read<boolean>('visible', options)\n }\n\n override async isEnabled(options?: WaitOptions): Promise<boolean> {\n const [disabled, ariaDisabled] = await this.readOne<[boolean, string | null]>(\n 'enabled',\n options,\n )\n return enabledFrom(disabled, ariaDisabled)\n }\n\n override async isChecked(options?: WaitOptions): Promise<boolean> {\n const [aria, native] = await this.readOne<[string | null, boolean]>('checked', options)\n return checkedFrom(aria, native)\n }\n\n override async selectedOptions(options?: WaitOptions): Promise<string[]> {\n return this.readOne<string[]>('selected', options)\n }\n\n // --- waiting ------------------------------------------------------------\n\n /** Polls from Node rather than waiting inside the page, as every read here does. */\n override async waitFor(state: WaitState, options?: WaitOptions): Promise<void> {\n const timeout = timeoutFor(options?.timeout)\n const deadline = Date.now() + timeout\n for (;;) {\n if (await this.read<boolean>(state, { timeout })) return\n if (Date.now() >= deadline) {\n throw new Error(`harnessed: ${this.described} did not become ${state} within ${timeout}ms.`)\n }\n await delay(POLL_MS)\n }\n }\n\n /** Waits for the scope chain, as every driver does; the count itself answers at once. */\n override async count(): Promise<number> {\n return this.readList<number>('count', 0)\n }\n\n /** Every match read in one round trip, once the scope is there; trimmed to match `text()`. */\n override async texts(): Promise<string[]> {\n return this.readList<string[]>('texts', [])\n }\n}\n\nregisterDriver(TESTCAFE_DRIVER, (env: EnvConfig, scope, selector) => {\n return new TestCafeQuery((env as TestCafeEnv).t, scope, selector)\n})\n\n/**\n * This driver can navigate. A relative path resolves against the env's\n * `baseUrl` when it has one, and otherwise against the page the test is on.\n */\nregisterNavigation(TESTCAFE_DRIVER, {\n async goto(env, url) {\n const { t, baseUrl } = env as TestCafeEnv\n const session = sessionFor(t)\n const base = baseUrl ?? (await session.locate())\n let target: string\n try {\n target = new URL(url, base).href\n } catch {\n throw new Error(\n `harnessed: cannot resolve \"${url}\" against ${base}. Navigate to the app first, or pass ` +\n '`baseUrl` to testcafe(t, { baseUrl }).',\n )\n }\n try {\n await t.navigateTo(target)\n } catch (error) {\n throw toError(error, `navigate to ${target}`)\n } finally {\n // A new document, which has no resolver until one is sent.\n session.navigated()\n }\n await session.locate()\n },\n currentUrl(env) {\n const { href } = sessionFor((env as TestCafeEnv).t)\n if (href === undefined) {\n throw new Error(\n 'harnessed: the testcafe driver has not read the URL yet. TestCafe reads the page ' +\n 'asynchronously, so the URL is learned from goto() and from every harness call — ' +\n 'make one of those first.',\n )\n }\n return href\n },\n async waitForUrl(env, matches, timeout) {\n const session = sessionFor((env as TestCafeEnv).t)\n const deadline = Date.now() + timeout\n for (;;) {\n const href = await session.locate()\n if (matches(new URL(href))) return\n if (Date.now() >= deadline) {\n throw new Error(`harnessed: the URL did not match within ${timeout}ms; it is ${href}.`)\n }\n await delay(POLL_MS)\n }\n },\n})\n","/// <reference types=\"testcafe\" />\nimport type { EnvConfig } from '@harnessed-ts/core'\nimport { TESTCAFE_DRIVER } from './driver-id'\nimport { assertOwnController } from './session'\n// Side effect: constructing an env is the moment the driver has to be registered.\nimport './testcafe-query'\n// And its mock transport, so `mock(testcafe(t))` works without a second import.\nimport './mock-transport'\n\nexport { TESTCAFE_DRIVER }\n\nexport interface TestCafeEnv extends EnvConfig {\n readonly driver: typeof TESTCAFE_DRIVER\n /** The test's controller. Every action goes through it, so an env is per test. */\n readonly t: TestController\n /**\n * What a page's relative path resolves against in `goto()`. Without it, the\n * page the test is on — which is the fixture's page when a test starts.\n */\n readonly baseUrl?: string\n}\n\nexport interface TestCafeEnvOptions {\n baseUrl?: string\n}\n\n/**\n * Builds the env a harness is constructed with under TestCafe. `t` is the one\n * the test function is handed — not the shared `t` exported by 'testcafe',\n * which belongs to no one test.\n */\nexport function testcafe(t: TestController, options: TestCafeEnvOptions = {}): TestCafeEnv {\n assertOwnController(t)\n return options.baseUrl === undefined\n ? { driver: TESTCAFE_DRIVER, t }\n : { driver: TESTCAFE_DRIVER, t, baseUrl: options.baseUrl }\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mock-transport.d.ts","sourceRoot":"","sources":["../src/mock-transport.ts"],"names":[],"mappings":""}
|
package/dist/mock.cjs
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var mock = require('@harnessed-ts/mock');
|
|
4
|
+
var testcafe = require('testcafe');
|
|
5
|
+
|
|
6
|
+
// src/mock-transport.ts
|
|
7
|
+
|
|
8
|
+
// src/driver-id.ts
|
|
9
|
+
var TESTCAFE_DRIVER = "testcafe";
|
|
10
|
+
|
|
11
|
+
// src/mock-transport.ts
|
|
12
|
+
function responseMockClass() {
|
|
13
|
+
const probe = testcafe.RequestMock().onRequestTo(() => false).respond("");
|
|
14
|
+
return probe.mocks.values().next().value.constructor;
|
|
15
|
+
}
|
|
16
|
+
var UNREACHABLE = { hostname: "127.0.0.1", port: 9 };
|
|
17
|
+
var MockHook = class extends testcafe.RequestHook {
|
|
18
|
+
#dispatcher;
|
|
19
|
+
#ResponseMock = responseMockClass();
|
|
20
|
+
disposed = false;
|
|
21
|
+
constructor(dispatcher) {
|
|
22
|
+
super(void 0, {});
|
|
23
|
+
this.#dispatcher = dispatcher;
|
|
24
|
+
}
|
|
25
|
+
async onRequest(event) {
|
|
26
|
+
if (this.disposed) return;
|
|
27
|
+
const request = event._requestInfo;
|
|
28
|
+
const raw = {
|
|
29
|
+
method: request.method.toUpperCase(),
|
|
30
|
+
url: request.url,
|
|
31
|
+
headers: request.headers,
|
|
32
|
+
body: request.body !== void 0 && request.body.length > 0 ? new Uint8Array(request.body) : null,
|
|
33
|
+
kind: request.isAjax ? "fetch" : "other"
|
|
34
|
+
};
|
|
35
|
+
const result = await this.#dispatcher.dispatch(raw);
|
|
36
|
+
if (result.kind === "passthrough") return;
|
|
37
|
+
if (result.kind === "error") {
|
|
38
|
+
const options = event.requestOptions;
|
|
39
|
+
options.hostname = UNREACHABLE.hostname;
|
|
40
|
+
options.host = `${UNREACHABLE.hostname}:${UNREACHABLE.port}`;
|
|
41
|
+
options.port = UNREACHABLE.port;
|
|
42
|
+
options.protocol = "http:";
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
const { reply } = result;
|
|
46
|
+
await event.setMock(
|
|
47
|
+
this.#ResponseMock.from({
|
|
48
|
+
body: reply.body === null ? "" : Buffer.from(reply.body),
|
|
49
|
+
statusCode: reply.status,
|
|
50
|
+
headers: reply.headers
|
|
51
|
+
})
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
async onResponse() {
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
async function install(t, dispatcher) {
|
|
58
|
+
const hook = new MockHook(dispatcher);
|
|
59
|
+
await t.addRequestHooks(hook);
|
|
60
|
+
return {
|
|
61
|
+
async dispose() {
|
|
62
|
+
hook.disposed = true;
|
|
63
|
+
await t.removeRequestHooks(hook).catch(() => {
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
mock.registerMockTransport(TESTCAFE_DRIVER, {
|
|
69
|
+
// Buffered, and no sockets: TestCafe's proxy offers neither a streamed
|
|
70
|
+
// response nor a hook on WebSockets.
|
|
71
|
+
capabilities: { streaming: false, websockets: false, harRecord: false },
|
|
72
|
+
// Hooks are attached per test, through the test's own controller.
|
|
73
|
+
key: (env) => env.t,
|
|
74
|
+
install: (env, dispatcher) => install(env.t, dispatcher)
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
Object.keys(mock).forEach(function (k) {
|
|
78
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
79
|
+
enumerable: true,
|
|
80
|
+
get: function () { return mock[k]; }
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
//# sourceMappingURL=mock.cjs.map
|
|
84
|
+
//# sourceMappingURL=mock.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/driver-id.ts","../src/mock-transport.ts"],"names":["RequestMock","RequestHook","registerMockTransport"],"mappings":";;;;;;;;AACO,IAAM,eAAA,GAAkB,UAAA;;;ACyC/B,SAAS,iBAAA,GAAuC;AAC9C,EAAA,MAAM,KAAA,GAAQA,sBAAY,CACvB,WAAA,CAAY,MAAM,KAAK,CAAA,CACvB,QAAQ,EAAE,CAAA;AACb,EAAA,OAAO,MAAM,KAAA,CAAM,MAAA,EAAO,CAAE,IAAA,GAAO,KAAA,CAAO,WAAA;AAC5C;AAGA,IAAM,WAAA,GAAc,EAAE,QAAA,EAAU,WAAA,EAAa,MAAM,CAAA,EAAE;AAErD,IAAM,QAAA,GAAN,cAAuBC,oBAAA,CAAY;AAAA,EACxB,WAAA;AAAA,EACA,gBAAgB,iBAAA,EAAkB;AAAA,EAC3C,QAAA,GAAW,KAAA;AAAA,EAEX,YAAY,UAAA,EAAwB;AAClC,IAAA,KAAA,CAAM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EAAM,MAAM,IAAA,KAAS,IAAA,GAAO,KAAK,MAAA,CAAO,IAAA,CAAK,MAAM,IAAI,CAAA;AAAA,QACvD,YAAY,KAAA,CAAM,MAAA;AAAA,QAClB,SAAS,KAAA,CAAM;AAAA,OAChB;AAAA,KACH;AAAA,EACF;AAAA,EAEA,MAAe,UAAA,GAA4B;AAAA,EAAC;AAC9C,CAAA;AAEA,eAAe,OAAA,CAAQ,GAAmB,UAAA,EAAqD;AAC7F,EAAA,MAAM,IAAA,GAAO,IAAI,QAAA,CAAS,UAAU,CAAA;AACpC,EAAA,MAAM,CAAA,CAAE,gBAAgB,IAAI,CAAA;AAC5B,EAAA,OAAO;AAAA,IACL,MAAM,OAAA,GAAU;AACd,MAAA,IAAA,CAAK,QAAA,GAAW,IAAA;AAChB,MAAA,MAAM,CAAA,CAAE,kBAAA,CAAmB,IAAI,CAAA,CAAE,MAAM,MAAM;AAAA,MAE7C,CAAC,CAAA;AAAA,IACH;AAAA,GACF;AACF;AAEAC,0BAAA,CAAsB,eAAA,EAAiB;AAAA;AAAA;AAAA,EAGrC,cAAc,EAAE,SAAA,EAAW,OAAO,UAAA,EAAY,KAAA,EAAO,WAAW,KAAA,EAAM;AAAA;AAAA,EAEtE,GAAA,EAAK,SAAQ,GAAA,CAAoB,CAAA;AAAA,EACjC,SAAS,CAAC,GAAA,EAAK,eAAe,OAAA,CAAS,GAAA,CAAoB,GAAG,UAAU;AAC1E,CAAC,CAAA","file":"mock.cjs","sourcesContent":["/** Its own module so `env.ts` and `testcafe-query.ts` can share it without a cycle. */\nexport const TESTCAFE_DRIVER = 'testcafe'\n","import { registerMockTransport } from '@harnessed-ts/mock'\nimport type { Dispatcher, InstalledTransport, RawRequest } from '@harnessed-ts/mock'\nimport { RequestHook, RequestMock } from 'testcafe'\nimport { TESTCAFE_DRIVER } from './driver-id'\nimport type { TestCafeEnv } from './env'\n\n/**\n * The parts of hammerhead's request event this transport reads and writes.\n * `_requestInfo` is what TestCafe's own RequestLogger reads; there is no\n * public equivalent.\n */\ninterface RequestEvent {\n _requestInfo: {\n url: string\n method: string\n headers: Record<string, string>\n body?: Buffer\n isAjax: boolean\n }\n requestOptions: {\n hostname: string\n host: string\n port: number | string\n protocol: string\n path: string\n }\n setMock(mock: unknown): Promise<void>\n}\n\ninterface ResponseMockClass {\n from(init: {\n body: Buffer | string\n statusCode: number\n headers: Record<string, string>\n }): unknown\n}\n\n/**\n * hammerhead's ResponseMock, which TestCafe does not export. A RequestMock\n * builds one per rule, so one built here and read back gives the class without\n * depending on hammerhead directly.\n */\nfunction responseMockClass(): ResponseMockClass {\n const probe = RequestMock()\n .onRequestTo(() => false)\n .respond('') as unknown as { mocks: Map<string, object> }\n return probe.mocks.values().next().value!.constructor as unknown as ResponseMockClass\n}\n\n/** A port nothing listens on: sending a request there is how a network failure is staged. */\nconst UNREACHABLE = { hostname: '127.0.0.1', port: 9 }\n\nclass MockHook extends RequestHook {\n readonly #dispatcher: Dispatcher\n readonly #ResponseMock = responseMockClass()\n disposed = false\n\n constructor(dispatcher: Dispatcher) {\n super(undefined, {})\n this.#dispatcher = dispatcher\n }\n\n override async onRequest(event: object): Promise<void> {\n if (this.disposed) return\n const request = (event as RequestEvent)._requestInfo\n const raw: RawRequest = {\n method: request.method.toUpperCase(),\n url: request.url,\n headers: request.headers,\n body:\n request.body !== undefined && request.body.length > 0 ? new Uint8Array(request.body) : null,\n kind: request.isAjax ? 'fetch' : 'other',\n }\n const result = await this.#dispatcher.dispatch(raw)\n if (result.kind === 'passthrough') return\n if (result.kind === 'error') {\n // TestCafe can mock a response but not fail one, so the request is sent\n // where nothing answers — the browser sees the same network error.\n const options = (event as RequestEvent).requestOptions\n options.hostname = UNREACHABLE.hostname\n options.host = `${UNREACHABLE.hostname}:${UNREACHABLE.port}`\n options.port = UNREACHABLE.port\n options.protocol = 'http:'\n return\n }\n const { reply } = result\n await (event as RequestEvent).setMock(\n this.#ResponseMock.from({\n body: reply.body === null ? '' : Buffer.from(reply.body),\n statusCode: reply.status,\n headers: reply.headers,\n }),\n )\n }\n\n override async onResponse(): Promise<void> {}\n}\n\nasync function install(t: TestController, dispatcher: Dispatcher): Promise<InstalledTransport> {\n const hook = new MockHook(dispatcher)\n await t.addRequestHooks(hook)\n return {\n async dispose() {\n hook.disposed = true\n await t.removeRequestHooks(hook).catch(() => {\n // The test is over and took its hooks with it.\n })\n },\n }\n}\n\nregisterMockTransport(TESTCAFE_DRIVER, {\n // Buffered, and no sockets: TestCafe's proxy offers neither a streamed\n // response nor a hook on WebSockets.\n capabilities: { streaming: false, websockets: false, harRecord: false },\n // Hooks are attached per test, through the test's own controller.\n key: env => (env as TestCafeEnv).t,\n install: (env, dispatcher) => install((env as TestCafeEnv).t, dispatcher),\n})\n"]}
|
package/dist/mock.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* API mocking under TestCafe, through a request hook on the test's controller.
|
|
3
|
+
* Everything from `@harnessed-ts/mock`, with this driver's transport
|
|
4
|
+
* registered. Streaming and WebSockets are not available under TestCafe.
|
|
5
|
+
*
|
|
6
|
+
* ```ts
|
|
7
|
+
* import { json, mock } from '@harnessed-ts/testcafe/mock'
|
|
8
|
+
*
|
|
9
|
+
* test('shows the user', async t => {
|
|
10
|
+
* const api = mock(testcafe(t), { scope: '/api/**' })
|
|
11
|
+
* await api.get('/api/users/:id').reply(({ params }) => json({ id: params.id }))
|
|
12
|
+
* await t.navigateTo('/users/1')
|
|
13
|
+
* })
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
import './mock-transport';
|
|
17
|
+
export * from '@harnessed-ts/mock';
|
|
18
|
+
//# sourceMappingURL=mock.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mock.d.ts","sourceRoot":"","sources":["../src/mock.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,kBAAkB,CAAA;AACzB,cAAc,oBAAoB,CAAA"}
|
package/dist/mock.js
ADDED
package/dist/mock.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"mock.js","sourcesContent":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@harnessed-ts/testcafe",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.1",
|
|
4
4
|
"description": "TestCafe driver for @harnessed-ts/core: harnesses resolve through TestCafe's client functions with the shared resolver.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"testing",
|
|
@@ -37,8 +37,20 @@
|
|
|
37
37
|
"import": "./dist/index.js",
|
|
38
38
|
"require": "./dist/index.cjs"
|
|
39
39
|
},
|
|
40
|
+
"./mock": {
|
|
41
|
+
"types": "./dist/mock.d.ts",
|
|
42
|
+
"import": "./dist/mock.js",
|
|
43
|
+
"require": "./dist/mock.cjs"
|
|
44
|
+
},
|
|
40
45
|
"./package.json": "./package.json"
|
|
41
46
|
},
|
|
47
|
+
"typesVersions": {
|
|
48
|
+
"*": {
|
|
49
|
+
"mock": [
|
|
50
|
+
"./dist/mock.d.ts"
|
|
51
|
+
]
|
|
52
|
+
}
|
|
53
|
+
},
|
|
42
54
|
"files": [
|
|
43
55
|
"dist",
|
|
44
56
|
"CHANGELOG.md",
|
|
@@ -49,8 +61,9 @@
|
|
|
49
61
|
"node": ">=22.12.0"
|
|
50
62
|
},
|
|
51
63
|
"dependencies": {
|
|
52
|
-
"@harnessed-ts/core": "^0.
|
|
53
|
-
"@harnessed-ts/
|
|
64
|
+
"@harnessed-ts/core": "^0.8.1",
|
|
65
|
+
"@harnessed-ts/mock": "^0.8.1",
|
|
66
|
+
"@harnessed-ts/resolve": "^0.8.1"
|
|
54
67
|
},
|
|
55
68
|
"peerDependencies": {
|
|
56
69
|
"testcafe": ">=3"
|