1+ import test from 'node:test' ;
2+ import assert from 'node:assert/strict' ;
3+
4+ import { shouldShowAllClear } from './review_outcome_state.mjs' ;
5+
6+ test ( 'shouldShowAllClear returns true for completed reviews with zero comments and no error' , ( ) => {
7+ assert . equal ( shouldShowAllClear ( {
8+ status : 'completed' ,
9+ totalComments : 0 ,
10+ errorSummary : '' ,
11+ } ) , true ) ;
12+ } ) ;
13+
14+ test ( 'shouldShowAllClear returns false when comments exist' , ( ) => {
15+ assert . equal ( shouldShowAllClear ( {
16+ status : 'completed' ,
17+ totalComments : 1 ,
18+ errorSummary : '' ,
19+ } ) , false ) ;
20+ } ) ;
21+
22+ test ( 'shouldShowAllClear returns false when an error summary is present' , ( ) => {
23+ assert . equal ( shouldShowAllClear ( {
24+ status : 'completed' ,
25+ totalComments : 0 ,
26+ errorSummary : 'Review failed' ,
27+ } ) , false ) ;
28+ } ) ;
29+
30+ test ( 'shouldShowAllClear returns false while review is still running' , ( ) => {
31+ assert . equal ( shouldShowAllClear ( {
32+ status : 'in_progress' ,
33+ totalComments : 0 ,
34+ errorSummary : '' ,
35+ } ) , false ) ;
36+ } ) ;
37+
38+ test ( 'shouldShowAllClear normalizes string inputs and whitespace-only error summaries' , ( ) => {
39+ assert . equal ( shouldShowAllClear ( {
40+ status : ' Completed ' ,
41+ totalComments : '0' ,
42+ errorSummary : ' ' ,
43+ } ) , true ) ;
44+ } ) ;
45+
46+ test ( 'shouldShowAllClear treats missing or non-numeric comment counts as zero' , ( ) => {
47+ assert . equal ( shouldShowAllClear ( {
48+ status : 'completed' ,
49+ totalComments : undefined ,
50+ errorSummary : undefined ,
51+ } ) , true ) ;
52+
53+ assert . equal ( shouldShowAllClear ( {
54+ status : 'completed' ,
55+ totalComments : 'not-a-number' ,
56+ errorSummary : '' ,
57+ } ) , true ) ;
58+ } ) ;
59+
60+ test ( 'shouldShowAllClear rejects non-string error payloads' , ( ) => {
61+ assert . equal ( shouldShowAllClear ( {
62+ status : 'completed' ,
63+ totalComments : 0 ,
64+ errorSummary : { message : 'boom' } ,
65+ } ) , false ) ;
66+ } ) ;
67+
68+ test ( 'shouldShowAllClear rejects missing status even when counts are zero' , ( ) => {
69+ assert . equal ( shouldShowAllClear ( {
70+ status : null ,
71+ totalComments : 0 ,
72+ errorSummary : '' ,
73+ } ) , false ) ;
74+ } ) ;
0 commit comments