From 674d9a2093a12a8cda7803c2fdcac43572556f81 Mon Sep 17 00:00:00 2001 From: Mike Pennisi Date: Tue, 5 Mar 2024 22:28:40 -0500 Subject: [PATCH] Correct types: src/agent/driver-test-runner.js The modifications to the ARIA-AT type definitions were approved via https://github.com/w3c/aria-at/pull/1044 --- src/agent/driver-test-runner.js | 23 ++++++++++++++--------- src/data/types.js | 4 +++- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/src/agent/driver-test-runner.js b/src/agent/driver-test-runner.js index c1ace1b..8b815cc 100644 --- a/src/agent/driver-test-runner.js +++ b/src/agent/driver-test-runner.js @@ -1,4 +1,3 @@ -// @ts-nocheck /// /// /// @@ -43,7 +42,9 @@ export class DriverTestRunner { } /** - * @param {URL} url + * @param {object} options + * @param {URL} options.url + * @param {string} options.referencePage */ async openPage({ url, referencePage }) { await this.log(AgentMessage.OPEN_PAGE, { url }); @@ -59,10 +60,16 @@ export class DriverTestRunner { try { await this.webDriver.executeAsyncScript(function (callback) { + // @ts-expect-error (The TypeScript compiler cannot be configured to + // recognize that this function executes in another environment--one + // where `document` is defined globally.) if (document.readyState === 'complete') { callback(); } else { new Promise(resolve => { + // @ts-expect-error (The TypeScript compiler cannot be configured + // to recognize that this function executes in another + // environment--one where `window` is defined globally.) window.addEventListener('load', () => resolve()); }) // Wait until after any microtasks registered by other 'load' event @@ -84,7 +91,7 @@ export class DriverTestRunner { } /** - * @param {ATKeySequence} sequence + * @param {import('./at-driver').ATKeySequence} sequence */ async sendKeys(sequence) { await this.log(AgentMessage.PRESS_KEYS, { keys: sequence }); @@ -155,11 +162,11 @@ export class DriverTestRunner { } else if (!atName) { return; } - throw new Error(`Unable to ensure proper mode. Unknown atName ${capabilities.atName}`); + throw new Error(`Unable to ensure proper mode. Unknown atName ${atName}`); } /** - * @param {AriaATFile.CollectedTest} test + * @param {AriaATCIData.CollectedTest} test */ async run(test) { const capabilities = await this.collectedCapabilities; @@ -270,10 +277,8 @@ export class DriverTestRunner { } _appendBaseUrl(pathname) { - return new URL( - `${this.baseUrl.pathname ? `${this.baseUrl.pathname}/` : ''}${pathname}`, - this.baseUrl - ); + const base = `${this.baseUrl.protocol}://${this.baseUrl.hostname}:${this.baseUrl.port}/${this.baseUrl.pathname}`; + return new URL(`${this.baseUrl.pathname ? `${this.baseUrl.pathname}/` : ''}${pathname}`, base); } } diff --git a/src/data/types.js b/src/data/types.js index e80a7ff..0e1c324 100644 --- a/src/data/types.js +++ b/src/data/types.js @@ -12,6 +12,7 @@ * @property {number} info.testId * @property {string} info.title * @property {string} info.task + * @property {string} [info.presentationNumber] * @property {object[]} info.references * @property {string} info.references[].refId * @property {string} info.references[].value @@ -24,7 +25,7 @@ * @property {string} target.at.key * @property {string} target.at.raw original test plan file assistive tech id * @property {string} target.at.name - * @property {string} target.mode + * @property {"interaction" | "reading"} target.mode * @property {string} target.referencePage * @property {object} [target.setupScript] * @property {string} target.setupScript.name @@ -39,6 +40,7 @@ * @property {string} commands[].keypresses[].id * @property {string} commands[].keypresses[].keystroke single human-readable key or key chord press * @property {string} [commands[].extraInstruction] human-readable additional instruction to follow + * @property {string} [commands[].settings] this property only exists on v2 tests * @property {object[]} assertions[] * @property {1 | 2} assertions[].priority * @property {string} [assertions[].expectation] assertion statement string, this property only exists on v1 tests