An open source design system that's fully customizable and agent ready
TypeScript
test(Lightbox): the slowed-settle calibration pools its three settles (#10855)
Christopher Chedeau168d9979b26e
diff --git a/packages/core/src/Lightbox/__tests__/LightboxPaging.interaction.browser.spec.ts b/packages/core/src/Lightbox/__tests__/LightboxPaging.interaction.browser.spec.tsindex c509405fd0..98490a954e 100644--- a/packages/core/src/Lightbox/__tests__/LightboxPaging.interaction.browser.spec.ts+++ b/packages/core/src/Lightbox/__tests__/LightboxPaging.interaction.browser.spec.ts@@ -803,42 +803,6 @@ async function pooledSettleProof(};}-/**- * How long after each settle starts its block starts. Each run swipes and- * blocks as `pooledSettleProof` does, with the screencast on, so its block- * starts as a judged run's does. It reads no frames.- */-async function settleBlockLags(- page: Page,- g: Gallery,- toward: ReadonlyArray<'next' | 'previous'>,-): Promise<number[]> {- const trackRuns = await recordTrackRuns(g.track);- const lags: number[] = [];- for (const direction of toward) {- await expect- .poll(async () =>- g.track.evaluate(el =>- el.getAnimations().some(a => a.playState === 'running'),- ),- )- .toBe(false);- const cast = await startScreencast(page);- const blocking = blockOnceShown(g.track, 600);- await g.driver.play(swipeAtRest(g, direction));- const block = await blocking;- await frames(page, 6);- await cast.stop();- const settle = (await trackRuns()).at(-1);- if (settle == null) {- throw new Error('no settle recorded');- }- lags.push(block.from - settle.from);- await waitForRest(g.track);- }- return lags;-}-test('the page settle keeps advancing every frame while the main thread is blocked', async ({page,}, testInfo) => {@@ -1003,25 +967,32 @@ for (const late of ['two frames', '450 ms'] as const) {const g = await openGallery(page);await startBusyControl(page);await slowViewer(page, SETTLE_TEMPO);- // Three settles first give this machine's numbers: how long after a- // settle starts its block starts. The first, judged in full, also gives- // the cast's frame interval. One settle can start its block late, such as- // the first in a new gallery. A delay read from it would push the motion- // past the block. So 450 ms counts from the earliest block, and two frames- // from the median one. The delayed settle then stays still for that long,- // then for two frames and a little more or for 450 ms. That is past the- // one frame the proof skips.- const first = await pooledSettleProof(page, g, ['next']);- const lags = [- first.blocks[0].from - first.settles[0].from,- ...(await settleBlockLags(page, g, ['next', 'previous'])),- ];+ // Three settles first give this machine's numbers, judged as one pool.+ // Their blocks show how long after a settle starts its block starts, and+ // their casts give the frame interval during a block. One run can hold+ // too few control frames to judge, in WebKit or on a loaded machine.+ // Three runs together hold enough. One settle can start its block late,+ // such as the first in a new gallery. A delay read from it would push the+ // motion past the block. So 450 ms counts from the earliest block, and two+ // frames from the median one. The delayed settle then stays still for+ // that long, then for two frames and a little more or for 450 ms. That is+ // past the one frame the proof skips.+ const calibration = await pooledSettleProof(page, g, [+ 'next',+ 'next',+ 'previous',+ ]);+ const lags = calibration.blocks.map(+ (block, i) => block.from - calibration.settles[i].from,+ );const blockAfterMs =late === 'two frames' ? median(lags) : Math.min(...lags);- // A run the pool left out has no frame interval to measure by.- const cadenceMs = first.proof.runs[0]?.cadenceMs;- expect(cadenceMs, first.proof.summary).toBeGreaterThan(0);- const stillMs = late === 'two frames' ? 2.2 * (cadenceMs ?? 0) : 450;+ // Only the runs the pool judged give a frame interval.+ const cadences = calibration.proof.runs.flatMap((run, i) =>+ run != null && calibration.proof.judged[i] ? [run.cadenceMs] : [],+ );+ expect(cadences.length, calibration.proof.summary).toBeGreaterThan(0);+ const stillMs = late === 'two frames' ? 2.2 * median(cadences) : 450;const delayMs = blockAfterMs + stillMs;await breakSettle(g, 'delayed', delayMs);const {proof, blocks, settles} = await pooledSettleProof(page, g, [