@@ -2240,6 +2240,46 @@ describe("PreviewManager", () => {
22402240 ) ,
22412241 ) ;
22422242
2243+ effectIt . effect ( "preserves both screenshots of the same site in the same millisecond" , ( ) =>
2244+ withManager ( ( manager ) =>
2245+ Effect . gen ( function * ( ) {
2246+ const firstPng = Buffer . from ( "first-preview-png" ) ;
2247+ const secondPng = Buffer . from ( "second-preview-png" ) ;
2248+ const capturePage = vi . fn ( async ( ) => ( {
2249+ toPNG : ( ) => firstPng ,
2250+ toJPEG : ( ) => firstPng ,
2251+ getSize : ( ) => ( { width : 1280 , height : 720 } ) ,
2252+ } ) ) ;
2253+ capturePage . mockResolvedValueOnce ( {
2254+ toPNG : ( ) => firstPng ,
2255+ toJPEG : ( ) => firstPng ,
2256+ getSize : ( ) => ( { width : 1280 , height : 720 } ) ,
2257+ } ) ;
2258+ capturePage . mockResolvedValueOnce ( {
2259+ toPNG : ( ) => secondPng ,
2260+ toJPEG : ( ) => secondPng ,
2261+ getSize : ( ) => ( { width : 1280 , height : 720 } ) ,
2262+ } ) ;
2263+ fromId . mockReturnValue ( makeTestPreviewWebContents ( capturePage ) ) ;
2264+ yield * manager . createTab ( "tab_1" ) ;
2265+ yield * manager . registerWebview ( "tab_1" , 42 ) ;
2266+ // it.effect keeps TestClock fixed until explicitly advanced.
2267+ const first = yield * manager . captureScreenshot ( "tab_1" ) ;
2268+ const second = yield * manager . captureScreenshot ( "tab_1" ) ;
2269+
2270+ expect ( first . createdAt ) . toBe ( second . createdAt ) ;
2271+ expect ( first . id ) . not . toBe ( second . id ) ;
2272+ expect ( first . path ) . not . toBe ( second . path ) ;
2273+ 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 } $ / ) ;
2274+ 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 } $ / ) ;
2275+ expect ( writeFile . mock . calls ) . toEqual ( [
2276+ [ first . path , firstPng ] ,
2277+ [ second . path , secondPng ] ,
2278+ ] ) ;
2279+ } ) ,
2280+ ) ,
2281+ ) ;
2282+
22432283 effectIt . effect ( "keeps every recorded guest unthrottled until its frame capture stops" , ( ) =>
22442284 withManager ( ( manager ) =>
22452285 Effect . gen ( function * ( ) {
0 commit comments