@@ -2357,6 +2357,40 @@ 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 pngImage = ( png : Buffer ) => ( {
2366+ toPNG : ( ) => png ,
2367+ toJPEG : ( ) => png ,
2368+ getSize : ( ) => ( { width : 1280 , height : 720 } ) ,
2369+ } ) ;
2370+ const capturePage = vi
2371+ . fn < ( ) => Promise < ReturnType < typeof pngImage > > > ( )
2372+ . mockResolvedValueOnce ( pngImage ( firstPng ) )
2373+ . mockResolvedValueOnce ( pngImage ( secondPng ) ) ;
2374+ fromId . mockReturnValue ( makeTestPreviewWebContents ( capturePage ) ) ;
2375+ yield * manager . createTab ( "tab_1" ) ;
2376+ yield * manager . registerWebview ( "tab_1" , 42 ) ;
2377+ // it.effect keeps TestClock fixed until explicitly advanced.
2378+ const first = yield * manager . captureScreenshot ( "tab_1" ) ;
2379+ const second = yield * manager . captureScreenshot ( "tab_1" ) ;
2380+
2381+ expect ( first . createdAt ) . toBe ( second . createdAt ) ;
2382+ expect ( first . id ) . not . toBe ( second . id ) ;
2383+ expect ( first . path ) . not . toBe ( second . path ) ;
2384+ 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 } $ / ) ;
2385+ 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 } $ / ) ;
2386+ expect ( writeFile . mock . calls ) . toEqual ( [
2387+ [ first . path , firstPng ] ,
2388+ [ second . path , secondPng ] ,
2389+ ] ) ;
2390+ } ) ,
2391+ ) ,
2392+ ) ;
2393+
23602394 effectIt . effect ( "keeps every recorded guest unthrottled until its frame capture stops" , ( ) =>
23612395 withManager ( ( manager ) =>
23622396 Effect . gen ( function * ( ) {
0 commit comments