@@ -13,6 +13,7 @@ function sessionReading(readings: Reading[], late: string[], playerReadyTimeout
1313 const session = {
1414 page : { evaluate } as unknown as Page ,
1515 lateImages : new Set ( late ) ,
16+ warnings : [ ] ,
1617 config : { playerReadyTimeout } ,
1718 } as unknown as CaptureSession ;
1819 return { session, evaluate } ;
@@ -53,17 +54,24 @@ describe("waitForShownLateImages", () => {
5354 const { session } = sessionReading ( [ { arrived : [ ] , waiting : [ PHOTO ] , broken : [ ] } ] , [ PHOTO ] , 0 ) ;
5455 const stopped = await waitForShownLateImages ( session , 360 ) . catch ( ( error : unknown ) => error ) ;
5556 expect ( stopped ) . toBeInstanceOf ( ImageMissingFromFrameError ) ;
56- expect ( stopped ) . toMatchObject ( { frameIndex : 360 , sources : [ PHOTO ] } ) ;
57+ expect ( stopped ) . toMatchObject ( { frameIndex : 360 , sources : [ PHOTO ] , failedToLoad : false } ) ;
58+ expect ( ( stopped as Error ) . message ) . toContain ( "did not load in time" ) ;
59+ expect ( session . warnings ) . toEqual ( [
60+ expect . objectContaining ( {
61+ code : "image_missing_from_frame" ,
62+ message : ( stopped as Error ) . message ,
63+ } ) ,
64+ ] ) ;
5765 } ) ;
5866
5967 it ( "stops at once for a shown image that failed to load, since waiting cannot help" , async ( ) => {
6068 const { session, evaluate } = sessionReading (
6169 [ { arrived : [ ] , waiting : [ ] , broken : [ PHOTO ] } ] ,
6270 [ PHOTO ] ,
6371 ) ;
64- await expect ( waitForShownLateImages ( session , 5 ) ) . rejects . toBeInstanceOf (
65- ImageMissingFromFrameError ,
66- ) ;
72+ const stopped = await waitForShownLateImages ( session , 5 ) . catch ( ( error : unknown ) => error ) ;
73+ expect ( stopped ) . toBeInstanceOf ( ImageMissingFromFrameError ) ;
74+ expect ( ( stopped as Error ) . message ) . toContain ( "failed to load" ) ;
6775 expect ( evaluate ) . toHaveBeenCalledTimes ( 1 ) ;
6876 } ) ;
6977} ) ;
0 commit comments