Skip to content

Commit

Permalink
Assertion verdict radio buttons (#1093)
Browse files Browse the repository at this point in the history
* Update assertion verdicts to radio buttons

* Remove unneeded function, update commands assertion behavior

* Use boolean or null in passed and in result for assertions

* Default to null for assertion verdicts

* JSDoc update

* Lint
  • Loading branch information
stalgiag authored Aug 26, 2024
1 parent a549366 commit 74306de
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 55 deletions.
43 changes: 23 additions & 20 deletions tests/resources/aria-at-harness.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {
render,
} from './vrender.mjs';
import {
AssertionResultMap,
userCloseWindow,
userOpenWindow,
WhitespaceStyleMap,
Expand Down Expand Up @@ -415,7 +414,29 @@ function renderVirtualInstructionDocument(doc) {
fieldset(
className(['assertions']),
legend(rich(command.assertionsHeader.descriptionHeader)),
...command.assertions.map(bind(commandResultAssertion, commandIndex))
...command.assertions.map((assertion, assertionIndex) =>
fieldset(
legend(rich(assertion.description)),
radioChoice(
`cmd-${commandIndex}-assertion-${assertionIndex}-yes`,
`cmd-${commandIndex}-assertion-${assertionIndex}`,
{
label: 'Yes',
checked: assertion.passed === true,
click: () => assertion.click(true),
}
),
radioChoice(
`cmd-${commandIndex}-assertion-${assertionIndex}-no`,
`cmd-${commandIndex}-assertion-${assertionIndex}`,
{
label: 'No',
checked: assertion.passed === false,
click: () => assertion.click(false),
}
)
)
)
),
...[command.unexpectedBehaviors].map(bind(commandResultUnexpectedBehavior, commandIndex))
);
Expand Down Expand Up @@ -526,24 +547,6 @@ function renderVirtualInstructionDocument(doc) {
);
}

/**
* @param {number} commandIndex
* @param {InstructionDocumentResultsCommandsAssertion} assertion
* @param {number} assertionIndex
*/
function commandResultAssertion(commandIndex, assertion, assertionIndex) {
return label(
className(['assertion']),
input(
type('checkbox'),
id(`cmd-${commandIndex}-${assertionIndex}`),
checked(assertion.passed === AssertionResultMap.PASS),
onclick(assertion.click)
),
rich(assertion.description)
);
}

/**
* @param {string} idKey
* @param {string} nameKey
Expand Down
14 changes: 4 additions & 10 deletions tests/resources/aria-at-test-io-format.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -1296,13 +1296,13 @@ export class TestRunInputOutput {
description: assertion.assertion,
highlightRequired: false,
priority: assertion.priority,
result: CommonResultMap.NOT_SET,
result: null,
})),
additionalAssertions: test.additionalAssertions.map(assertion => ({
description: assertion.assertion,
highlightRequired: false,
priority: assertion.priority,
result: CommonResultMap.NOT_SET,
result: null,
})),
unexpected: {
highlightRequired: false,
Expand Down Expand Up @@ -1517,7 +1517,7 @@ export class TestRunInputOutput {
assertion.priority === 1 ? 'MUST' : assertion.priority === 2 ? 'SHOULD' : 'MAY',
text: assertion.description,
},
passed: assertion.result === 'pass',
passed: assertion.result,
failedReason:
assertion.result === 'failIncorrect'
? 'INCORRECT_OUTPUT'
Expand Down Expand Up @@ -1576,13 +1576,7 @@ export class TestRunInputOutput {
return {
...assertion,
highlightRequired: false,
result: assertionResult.passed
? 'pass'
: assertionResult.failedReason === 'INCORRECT_OUTPUT'
? 'failIncorrect'
: assertionResult.failedReason === 'NO_OUTPUT'
? 'failMissing'
: 'fail',
result: assertionResult.passed,
};
}),
unexpected: {
Expand Down
39 changes: 15 additions & 24 deletions tests/resources/aria-at-test-run.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -389,15 +389,12 @@ export function instructionDocument(resultState, hooks) {
const resultAssertion = resultState.commands[commandIndex].assertions[assertionIndex];
return /** @type {InstructionDocumentResultsCommandsAssertion} */ ({
description: [assertion],
passed: resultAssertion.result === AssertionResultMap.PASS,
click: () =>
passed: resultAssertion.result,
click: newResult =>
hooks.setCommandAssertion({
commandIndex,
assertionIndex,
result:
resultAssertion.result === AssertionResultMap.PASS
? AssertionResultMap.FAIL
: AssertionResultMap.PASS,
result: newResult,
}),
});
}
Expand All @@ -412,15 +409,12 @@ export function instructionDocument(resultState, hooks) {
resultState.commands[commandIndex].additionalAssertions[assertionIndex];
return /** @type {InstructionDocumentResultsCommandsAssertion} */ ({
description: [assertion],
passed: resultAdditionalAssertion.result === CommonResultMap.PASS,
click: () =>
passed: resultAdditionalAssertion.result,
click: newResult =>
hooks.setCommandAssertion({
commandIndex,
assertionIndex,
result:
resultAdditionalAssertion.result === AssertionResultMap.PASS
? AssertionResultMap.FAIL
: AssertionResultMap.PASS,
result: newResult,
}),
});
}
Expand Down Expand Up @@ -477,7 +471,7 @@ export const AdditionalAssertionResultMap = createEnumMap({
});

