@@ -19,6 +19,9 @@ export class TestRun {
19
19
setCommandAssertion : bindDispatch ( userChangeCommandAssertion ) ,
20
20
setCommandHasUnexpectedBehavior : bindDispatch ( userChangeCommandHasUnexpectedBehavior ) ,
21
21
setCommandUnexpectedBehavior : bindDispatch ( userChangeCommandUnexpectedBehavior ) ,
22
+ setCommandUnexpectedBehaviorSeverity : bindDispatch (
23
+ userChangeCommandUnexpectedBehaviorSeverity
24
+ ) ,
22
25
setCommandUnexpectedBehaviorMore : bindDispatch ( userChangeCommandUnexpectedBehaviorMore ) ,
23
26
setCommandOutput : bindDispatch ( userChangeCommandOutput ) ,
24
27
submit : ( ) => submitResult ( this ) ,
@@ -295,6 +298,7 @@ export function instructionDocument(resultState, hooks) {
295
298
options : resultUnexpectedBehavior . behaviors . map ( ( behavior , unexpectedIndex ) => {
296
299
return {
297
300
description : behavior . description ,
301
+ severity : behavior . severity ,
298
302
enabled :
299
303
resultUnexpectedBehavior . hasUnexpected ===
300
304
HasUnexpectedBehaviorMap . HAS_UNEXPECTED ,
@@ -312,6 +316,12 @@ export function instructionDocument(resultState, hooks) {
312
316
focusFirstRequired ( ) ,
313
317
change : checked =>
314
318
hooks . setCommandUnexpectedBehavior ( { commandIndex, unexpectedIndex, checked } ) ,
319
+ severitychange : severity =>
320
+ hooks . setCommandUnexpectedBehaviorSeverity ( {
321
+ commandIndex,
322
+ unexpectedIndex,
323
+ severity,
324
+ } ) ,
315
325
keydown : key => {
316
326
const increment = keyToFocusIncrement ( key ) ;
317
327
if ( increment ) {
@@ -324,30 +334,28 @@ export function instructionDocument(resultState, hooks) {
324
334
}
325
335
return false ;
326
336
} ,
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
+ } ,
351
359
} ;
352
360
} ) ,
353
361
} ,
@@ -463,6 +471,15 @@ export const AssertionResultMap = createEnumMap({
463
471
FAIL : 'fail' ,
464
472
} ) ;
465
473
474
+ /**
475
+ * @typedef {EnumValues<typeof UnexpectedBehaviorSeverityMap> } UnexpectedBehaviorSeverity
476
+ */
477
+
478
+ export const UnexpectedBehaviorSeverityMap = createEnumMap ( {
479
+ MODERATE : 'Moderate' ,
480
+ HIGH : 'High' ,
481
+ } ) ;
482
+
466
483
/**
467
484
* @param {object } props
468
485
* @param {number } props.commandIndex
@@ -611,6 +628,44 @@ export function userChangeCommandUnexpectedBehavior({ commandIndex, unexpectedIn
611
628
} ;
612
629
}
613
630
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
+
614
669
/**
615
670
* @param {object } props
616
671
* @param {number } props.commandIndex
@@ -762,7 +817,7 @@ function resultsTableDocument(state) {
762
817
763
818
let passingAssertions = [ 'No passing assertions.' ] ;
764
819
let failingAssertions = [ 'No failing assertions.' ] ;
765
- let unexpectedBehaviors = [ 'No unexpect behaviors.' ] ;
820
+ let unexpectedBehaviors = [ 'No unexpected behaviors.' ] ;
766
821
767
822
if ( allAssertions . some ( ( { result } ) => result === CommonResultMap . PASS ) ) {
768
823
passingAssertions = allAssertions
@@ -777,7 +832,12 @@ function resultsTableDocument(state) {
777
832
if ( command . unexpected . behaviors . some ( ( { checked } ) => checked ) ) {
778
833
unexpectedBehaviors = command . unexpected . behaviors
779
834
. 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
+ } ) ;
781
841
}
782
842
783
843
return {
@@ -794,7 +854,7 @@ function resultsTableDocument(state) {
794
854
: 'FULL' ,
795
855
details : {
796
856
output : /** @type {Description } */ [
797
- 'output :' ,
857
+ 'Output :' ,
798
858
/** @type {DescriptionWhitespace } */ ( { whitespace : WhitespaceStyleMap . LINE_BREAK } ) ,
799
859
' ' ,
800
860
...command . atOutput . value . split ( / ( \r \n | \r | \n ) / g) . map ( output =>
@@ -814,7 +874,7 @@ function resultsTableDocument(state) {
814
874
items : failingAssertions ,
815
875
} ,
816
876
unexpectedBehaviors : {
817
- description : 'Unexpected Behavior ' ,
877
+ description : 'Unexpected Behaviors ' ,
818
878
items : unexpectedBehaviors ,
819
879
} ,
820
880
} ,
@@ -1122,6 +1182,7 @@ export function userValidateState() {
1122
1182
* @property {(options: {commandIndex: number, hasUnexpected: HasUnexpectedBehavior}) => void } setCommandHasUnexpectedBehavior
1123
1183
* @property {(options: {commandIndex: number, atOutput: string}) => void } setCommandOutput
1124
1184
* @property {(options: {commandIndex: number, unexpectedIndex: number, checked}) => void } setCommandUnexpectedBehavior
1185
+ * @property {(options: {commandIndex: number, unexpectedIndex: number, severity: string}) => void } setCommandUnexpectedBehaviorSeverity
1125
1186
* @property {(options: {commandIndex: number, unexpectedIndex: number, more: string}) => void } setCommandUnexpectedBehaviorMore
1126
1187
* @property {() => void } submit
1127
1188
*/
@@ -1161,6 +1222,7 @@ export function userValidateState() {
1161
1222
* @property {object } [more]
1162
1223
* @property {boolean } more.highlightRequired
1163
1224
* @property {string } more.value
1225
+ * @property {string } severity
1164
1226
*/
1165
1227
1166
1228
/**
0 commit comments