Skip to content

Commit

Permalink
Correct types: src/agent/driver-test-runner.js
Browse files Browse the repository at this point in the history
The modifications to the ARIA-AT type definitions were approved via
w3c/aria-at#1044
  • Loading branch information
jugglinmike committed Mar 13, 2024
1 parent 072cff0 commit 674d9a2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
23 changes: 14 additions & 9 deletions src/agent/driver-test-runner.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// @ts-nocheck
/// <reference path="../data/types.js" />
/// <reference path="../shared/types.js" />
/// <reference path="types.js" />
Expand Down Expand Up @@ -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 });
Expand All @@ -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
Expand All @@ -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 });
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
}

Expand Down
4 changes: 3 additions & 1 deletion src/data/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 674d9a2

Please sign in to comment.