@@ -2357,6 +2357,46 @@ describe("PreviewManager", () => {
23572357 ) ,
23582358 ) ;
23592359
2360+ effectIt . effect ( "preserves both screenshots of the same site in the same millisecond" , ( ) =>
2361+ withManager ( ( manager ) =>
2362+ Effect . gen ( function * ( ) {
2363+ const firstPng = Buffer . from ( "first-preview-png" ) ;
2364+ const secondPng = Buffer . from ( "second-preview-png" ) ;
2365+ const capturePage = vi . fn ( async ( ) => ( {
2366+ toPNG : ( ) => firstPng ,
2367+ toJPEG : ( ) => firstPng ,
2368+ getSize : ( ) => ( { width : 1280 , height : 720 } ) ,
2369+ } ) ) ;
2370+ capturePage . mockResolvedValueOnce ( {
2371+ toPNG : ( ) => firstPng ,
2372+ toJPEG : ( ) => firstPng ,
2373+ getSize : ( ) => ( { width : 1280 , height : 720 } ) ,
2374+ } ) ;
2375+ capturePage . mockResolvedValueOnce ( {
2376+ toPNG : ( ) => secondPng ,
2377+ toJPEG : ( ) => secondPng ,
2378+ getSize : ( ) => ( { width : 1280 , height : 720 } ) ,
2379+ } ) ;
2380+ fromId . mockReturnValue ( makeTestPreviewWebContents ( capturePage ) ) ;
2381+ yield * manager . createTab ( "tab_1" ) ;
2382+ yield * manager . registerWebview ( "tab_1" , 42 ) ;
2383+ // it.effect keeps TestClock fixed until explicitly advanced.
2384+ const first = yield * manager . captureScreenshot ( "tab_1" ) ;
2385+ const second = yield * manager . captureScreenshot ( "tab_1" ) ;
2386+
2387+ expect ( first . createdAt ) . toBe ( second . createdAt ) ;
2388+ expect ( first . id ) . not . toBe ( second . id ) ;
2389+ expect ( first . path ) . not . toBe ( second . path ) ;
2390+ expect ( first . id ) . toMatch ( / ^ b r o w s e r - s c r e e n s h o t - e x a m p l e - c o m - [ a - z 0 - 9 ] + - [ 0 - 9 a - f ] { 8 } $ / ) ;
2391+ expect ( second . id ) . toMatch ( / ^ b r o w s e r - s c r e e n s h o t - e x a m p l e - c o m - [ a - z 0 - 9 ] + - [ 0 - 9 a - f ] { 8 } $ / ) ;
2392+ expect ( writeFile . mock . calls ) . toEqual ( [
2393+ [ first . path , firstPng ] ,
2394+ [ second . path , secondPng ] ,
2395+ ] ) ;
2396+ } ) ,
2397+ ) ,
2398+ ) ;
2399+
23602400 effectIt . effect ( "keeps every recorded guest unthrottled until its frame capture stops" , ( ) =>
23612401 withManager ( ( manager ) =>
23622402 Effect . gen ( function * ( ) {
0 commit comments