@@ -934,6 +934,8 @@ describe('workflowStatusCommand', () => {
934934 } ,
935935 ] ) ;
936936
937+ const startTime = new Date ( Date . now ( ) - 25 * 1000 ) . toISOString ( ) ;
938+ const endTime = new Date ( Date . now ( ) - 15 * 1000 ) . toISOString ( ) ;
937939 ( workflowEventsDb . listWorkflowEvents as ReturnType < typeof mock > ) . mockResolvedValueOnce ( [
938940 {
939941 id : 'e1' ,
@@ -942,16 +944,16 @@ describe('workflowStatusCommand', () => {
942944 step_name : 'plan' ,
943945 step_index : null ,
944946 data : { } ,
945- created_at : new Date ( ) . toISOString ( ) ,
947+ created_at : startTime ,
946948 } ,
947949 {
948950 id : 'e2' ,
949951 workflow_run_id : 'run-verbose' ,
950952 event_type : 'node_completed' ,
951953 step_name : 'plan' ,
952954 step_index : null ,
953- data : { node_output : 'Plan output here' , duration_ms : 5000 } ,
954- created_at : new Date ( ) . toISOString ( ) ,
955+ data : { node_output : 'Plan output here' } ,
956+ created_at : endTime ,
955957 } ,
956958 ] ) ;
957959
@@ -961,7 +963,6 @@ describe('workflowStatusCommand', () => {
961963 expect ( calls . some ( c => c . includes ( 'Nodes:' ) ) ) . toBe ( true ) ;
962964 expect ( calls . some ( c => c . includes ( '✓' ) && c . includes ( 'plan' ) ) ) . toBe ( true ) ;
963965 expect ( calls . some ( c => c . includes ( 'Plan output here' ) ) ) . toBe ( true ) ;
964- expect ( calls . some ( c => c . includes ( 'Total:' ) ) ) . toBe ( true ) ;
965966 } ) ;
966967
967968 it ( 'should show error message for failed node in verbose mode' , async ( ) => {
@@ -978,6 +979,8 @@ describe('workflowStatusCommand', () => {
978979 } ,
979980 ] ) ;
980981
982+ const startTime = new Date ( Date . now ( ) - 20 * 1000 ) . toISOString ( ) ;
983+ const endTime = new Date ( Date . now ( ) - 10 * 1000 ) . toISOString ( ) ;
981984 ( workflowEventsDb . listWorkflowEvents as ReturnType < typeof mock > ) . mockResolvedValueOnce ( [
982985 {
983986 id : 'e3' ,
@@ -986,16 +989,16 @@ describe('workflowStatusCommand', () => {
986989 step_name : 'implement' ,
987990 step_index : null ,
988991 data : { } ,
989- created_at : new Date ( ) . toISOString ( ) ,
992+ created_at : startTime ,
990993 } ,
991994 {
992995 id : 'e4' ,
993996 workflow_run_id : 'run-failed' ,
994997 event_type : 'node_failed' ,
995998 step_name : 'implement' ,
996999 step_index : null ,
997- data : { error : 'Compilation failed' , duration_ms : 3000 } ,
998- created_at : new Date ( ) . toISOString ( ) ,
1000+ data : { error : 'Compilation failed' } ,
1001+ created_at : endTime ,
9991002 } ,
10001003 ] ) ;
10011004
@@ -1006,51 +1009,6 @@ describe('workflowStatusCommand', () => {
10061009 expect ( calls . some ( c => c . includes ( 'Compilation failed' ) ) ) . toBe ( true ) ;
10071010 } ) ;
10081011
1009- it ( 'should truncate output at word boundary in verbose mode' , async ( ) => {
1010- const workflowDb = await import ( '@archon/core/db/workflows' ) ;
1011- const workflowEventsDb = await import ( '@archon/core/db/workflow-events' ) ;
1012-
1013- ( workflowDb . listWorkflowRuns as ReturnType < typeof mock > ) . mockResolvedValueOnce ( [
1014- {
1015- id : 'run-truncate' ,
1016- workflow_name : 'implement' ,
1017- working_path : '/path/to/worktree' ,
1018- status : 'running' ,
1019- started_at : new Date ( Date . now ( ) - 5 * 1000 ) ,
1020- } ,
1021- ] ) ;
1022-
1023- // Build a 210-char string with spaces every 5 chars: "aaaaa bbbbb ccccc ..."
1024- const words = Array . from ( { length : 42 } , ( _ , i ) =>
1025- String . fromCharCode ( 97 + ( i % 26 ) ) . repeat ( 5 )
1026- ) ;
1027- const longOutput = words . join ( ' ' ) ; // 5*42 + 41 spaces = 251 chars total
1028-
1029- ( workflowEventsDb . listWorkflowEvents as ReturnType < typeof mock > ) . mockResolvedValueOnce ( [
1030- {
1031- id : 'e-trunc' ,
1032- workflow_run_id : 'run-truncate' ,
1033- event_type : 'node_completed' ,
1034- step_name : 'plan' ,
1035- step_index : null ,
1036- data : { node_output : longOutput , duration_ms : 1000 } ,
1037- created_at : new Date ( ) . toISOString ( ) ,
1038- } ,
1039- ] ) ;
1040-
1041- await workflowStatusCommand ( false , true ) ;
1042-
1043- const calls = consoleSpy . mock . calls . map ( ( c : unknown [ ] ) => String ( c [ 0 ] ) ) ;
1044- const outputLine = calls . find ( c => c . includes ( 'Output:' ) ) ?? '' ;
1045- const preview = outputLine . replace ( / ^ \s * O u t p u t : \s * / , '' ) ;
1046- // Must end with '...' (was truncated)
1047- expect ( preview . endsWith ( '...' ) ) . toBe ( true ) ;
1048- // The cut must be at a word boundary: char in original at cut position must be a space
1049- const previewText = preview . slice ( 0 , - 3 ) ; // remove trailing '...'
1050- const cutPos = previewText . length ;
1051- expect ( longOutput [ cutPos ] ) . toBe ( ' ' ) ; // original char right after cut is a space
1052- } ) ;
1053-
10541012 it ( 'should not show nodes section when no events in verbose mode' , async ( ) => {
10551013 const workflowDb = await import ( '@archon/core/db/workflows' ) ;
10561014 const workflowEventsDb = await import ( '@archon/core/db/workflow-events' ) ;
0 commit comments