Skip to content

Commit

Permalink
Handle v2 combo key presses and v2 expectations in mocked error keys
Browse files Browse the repository at this point in the history
  • Loading branch information
stalgiag committed Dec 1, 2023
1 parent 1cd817c commit 3c301d3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
3 changes: 3 additions & 0 deletions src/agent/driver-test-runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 '/'.`);
}
Expand Down Expand Up @@ -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
Expand Down
12 changes: 8 additions & 4 deletions src/agent/mock-test-runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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,
});
}
Expand Down

0 comments on commit 3c301d3

Please sign in to comment.