@@ -59,8 +59,8 @@ describe("runner.start", () => {
5959 const events = await collect ( o , { agentCommand : replayAgent ( spike ) } ) ;
6060
6161 expect ( events [ 0 ] ! . type ) . toBe ( "task.started" ) ;
62- expect ( events . at ( - 1 ) ! . type ) . toBe ( "task.finished" ) ;
63- expect ( events ) . toHaveLength ( 17 ) ;
62+ expect ( events . map ( ( e ) => e . type ) . slice ( - 2 ) ) . toEqual ( [ "task.finished" , "approval.requested" ] ) ;
63+ expect ( events ) . toHaveLength ( 18 ) ;
6464 expect ( events . map ( ( e ) => e . seq ) ) . toEqual ( events . map ( ( _ , i ) => i + 1 ) ) ;
6565 expect ( events . every ( ( e ) => e . sessionId === o . sessionId ) ) . toBe ( true ) ;
6666
@@ -116,8 +116,10 @@ describe("runner diff, approve and reject", () => {
116116
117117 it ( "puts the diff summary on task.finished and returns the full patch, new files included" , async ( ) => {
118118 const { runner, o, events } = await finishedRun ( ) ;
119- expect ( events . at ( - 1 ) ! . type ) . toBe ( "task.finished" ) ;
120- expect ( events . at ( - 1 ) ! . payload . diffStat ) . toMatch ( / 2 f i l e s c h a n g e d / ) ;
119+ const finished = events . at ( - 2 ) ! ;
120+ expect ( finished . type ) . toBe ( "task.finished" ) ;
121+ expect ( finished . payload . diffStat ) . toMatch ( / 2 f i l e s c h a n g e d / ) ;
122+ expect ( events . at ( - 1 ) ) . toMatchObject ( { type : "approval.requested" , payload : { diffStat : finished . payload . diffStat } } ) ;
121123 const { patch, stat } = await runner . diff ( o . sessionId ) ;
122124 expect ( patch ) . toContain ( "+world" ) ;
123125 expect ( patch ) . toContain ( "new.txt" ) ;
@@ -229,8 +231,8 @@ describe("runner.resume", () => {
229231 const { repo, o, runner, events } = await stoppedRun ( { resumeCommand : resumeWith ( "edit" ) } ) ;
230232 const resumed = await drain ( runner . resume ( o . sessionId ) ) ;
231233
232- expect ( resumed . at ( - 1 ) ! . type ) . toBe ( "task.finished" ) ;
233- expect ( resumed . at ( - 1 ) ! . payload . diffStat ) . toMatch ( / 2 f i l e s c h a n g e d / ) ;
234+ expect ( resumed . map ( ( e ) => e . type ) . slice ( - 2 ) ) . toEqual ( [ "task.finished" , "approval.requested" ] ) ;
235+ expect ( resumed . at ( - 2 ) ! . payload . diffStat ) . toMatch ( / 2 f i l e s c h a n g e d / ) ;
234236 expect ( [ ...events , ...resumed ] . map ( ( e ) => e . seq ) ) . toEqual ( [ ...events , ...resumed ] . map ( ( _ , i ) => i + 1 ) ) ;
235237
236238 const { branch } = await runner . approve ( o . sessionId , "Fix the failing test" ) ;
0 commit comments