Skip to content

Commit 442ef65

Browse files
committed
Update client/resources
1 parent e9f4388 commit 442ef65

File tree

4 files changed

+141
-60
lines changed

4 files changed

+141
-60
lines changed

client/resources/aria-at-harness.mjs

+33-24
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
userCloseWindow,
1414
userOpenWindow,
1515
WhitespaceStyleMap,
16+
UnexpectedBehaviorSeverityMap,
1617
} from './aria-at-test-run.mjs';
1718
import { TestRunExport, TestRunInputOutput } from './aria-at-test-io-format.mjs';
1819
import { TestWindow } from './aria-at-test-window.mjs';
@@ -249,6 +250,8 @@ const h3 = bind(element, 'h3');
249250
const hr = bind(element, 'hr');
250251
const input = bind(element, 'input');
251252
const label = bind(element, 'label');
253+
const select = bind(element, 'select');
254+
const option = bind(element, 'option');
252255
const legend = bind(element, 'legend');
253256
const li = bind(element, 'li');
254257
const ol = bind(element, 'ol');
@@ -431,7 +434,8 @@ function renderVirtualInstructionDocument(doc) {
431434
id(`cmd-${commandIndex}-problem-checkboxes`),
432435
legend(rich(unexpected.failChoice.options.header)),
433436
...unexpected.failChoice.options.options.map(failOption =>
434-
fragment(
437+
fieldset(
438+
legend(rich(failOption.description)),
435439
input(
436440
type('checkbox'),
437441
value(failOption.description),
@@ -451,32 +455,37 @@ function renderVirtualInstructionDocument(doc) {
451455
}
452456
})
453457
),
454-
label(
455-
forInput(`${failOption.description}-${commandIndex}`),
456-
rich(failOption.description)
458+
label(forInput(`${failOption.description}-${commandIndex}`), rich('Behavior occurred')),
459+
br(),
460+
label(forInput(`${failOption.description}-${commandIndex}-severity`), rich('Impact: ')),
461+
select(
462+
id(`${failOption.description}-${commandIndex}-severity`),
463+
name(`${failOption.description}-${commandIndex}-severity`),
464+
option(UnexpectedBehaviorSeverityMap.MODERATE),
465+
option(UnexpectedBehaviorSeverityMap.HIGH),
466+
disabled(!failOption.checked),
467+
onchange(ev =>
468+
failOption.severitychange(/** @type {HTMLInputElement} */ (ev.currentTarget).value)
469+
)
457470
),
458471
br(),
459-
failOption.more
460-
? div(
461-
label(
462-
forInput(`${failOption.description}-${commandIndex}-input`),
463-
rich(failOption.more.description)
464-
),
465-
input(
466-
type('text'),
467-
id(`${failOption.description}-${commandIndex}-input`),
468-
name(`${failOption.description}-${commandIndex}-input`),
469-
className(['undesirable-other-input']),
470-
disabled(!failOption.more.enabled),
471-
value(failOption.more.value),
472-
onchange(ev =>
473-
failOption.more.change(
474-
/** @type {HTMLInputElement} */ (ev.currentTarget).value
475-
)
476-
)
477-
)
472+
div(
473+
label(
474+
forInput(`${failOption.description}-${commandIndex}-input`),
475+
rich(failOption.more.description)
476+
),
477+
input(
478+
type('text'),
479+
id(`${failOption.description}-${commandIndex}-input`),
480+
name(`${failOption.description}-${commandIndex}-input`),
481+
className(['undesirable-other-input']),
482+
disabled(!failOption.more.enabled),
483+
value(failOption.more.value),
484+
onchange(ev =>
485+
failOption.more.change(/** @type {HTMLInputElement} */ (ev.currentTarget).value)
478486
)
479-
: fragment()
487+
)
488+
)
480489
)
481490
)
482491
)

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

+16-7
Original file line numberDiff line numberDiff line change
@@ -699,8 +699,8 @@ class UnexpectedInput {
699699
static fromBuiltin() {
700700
return new UnexpectedInput({
701701
behaviors: [
702-
...UNEXPECTED_BEHAVIORS.map(description => ({ description, requireExplanation: false })),
703-
{ description: 'Other', requireExplanation: true },
702+
...UNEXPECTED_BEHAVIORS.map(description => ({ description })),
703+
{ description: 'Other' },
704704
],
705705
});
706706
}
@@ -1208,10 +1208,11 @@ export class TestRunInputOutput {
12081208
highlightRequired: false,
12091209
hasUnexpected: HasUnexpectedBehaviorMap.NOT_SET,
12101210
tabbedBehavior: 0,
1211-
behaviors: test.unexpectedBehaviors.map(({ description, requireExplanation }) => ({
1211+
behaviors: test.unexpectedBehaviors.map(({ description }) => ({
12121212
description,
12131213
checked: false,
1214-
more: requireExplanation ? { highlightRequired: false, value: '' } : null,
1214+
severity: UnexpectedBehaviorSeverityMap.MODERATE,
1215+
more: { highlightRequired: false, value: '' },
12151216
})),
12161217
},
12171218
})
@@ -1419,7 +1420,8 @@ export class TestRunInputOutput {
14191420
behavior.checked
14201421
? {
14211422
text: behavior.description,
1422-
otherUnexpectedBehaviorText: behavior.more ? behavior.more.value : null,
1423+
severity: behavior.severity,
1424+
unexpectedBehaviorText: behavior.more.value,
14231425
}
14241426
: null
14251427
)
@@ -1491,7 +1493,10 @@ export class TestRunInputOutput {
14911493
more: behavior.more
14921494
? {
14931495
highlightRequired: false,
1494-
value: behaviorResult ? behaviorResult.otherUnexpectedBehaviorText : '',
1496+
severity: behaviorResult
1497+
? behavior.severity
1498+
: UnexpectedBehaviorSeverityMap.MODERATE,
1499+
value: behaviorResult ? behaviorResult.unexpectedBehaviorText : '',
14951500
}
14961501
: behavior.more,
14971502
};
@@ -1576,6 +1581,11 @@ const AssertionFailJSONMap = createEnumMap({
15761581
FAIL: 'Fail',
15771582
});
15781583

1584+
const UnexpectedBehaviorSeverityMap = createEnumMap({
1585+
MODERATE: 'Moderate',
1586+
HIGH: 'High',
1587+
});
1588+
15791589
/** @typedef {SubmitResultDetailsCommandsAssertionsPass | SubmitResultDetailsCommandsAssertionsFail} SubmitResultAssertionsJSON */
15801590

15811591
/**
@@ -1735,7 +1745,6 @@ function invariant(test, message, ...args) {
17351745
/**
17361746
* @typedef BehaviorUnexpectedItem
17371747
* @property {string} description
1738-
* @property {boolean} requireExplanation
17391748
*/
17401749

17411750
/**

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

+90-28
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ export class TestRun {
1919
setCommandAssertion: bindDispatch(userChangeCommandAssertion),
2020
setCommandHasUnexpectedBehavior: bindDispatch(userChangeCommandHasUnexpectedBehavior),
2121
setCommandUnexpectedBehavior: bindDispatch(userChangeCommandUnexpectedBehavior),
22+
setCommandUnexpectedBehaviorSeverity: bindDispatch(
23+
userChangeCommandUnexpectedBehaviorSeverity
24+
),
2225
setCommandUnexpectedBehaviorMore: bindDispatch(userChangeCommandUnexpectedBehaviorMore),
2326
setCommandOutput: bindDispatch(userChangeCommandOutput),
2427
submit: () => submitResult(this),
@@ -295,6 +298,7 @@ export function instructionDocument(resultState, hooks) {
295298
options: resultUnexpectedBehavior.behaviors.map((behavior, unexpectedIndex) => {
296299
return {
297300
description: behavior.description,
301+
severity: behavior.severity,
298302
enabled:
299303
resultUnexpectedBehavior.hasUnexpected ===
300304
HasUnexpectedBehaviorMap.HAS_UNEXPECTED,
@@ -312,6 +316,12 @@ export function instructionDocument(resultState, hooks) {
312316
focusFirstRequired(),
313317
change: checked =>
314318
hooks.setCommandUnexpectedBehavior({ commandIndex, unexpectedIndex, checked }),
319+
severitychange: severity =>
320+
hooks.setCommandUnexpectedBehaviorSeverity({
321+
commandIndex,
322+
unexpectedIndex,
323+
severity,
324+
}),
315325
keydown: key => {
316326
const increment = keyToFocusIncrement(key);
317327
if (increment) {
@@ -324,30 +334,28 @@ export function instructionDocument(resultState, hooks) {
324334
}
325335
return false;
326336
},
327-
more: behavior.more
328-
? {
329-
description: /** @type {Description[]} */ ([
330-
`If "other" selected, explain`,
331-
{
332-
required: true,
333-
highlightRequired: behavior.more.highlightRequired,
334-
description: '(required)',
335-
},
336-
]),
337-
enabled: behavior.checked,
338-
value: behavior.more.value,
339-
focus:
340-
resultState.currentUserAction === 'validateResults' &&
341-
behavior.more.highlightRequired &&
342-
focusFirstRequired(),
343-
change: value =>
344-
hooks.setCommandUnexpectedBehaviorMore({
345-
commandIndex,
346-
unexpectedIndex,
347-
more: value,
348-
}),
349-
}
350-
: null,
337+
more: {
338+
description: /** @type {Description[]} */ ([
339+
`Details: `,
340+
{
341+
required: true,
342+
highlightRequired: behavior.more.highlightRequired,
343+
description: '(required)',
344+
},
345+
]),
346+
enabled: behavior.checked,
347+
value: behavior.more.value,
348+
focus:
349+
resultState.currentUserAction === 'validateResults' &&
350+
behavior.more.highlightRequired &&
351+
focusFirstRequired(),
352+
change: value =>
353+
hooks.setCommandUnexpectedBehaviorMore({
354+
commandIndex,
355+
unexpectedIndex,
356+
more: value,
357+
}),
358+
},
351359
};
352360
}),
353361
},
@@ -463,6 +471,15 @@ export const AssertionResultMap = createEnumMap({
463471
FAIL: 'fail',
464472
});
465473

