Skip to content

Commit 74306de

Browse files
authored
Assertion verdict radio buttons (#1093)
* 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
1 parent a549366 commit 74306de

File tree

4 files changed

+43
-55
lines changed

4 files changed

+43
-55
lines changed

tests/resources/aria-at-harness.mjs

+23-20
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import {
99
render,
1010
} from './vrender.mjs';
1111
import {
12-
AssertionResultMap,
1312
userCloseWindow,
1413
userOpenWindow,
1514
WhitespaceStyleMap,
@@ -415,7 +414,29 @@ function renderVirtualInstructionDocument(doc) {
415414
fieldset(
416415
className(['assertions']),
417416
legend(rich(command.assertionsHeader.descriptionHeader)),
418-
...command.assertions.map(bind(commandResultAssertion, commandIndex))
417+
...command.assertions.map((assertion, assertionIndex) =>
418+
fieldset(
419+
legend(rich(assertion.description)),
420+
radioChoice(
421+
`cmd-${commandIndex}-assertion-${assertionIndex}-yes`,
422+
`cmd-${commandIndex}-assertion-${assertionIndex}`,
423+
{
424+
label: 'Yes',
425+
checked: assertion.passed === true,
426+
click: () => assertion.click(true),
427+
}
428+
),
429+
radioChoice(
430+
`cmd-${commandIndex}-assertion-${assertionIndex}-no`,
431+
`cmd-${commandIndex}-assertion-${assertionIndex}`,
432+
{
433+
label: 'No',
434+
checked: assertion.passed === false,
435+
click: () => assertion.click(false),
436+
}
437+
)
438+
)
439+
)
419440
),
420441
...[command.unexpectedBehaviors].map(bind(commandResultUnexpectedBehavior, commandIndex))
421442
);
@@ -526,24 +547,6 @@ function renderVirtualInstructionDocument(doc) {
526547
);
527548
}
528549

529-
/**
530-
* @param {number} commandIndex
531-
* @param {InstructionDocumentResultsCommandsAssertion} assertion
532-
* @param {number} assertionIndex
533-
*/
534-
function commandResultAssertion(commandIndex, assertion, assertionIndex) {
535-
return label(
536-
className(['assertion']),
537-
input(
538-
type('checkbox'),
539-
id(`cmd-${commandIndex}-${assertionIndex}`),
540-
checked(assertion.passed === AssertionResultMap.PASS),
541-
onclick(assertion.click)
542-
),
543-
rich(assertion.description)
544-
);
545-
}
546-
547550
/**
548551
* @param {string} idKey
549552
* @param {string} nameKey

tests/resources/aria-at-test-io-format.mjs

+4-10
Original file line numberDiff line numberDiff line change
@@ -1296,13 +1296,13 @@ export class TestRunInputOutput {
12961296
description: assertion.assertion,
12971297
highlightRequired: false,
12981298
priority: assertion.priority,
1299-
result: CommonResultMap.NOT_SET,
1299+
result: null,
13001300
})),
13011301
additionalAssertions: test.additionalAssertions.map(assertion => ({
13021302
description: assertion.assertion,
13031303
highlightRequired: false,
13041304
priority: assertion.priority,
1305-
result: CommonResultMap.NOT_SET,
1305+
result: null,
13061306
})),
13071307
unexpected: {
13081308
highlightRequired: false,
@@ -1517,7 +1517,7 @@ export class TestRunInputOutput {
15171517
assertion.priority === 1 ? 'MUST' : assertion.priority === 2 ? 'SHOULD' : 'MAY',
15181518
text: assertion.description,
15191519
},
1520-
passed: assertion.result === 'pass',
1520+
passed: assertion.result,
15211521
failedReason:
15221522
assertion.result === 'failIncorrect'
15231523
? 'INCORRECT_OUTPUT'
@@ -1576,13 +1576,7 @@ export class TestRunInputOutput {
15761576
return {
15771577
...assertion,
15781578
highlightRequired: false,
1579-
result: assertionResult.passed
1580-
? 'pass'
1581-
: assertionResult.failedReason === 'INCORRECT_OUTPUT'
1582-
? 'failIncorrect'
1583-
: assertionResult.failedReason === 'NO_OUTPUT'
1584-
? 'failMissing'
1585-
: 'fail',
1579+
result: assertionResult.passed,
15861580
};
15871581
}),
15881582
unexpected: {

tests/resources/aria-at-test-run.mjs

+15-24
Original file line numberDiff line numberDiff line change
@@ -389,15 +389,12 @@ export function instructionDocument(resultState, hooks) {
389389
const resultAssertion = resultState.commands[commandIndex].assertions[assertionIndex];
390390
return /** @type {InstructionDocumentResultsCommandsAssertion} */ ({
391391
description: [assertion],
392-
passed: resultAssertion.result === AssertionResultMap.PASS,
393-
click: () =>
392+
passed: resultAssertion.result,
393+
click: newResult =>
394394
hooks.setCommandAssertion({
395395
commandIndex,
396396
assertionIndex,
397-
result:
398-
resultAssertion.result === AssertionResultMap.PASS
399-
? AssertionResultMap.FAIL
400-
: AssertionResultMap.PASS,
397+
result: newResult,
401398
}),
402399
});
403400
}
@@ -412,15 +409,12 @@ export function instructionDocument(resultState, hooks) {
412409
resultState.commands[commandIndex].additionalAssertions[assertionIndex];
413410
return /** @type {InstructionDocumentResultsCommandsAssertion} */ ({
414411
description: [assertion],
415-
passed: resultAdditionalAssertion.result === CommonResultMap.PASS,
416-
click: () =>
412+
passed: resultAdditionalAssertion.result,
413+
click: newResult =>
417414
hooks.setCommandAssertion({
418415
commandIndex,
419416
assertionIndex,
420-
result:
421-
resultAdditionalAssertion.result === AssertionResultMap.PASS
422-
? AssertionResultMap.FAIL
423-
: AssertionResultMap.PASS,
417+
result: newResult,
424418
}),
425419
});
426420
}
@@ -477,7 +471,7 @@ export const AdditionalAssertionResultMap = createEnumMap({
477471
});
478472