/**
* @typedef {EnumValues<typeof AssertionResultMap>} AssertionResult
* @typedef {boolean | null} AssertionResult
*/

export const AssertionResultMap = createEnumMap({
Expand Down Expand Up @@ -854,14 +848,14 @@ function resultsTableDocument(state) {
let failingAssertions = ['No failing assertions'];
let unexpectedBehaviors = ['None'];

if (allAssertions.some(({ result }) => result === CommonResultMap.PASS)) {
if (allAssertions.some(({ result }) => result)) {
passingAssertions = allAssertions
.filter(({ result }) => result === CommonResultMap.PASS)
.filter(({ result }) => result)
.map(({ description }) => description);
}
if (allAssertions.some(({ result }) => result !== CommonResultMap.PASS)) {
if (allAssertions.some(({ result }) => !result)) {
failingAssertions = allAssertions
.filter(({ result }) => result !== CommonResultMap.PASS)
.filter(({ result }) => !result)
.map(({ description }) => description);
}
if (command.unexpected.behaviors.some(({ checked }) => checked)) {
Expand All @@ -878,13 +872,10 @@ function resultsTableDocument(state) {
return {
description: command.description,
support:
allAssertions.some(
({ priority, result }) => priority === 1 && result !== CommonResultMap.PASS
) || command.unexpected.behaviors.some(({ checked }) => checked)
allAssertions.some(({ priority, result }) => priority === 1 && !result) ||
command.unexpected.behaviors.some(({ checked }) => checked)
? 'FAILING'
: allAssertions.some(
({ priority, result }) => priority === 2 && result !== CommonResultMap.PASS
)
: allAssertions.some(({ priority, result }) => priority === 2 && !result)
? 'ALL_REQUIRED'
: 'FULL',
details: {
Expand Down Expand Up @@ -1109,7 +1100,7 @@ export function userValidateState() {
/**
* @typedef InstructionDocumentResultsCommandsAssertion
* @property {Description} description
* @property {Boolean} passed
* @property {Boolean | null} passed
* @property {boolean} [focus]
* @property {() => void} click
*/
Expand Down
2 changes: 1 addition & 1 deletion tests/resources/types/aria-at-test-result.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
* @property {object} scenarioResults[].assertionResults[].assertion
* @property {AriaATTestResult.AssertionPriorityJSON} scenarioResults[].assertionResults[].assertion.priority
* @property {string} scenarioResults[].assertionResults[].assertion.text
* @property {boolean} scenarioResults[].assertionResults[].passed
* @property {boolean | null} scenarioResults[].assertionResults[].result
* @property {AriaATTestResult.AssertionFailedReasonJSON | null} [scenarioResults[].assertionResults[].failedReason]
* @property {object[]} scenarioResults[].unexpectedBehaviors
* @property {string} scenarioResults[].unexpectedBehaviors[].id
Expand Down

0 comments on commit 74306de

Please sign in to comment.