474+
/**
475+
* @typedef {EnumValues<typeof UnexpectedBehaviorSeverityMap>} UnexpectedBehaviorSeverity
476+
*/
477+
478+
export const UnexpectedBehaviorSeverityMap = createEnumMap({
479+
MODERATE: 'Moderate',
480+
HIGH: 'High',
481+
});
482+
466483
/**
467484
* @param {object} props
468485
* @param {number} props.commandIndex
@@ -611,6 +628,44 @@ export function userChangeCommandUnexpectedBehavior({ commandIndex, unexpectedIn
611628
};
612629
}
613630

631+
/**
632+
* @param {object} props
633+
* @param {number} props.commandIndex
634+
* @param {number} props.unexpectedIndex
635+
* @param {string} props.severity
636+
* @returns {(state: TestRunState) => TestRunState}
637+
*/
638+
export function userChangeCommandUnexpectedBehaviorSeverity({
639+
commandIndex,
640+
unexpectedIndex,
641+
severity,
642+
}) {
643+
return function (state) {
644+
return {
645+
...state,
646+
currentUserAction: UserActionMap.CHANGE_TEXT,
647+
commands: state.commands.map((command, commandI) =>
648+
commandI !== commandIndex
649+
? command
650+
: /** @type {TestRunCommand} */ ({
651+
...command,
652+
unexpected: {
653+
...command.unexpected,
654+
behaviors: command.unexpected.behaviors.map((unexpected, unexpectedI) =>
655+
unexpectedI !== unexpectedIndex
656+
? unexpected
657+
: /** @type {TestRunUnexpectedBehavior} */ ({
658+
...unexpected,
659+
severity: severity,
660+
})
661+
),
662+
},
663+
})
664+
),
665+
};
666+
};
667+
}
668+
614669
/**
615670
* @param {object} props
616671
* @param {number} props.commandIndex
@@ -762,7 +817,7 @@ function resultsTableDocument(state) {
762817

763818
let passingAssertions = ['No passing assertions.'];
764819
let failingAssertions = ['No failing assertions.'];
765-
let unexpectedBehaviors = ['No unexpect behaviors.'];
820+
let unexpectedBehaviors = ['No unexpected behaviors.'];
766821

767822
if (allAssertions.some(({ result }) => result === CommonResultMap.PASS)) {
768823
passingAssertions = allAssertions
@@ -777,7 +832,12 @@ function resultsTableDocument(state) {
777832
if (command.unexpected.behaviors.some(({ checked }) => checked)) {
778833
unexpectedBehaviors = command.unexpected.behaviors
779834
.filter(({ checked }) => checked)
780-
.map(({ description, more }) => (more ? more.value : description));
835+
.map(({ description, more, severity }) => {
836+
let result = `${description} (`;
837+
if (more) result = `${result}Details: ${more.value}, `;
838+
result = `${result}Impact: ${severity})`;
839+
return result;
840+
});
781841
}
782842

783843
return {
@@ -794,7 +854,7 @@ function resultsTableDocument(state) {
794854
: 'FULL',
795855
details: {
796856
output: /** @type {Description} */ [
797-
'output:',
857+
'Output:',
798858
/** @type {DescriptionWhitespace} */ ({ whitespace: WhitespaceStyleMap.LINE_BREAK }),
799859
' ',
800860
...command.atOutput.value.split(/(\r\n|\r|\n)/g).map(output =>
@@ -814,7 +874,7 @@ function resultsTableDocument(state) {
814874
items: failingAssertions,
815875
},
816876
unexpectedBehaviors: {
817-
description: 'Unexpected Behavior',
877+
description: 'Unexpected Behaviors',
818878
items: unexpectedBehaviors,
819879
},
820880
},
@@ -1122,6 +1182,7 @@ export function userValidateState() {
11221182
* @property {(options: {commandIndex: number, hasUnexpected: HasUnexpectedBehavior}) => void } setCommandHasUnexpectedBehavior
11231183
* @property {(options: {commandIndex: number, atOutput: string}) => void} setCommandOutput
11241184
* @property {(options: {commandIndex: number, unexpectedIndex: number, checked}) => void } setCommandUnexpectedBehavior
1185+
* @property {(options: {commandIndex: number, unexpectedIndex: number, severity: string}) => void } setCommandUnexpectedBehaviorSeverity
11251186
* @property {(options: {commandIndex: number, unexpectedIndex: number, more: string}) => void } setCommandUnexpectedBehaviorMore
11261187
* @property {() => void} submit
11271188
*/
@@ -1161,6 +1222,7 @@ export function userValidateState() {
11611222
* @property {object} [more]
11621223
* @property {boolean} more.highlightRequired
11631224
* @property {string} more.value
1225+
* @property {string} severity
11641226
*/
11651227

11661228
/**

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,6 @@
3434
* @property {object[]} scenarioResults[].unexpectedBehaviors
3535
* @property {string} scenarioResults[].unexpectedBehaviors[].id
3636
* @property {string} scenarioResults[].unexpectedBehaviors[].text
37-
* @property {string | null} [scenarioResults[].unexpectedBehaviors[].otherUnexpectedBehaviorText]
37+
* @property {string} scenarioResults[].unexpectedBehaviors[].severity
38+
* @property {string} scenarioResults[].unexpectedBehaviors[].unexpectedBehaviorText
3839
*/

0 commit comments

Comments
 (0)