diff --git a/packages/studio/tests/e2e/timeline-viewport-verdict.mjs b/packages/studio/tests/e2e/timeline-viewport-verdict.mjs index 4437cb43e5..831b21fd7b 100644 --- a/packages/studio/tests/e2e/timeline-viewport-verdict.mjs +++ b/packages/studio/tests/e2e/timeline-viewport-verdict.mjs @@ -123,6 +123,11 @@ export function describeAgainstBase({ head, base, interactions, frameIntervals, ].join(", "); } +/** Which build is measured: a row-virtualized timeline mounts only the rows in view, an unvirtualized one every row. */ +export function rowVirtualizationOf({ mountedRows }, budgets) { + return mountedRows <= budgets.maxMountedRows ? "on" : "off"; +} + /** A failed timing attempt is measured once more, so one bad stretch of a shared runner cannot fail the gate alone. */ export const TIMING_ATTEMPTS = 2; diff --git a/packages/studio/tests/e2e/timeline-viewport-verdict.test.mjs b/packages/studio/tests/e2e/timeline-viewport-verdict.test.mjs index 7ec09c29d2..4a9d319054 100644 --- a/packages/studio/tests/e2e/timeline-viewport-verdict.test.mjs +++ b/packages/studio/tests/e2e/timeline-viewport-verdict.test.mjs @@ -9,6 +9,7 @@ import { percentile, shouldCompareWithBase, responsivenessLimits, + rowVirtualizationOf, } from "./timeline-viewport-verdict.mjs"; const LIMITS = { samplesPerRun: 63, interactionLimitMs: 75, frameIntervalLimitMs: 75 }; @@ -239,3 +240,16 @@ describe("gatePassed", () => { expect(gatePassed({ ...passing, attempts: [], againstBase: pass })).toBe(false); }); }); + +describe("rowVirtualizationOf", () => { + // fails without the fix: main's gate read this load-time moment of a virtualized base as an unvirtualized build. + it("reads a virtualized timeline as on while its visible rows are full at load", () => { + const atLoad = { mountedRows: 8, mountedClipRoots: 1024, maxMountedClipRootsInOneRow: 128 }; + expect(rowVirtualizationOf(atLoad, TIMELINE_VIEWPORT_BUDGETS)).toBe("on"); + }); + + it("reads a timeline that mounts every row as off", () => { + const everyRow = { mountedRows: 1000, mountedClipRoots: 1000, maxMountedClipRootsInOneRow: 1 }; + expect(rowVirtualizationOf(everyRow, TIMELINE_VIEWPORT_BUDGETS)).toBe("off"); + }); +}); diff --git a/packages/studio/tests/e2e/timeline-virtualization.mjs b/packages/studio/tests/e2e/timeline-virtualization.mjs index f6efd97328..54ce6e5cd8 100644 --- a/packages/studio/tests/e2e/timeline-virtualization.mjs +++ b/packages/studio/tests/e2e/timeline-virtualization.mjs @@ -33,6 +33,7 @@ import { judgeAgainstBase, judgeResponsiveness, responsivenessLimits, + rowVirtualizationOf, shouldCompareWithBase, TIMING_ATTEMPTS, timingPassed, @@ -477,22 +478,20 @@ async function assertProductionRuntime(page) { } async function assertRowVirtualization(page, budgets) { - // Trust the DOM, not the caller. A virtualized build cannot mount every clip - // and an unvirtualized one cannot avoid it, so the mounted count says which - // build is really being measured. - const observedClipRoots = await page.evaluate( - () => window.__studioTest.readTimelinePerformanceDiagnostics().mountedClipRoots, + // Trust the DOM, not the caller: the mounted rows say which build is really being measured. + const diagnostics = await page.evaluate(() => + window.__studioTest.readTimelinePerformanceDiagnostics(), ); - const observedRowVirtualization = observedClipRoots <= budgets.maxMountedClipRoots ? "on" : "off"; + const observedRowVirtualization = rowVirtualizationOf(diagnostics, budgets); if (observedRowVirtualization !== ROW_VIRTUALIZATION) { throw new Error( `Requested TIMELINE_ROW_VIRTUALIZATION=${ROW_VIRTUALIZATION} but the server under test ` + - `behaves as ${observedRowVirtualization}: ${observedClipRoots} clip roots mounted for ` + - `${ELEMENT_COUNT} elements against a ${budgets.maxMountedClipRoots} budget. ` + + `behaves as ${observedRowVirtualization}: ${diagnostics.mountedRows} rows mounted for ` + + `${ELEMENT_COUNT} elements against a ${budgets.maxMountedRows} budget. ` + "Set VITE_STUDIO_TIMELINE_ROW_VIRTUALIZATION_ENABLED on the Studio dev server to match.", ); } - return observedClipRoots; + return diagnostics.mountedClipRoots; } async function waitForFixtureRender(page, elementCount) {