@@ -250,7 +250,7 @@ describe("useTimelinePlayhead follow while paused", () => {
250250} ) ;
251251
252252describe ( "useTimelinePlayhead committed viewport" , ( ) => {
253- it ( "keeps the visible 59-second clip mounted when a pointer zoom commits" , ( ) => {
253+ function mountViewport ( scrollLeft : number ) {
254254 vi . stubGlobal (
255255 "ResizeObserver" ,
256256 class {
@@ -264,7 +264,7 @@ describe("useTimelinePlayhead committed viewport", () => {
264264 timelineFitPps : 10 ,
265265 timelinePps : 100 ,
266266 } ) ;
267- const scroll = scrollBox ( 5000 , 1080 ) ;
267+ const scroll = scrollBox ( scrollLeft , 1080 ) ;
268268 const container = document . createElement ( "div" ) ;
269269 function Probe ( ) {
270270 const pps = usePlayerStore ( ( s ) => s . timelinePps ) ;
@@ -290,18 +290,36 @@ describe("useTimelinePlayhead committed viewport", () => {
290290 }
291291 const root = createRoot ( container ) ;
292292 roots . push ( root ) ;
293+ act ( ( ) => root . render ( < Probe /> ) ) ;
294+ return { scroll, container } ;
295+ }
296+
297+ afterEach ( ( ) => vi . unstubAllGlobals ( ) ) ;
298+
299+ it ( "keeps the visible 59-second clip mounted when a pointer zoom commits" , ( ) => {
300+ const { scroll, container } = mountViewport ( 5000 ) ;
301+ expect ( container . querySelector ( '[data-clip="59"]' ) ) . not . toBeNull ( ) ;
302+ act ( ( ) => {
303+ requestTimelineZoom ( 1090 , { time : 55.24 , x : 556 } ) ;
304+ settleTimelineZoom ( ) ;
305+ } ) ;
306+ expect ( scroll . scrollLeft ) . toBeCloseTo ( 5497.16 ) ;
307+ expect ( container . querySelector ( '[data-clip="59"]' ) ) . not . toBeNull ( ) ;
308+ expect ( Number ( container . querySelector ( "output" ) ?. textContent ) ) . toBeCloseTo ( 5497.16 ) ;
309+ } ) ;
310+
311+ it ( "renders a pan at the laid-out scale before the browser paints" , ( ) => {
312+ const { scroll, container } = mountViewport ( 0 ) ;
313+ const actEnvironment = globalThis as { IS_REACT_ACT_ENVIRONMENT ?: boolean } ;
314+ const wasActEnvironment = actEnvironment . IS_REACT_ACT_ENVIRONMENT ;
315+ actEnvironment . IS_REACT_ACT_ENVIRONMENT = false ;
293316 try {
294- act ( ( ) => root . render ( < Probe /> ) ) ;
295- expect ( container . querySelector ( '[data-clip="59"]' ) ) . not . toBeNull ( ) ;
296- act ( ( ) => {
297- requestTimelineZoom ( 1090 , { time : 55.24 , x : 556 } ) ;
298- settleTimelineZoom ( ) ;
299- } ) ;
300- expect ( scroll . scrollLeft ) . toBeCloseTo ( 5497.16 ) ;
301- expect ( container . querySelector ( '[data-clip="59"]' ) ) . not . toBeNull ( ) ;
302- expect ( Number ( container . querySelector ( "output" ) ?. textContent ) ) . toBeCloseTo ( 5497.16 ) ;
317+ requestTimelineZoom ( 1000 , { time : 60 , x : ORIGIN } ) ;
318+ settleTimelineZoom ( ) ;
319+ expect ( scroll . scrollLeft ) . toBe ( 6000 ) ;
320+ expect ( container . querySelector ( "output" ) ?. textContent ) . toBe ( "6000" ) ;
303321 } finally {
304- vi . unstubAllGlobals ( ) ;
322+ actEnvironment . IS_REACT_ACT_ENVIRONMENT = wasActEnvironment ;
305323 }
306324 } ) ;
307325} ) ;
0 commit comments