479473
/**
480-
* @typedef {EnumValues<typeof AssertionResultMap>} AssertionResult
474+
* @typedef {boolean | null} AssertionResult
481475
*/
482476

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

857-
if (allAssertions.some(({ result }) => result === CommonResultMap.PASS)) {
851+
if (allAssertions.some(({ result }) => result)) {
858852
passingAssertions = allAssertions
859-
.filter(({ result }) => result === CommonResultMap.PASS)
853+
.filter(({ result }) => result)
860854
.map(({ description }) => description);
861855
}
862-
if (allAssertions.some(({ result }) => result !== CommonResultMap.PASS)) {
856+
if (allAssertions.some(({ result }) => !result)) {
863857
failingAssertions = allAssertions
864-
.filter(({ result }) => result !== CommonResultMap.PASS)
858+
.filter(({ result }) => !result)
865859
.map(({ description }) => description);
866860
}
867861
if (command.unexpected.behaviors.some(({ checked }) => checked)) {
@@ -878,13 +872,10 @@ function resultsTableDocument(state) {
878872
return {
879873
description: command.description,
880874
support:
881-
allAssertions.some(
882-
({ priority, result }) => priority === 1 && result !== CommonResultMap.PASS
883-
) || command.unexpected.behaviors.some(({ checked }) => checked)
875+
allAssertions.some(({ priority, result }) => priority === 1 && !result) ||
876+
command.unexpected.behaviors.some(({ checked }) => checked)
884877
? 'FAILING'
885-
: allAssertions.some(
886-
({ priority, result }) => priority === 2 && result !== CommonResultMap.PASS
887-
)
878+
: allAssertions.some(({ priority, result }) => priority === 2 && !result)
888879
? 'ALL_REQUIRED'
889880
: 'FULL',
890881
details: {
@@ -1109,7 +1100,7 @@ export function userValidateState() {
11091100
/**
11101101
* @typedef InstructionDocumentResultsCommandsAssertion
11111102
* @property {Description} description
1112-
* @property {Boolean} passed
1103+
* @property {Boolean | null} passed
11131104
* @property {boolean} [focus]
11141105
* @property {() => void} click
11151106
*/

tests/resources/types/aria-at-test-result.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
* @property {object} scenarioResults[].assertionResults[].assertion
3131
* @property {AriaATTestResult.AssertionPriorityJSON} scenarioResults[].assertionResults[].assertion.priority
3232
* @property {string} scenarioResults[].assertionResults[].assertion.text
33-
* @property {boolean} scenarioResults[].assertionResults[].passed
33+
* @property {boolean | null} scenarioResults[].assertionResults[].result
3434
* @property {AriaATTestResult.AssertionFailedReasonJSON | null} [scenarioResults[].assertionResults[].failedReason]
3535
* @property {object[]} scenarioResults[].unexpectedBehaviors
3636
* @property {string} scenarioResults[].unexpectedBehaviors[].id

0 commit comments

Comments
 (0)