@@ -12,6 +12,7 @@ import { promisify } from 'node:util';
1212import { afterAll , describe , expect , it , vi } from 'vitest' ;
1313
1414import {
15+ bash ,
1516 foreground ,
1617 hasTmux ,
1718 monitor ,
@@ -71,8 +72,8 @@ describe.skipIf(!ENABLED)('TUI e2e — Monitor', () => {
7172 MONITOR_ON ,
7273 ) ) ;
7374
74- it ( 'WaitFor returns as soon as a monitor prints' , scenario (
75- [ monitor ( 'sleep 2; echo "tests passed"; sleep 60' ) , waitFor ( 60 ) , say ( 'Tests passed, moving on.' ) ] ,
75+ it ( 'WaitFor on a monitor returns as soon as it prints' , scenario (
76+ [ monitor ( 'sleep 2; echo "tests passed"; sleep 60' ) , waitForMonitor ( 60 , 'ticker' ) , say ( 'Tests passed, moving on.' ) ] ,
7677 async ( { tui, model } ) => {
7778 await tui . submit ( 'Watch the tests and wait for the result' ) ;
7879 await tui . see ( 'Wait ended by monitor output' , 'wait-ended-by-event' ) ;
@@ -84,6 +85,28 @@ describe.skipIf(!ENABLED)('TUI e2e — Monitor', () => {
8485 MONITOR_ON ,
8586 ) ) ;
8687
88+ it ( 'WaitFor without a task id waits for the build, not for monitor output' , scenario (
89+ [
90+ bash ( 'sleep 6; echo build ok' ) ,
91+ monitor ( `${ gate ( 'crash' ) } ; echo "dev: 500 on /api"; sleep 60` , 'dev server' ) ,
92+ waitFor ( 30 ) ,
93+ say ( 'Build done; now the 500.' ) ,
94+ ] ,
95+ async ( { tui, model, workDir } ) => {
96+ await tui . submit ( 'Build, and keep an eye on the dev server' ) ;
97+ await tui . see ( / W a i t i n g \d + s / ) ;
98+ writeFileSync ( join ( workDir , 'crash' ) , '' ) ;
99+ await pause ( 2_500 ) ;
100+ expect ( await tui . screen ( ) ) . toMatch ( / W a i t i n g \d + s / ) ;
101+ await tui . see ( 'Build done; now the 500.' , 'build-then-event' ) ;
102+
103+ expect ( model . toolResult ( 3 ) ) . toContain ( 'wait_status: completed' ) ;
104+ expect ( model . toolResult ( 3 ) ) . toContain ( 'build ok' ) ;
105+ expect ( model . userTexts ( 3 ) . join ( '\n' ) ) . toContain ( 'dev: 500 on /api' ) ;
106+ } ,
107+ MONITOR_ON ,
108+ ) ) ;
109+
87110 it ( 'A monitor that floods output is stopped' , scenario (
88111 [ monitor ( 'yes flood' , 'flood' ) , say ( 'Started.' ) , say ( 'It was stopped.' ) , say ( 'Noted.' ) ] ,
89112 async ( { tui, model } ) => {
0 commit comments