From 3c301d3cbf099fee11a8c22eaafc59b83dc14fbc Mon Sep 17 00:00:00 2001 From: Stalgia Grigg Date: Thu, 30 Nov 2023 16:25:44 -0800 Subject: [PATCH] Handle v2 combo key presses and v2 expectations in mocked error keys --- src/agent/driver-test-runner.js | 3 +++ src/agent/mock-test-runner.js | 12 ++++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/agent/driver-test-runner.js b/src/agent/driver-test-runner.js index c9071dd..802b0e4 100644 --- a/src/agent/driver-test-runner.js +++ b/src/agent/driver-test-runner.js @@ -208,6 +208,8 @@ export function validateKeysFromCommand(command) { for (let { id } of command.keypresses) { // PAGE_DOWN and PAGE_UP are the only commands that have the extra _ inside a key id = id.replace(/(PAGE)_(DOWN|UP)/, '$1$2'); + // + is used to connect keys that are pressed simultaneously in v2 tests + id = id.replace('+', '_'); if (/\//.test(id)) { errors.push(`'${id}' cannot contain '/'.`); } @@ -249,6 +251,7 @@ export function atKeysFromCommand(command) { ATKey.chord( ...id .replace(/(PAGE)_(DOWN|UP)/, '$1$2') + .replace('+', '_') // + is used to connect keys that are pressed simultaneously in v2 tests .split('_') .map(key => key.trim().toLowerCase()) // `up arrow`, `down arrow`, etc are sent as `up`, `down`, etc diff --git a/src/agent/mock-test-runner.js b/src/agent/mock-test-runner.js index 242f727..6466b20 100644 --- a/src/agent/mock-test-runner.js +++ b/src/agent/mock-test-runner.js @@ -97,11 +97,13 @@ export class MockTestRunner { }); for (const assertion of task.assertions) { + const expectationText = assertion.expectation || assertion.assertionStatement; + results.push({ command: validCommand.id, - expectation: assertion.expectation || assertion.assertionStatement, + expectation: expectationText, pass: await this.testAssertion(validCommand, assertion), - output: `mocked output for ${assertion.expectation}`, + output: `mocked output for ${expectationText}`, }); } } else { @@ -113,10 +115,12 @@ export class MockTestRunner { }); for (const assertion of task.assertions) { + const expectationText = assertion.expectation || assertion.assertionStatement; + results.push({ command: command.id, - expectation: assertion.expectation, - output: `mocked output for ${assertion.expectation}`, + expectation: expectationText, + output: `mocked output for ${expectationText}`, pass: false, }); }