From c55c190b602c0be2899c83d606e192a77a3ca26a Mon Sep 17 00:00:00 2001 From: "Mx. Corey Frang" Date: Thu, 9 Nov 2023 15:05:47 -0500 Subject: [PATCH] Fix for the commands -> at-driver translation layer --- src/agent/at-driver.js | 4 +++ src/agent/driver-test-runner.js | 46 +++++++++++++++++---------------- 2 files changed, 28 insertions(+), 22 deletions(-) diff --git a/src/agent/at-driver.js b/src/agent/at-driver.js index 36ef53b..71b8d46 100644 --- a/src/agent/at-driver.js +++ b/src/agent/at-driver.js @@ -117,6 +117,8 @@ export const webDriverCodePoints = { SHIFT: '\ue008', CONTROL: '\ue009', ALT: '\ue00a', + OPT: '\ue00a', + OPTION: '\ue00a', PAUSE: '\ue00b', ESCAPE: '\ue00c', SPACE: '\ue00d', @@ -135,8 +137,10 @@ export const webDriverCodePoints = { ARROWRIGHT: '\ue014', DOWN: '\ue015', ARROWDOWN: '\ue015', + INS: '\ue016', INSERT: '\ue016', DELETE: '\ue017', + DEL: '\ue017', SEMICOLON: '\ue018', EQUALS: '\ue019', diff --git a/src/agent/driver-test-runner.js b/src/agent/driver-test-runner.js index 3526a7e..c4dfeae 100644 --- a/src/agent/driver-test-runner.js +++ b/src/agent/driver-test-runner.js @@ -197,28 +197,30 @@ export class DriverTestRunner { export function validateKeysFromCommand(command) { const errors = []; - for (const { keystroke } of command.keypresses) { - // Some old test plans have keys that contain indications of unspecified - // instructions ('/') or additional instructions that are not standardized - // in test plans. These keys should be updated to be separate commands or - // use a standardized approach. - if (/\//.test(keystroke)) { - errors.push(`'${keystroke}' cannot contain '/'.`); + for (const { id } of command.keypresses) { + if (/\//.test(id)) { + errors.push(`'${id}' cannot contain '/'.`); } - if (/[()]/.test(keystroke)) { - errors.push(`'${keystroke}' cannot contain '(' or ')'.`); + if (/[()]/.test(id)) { + errors.push(`'${id}' cannot contain '(' or ')'.`); } - if (/\bor\b/.test(keystroke)) { - errors.push(`'${keystroke}' cannot contain 'or'.`); + if (/\bor\b/.test(id)) { + errors.push(`'${id}' cannot contain 'or'.`); } - if (/\bfollowed\b/.test(keystroke)) { - errors.push(`'${keystroke}' cannot contain 'followed' or 'followed by'.`); + if (/\bfollowed\b/.test(id)) { + errors.push(`'${id}' cannot contain 'followed' or 'followed by'.`); } - - if (keystroke.length != 1 && !webDriverCodePoints[keystroke.toUpperCase()]) { - errors.push( - `'${keystroke}' is not a recognized key - use single characters or "Normalized" values from https://w3c.github.io/webdriver/#keyboard-actions` - ); + for (const part of id.split('_')) { + // Some old test plans have keys that contain indications of unspecified + // instructions ('/') or additional instructions that are not standardized + // in test plans. These keys should be updated to be separate commands or + // use a standardized approach. + + if (part.length != 1 && !webDriverCodePoints[part.toUpperCase()]) { + errors.push( + `'${part}' of '${id}' is not a recognized key - use single characters or "Normalized" values from https://w3c.github.io/webdriver/#keyboard-actions` + ); + } } } @@ -233,16 +235,16 @@ export function validateKeysFromCommand(command) { */ export function atKeysFromCommand(command) { return ATKey.sequence( - ...command.keypresses.map(({ keystroke }) => + ...command.keypresses.map(({ id }) => ATKey.chord( - ...keystroke - .split('+') + ...id + .split('_') .map(key => key.trim().toLowerCase()) // `up arrow`, `down arrow`, etc are sent as `up`, `down`, etc .map(key => key.replace(/\s?arrow\s?/g, '')) // remove whitespace for keys like 'page up' .map(key => key.replace(/\s/g, '')) - .map(key => ATKey.key(key)) + .map(key => ATKey.key(key.toLowerCase())) ) ) );