Skip to content

Commit 1e3480d

Browse files
committed
test(ui): hold the 10,000-node Overview and folder view to counted work budgets
The 10K wall-time checks for Ack and going back to the Overview sat at their budgets and failed under ordinary load. Following #1569, the required budgets project now counts layouts, style recalculations, DOM changes, nodes, rows drawn and mock reads for each interaction the timing test covers: opening the folder view, expand all, opening one folder, scrolling the opened tree, going back to the Overview and acknowledging nodes out of date. The wall-time test stays as it was, in the non-required UI timings job, which reports it. Acknowledging holds back the Overview's read that follows (the mock client's reply timer) and requires the item to have left the list already, so the settling that moves it at once is checked without timing it. Budgets come from 10 runs each at 1x and 6x CPU, with #1569's headroom. Both regressions tried are caught: with the folder tree's windowing off, expand all draws 4,480 rows against 28; with settling off, the item stays listed while the read is held, and styles go over budget.
1 parent 01916d9 commit 1e3480d

1 file changed

Lines changed: 119 additions & 1 deletion

File tree

‎ui/e2e/budgets.spec.ts‎

Lines changed: 119 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,102 @@ test('Plan: switching sections and showing more on a large changed build', async
249249
);
250250
});
251251

252+
/**
253+
* Runs in the page before the app. While `__sqbHoldReads(true)`, the mock client's replies (each a
254+
* `readMs` timer) are held, and run when holding stops, so a test can see the page before a read lands.
255+
*/
256+
function holdReads(readMs: number) {
257+
const realSetTimeout = window.setTimeout.bind(window);
258+
let holding = false;
259+
let next = 2e9;
260+
const held: (() => void)[] = [];
261+
window.setTimeout = ((handler: TimerHandler, ms?: number, ...args: unknown[]) => {
262+
if (!holding || ms !== readMs || typeof handler !== 'function') return realSetTimeout(handler, ms, ...args);
263+
held.push(() => handler(...args));
264+
return ++next;
265+
}) as typeof window.setTimeout;
266+
(window as unknown as { __sqbHoldReads: (on: boolean) => void }).__sqbHoldReads = (on) => {
267+
holding = on;
268+
if (on) return;
269+
for (const run of held.splice(0)) run();
270+
};
271+
}
272+
273+
const holdMockReads = (page: Page, on: boolean) => page.evaluate((o) => (window as unknown as { __sqbHoldReads: (on: boolean) => void }).__sqbHoldReads(o), on);
274+
275+
const FOLDER_ROW = '[data-testid="folder-tree"] tbody tr[data-path], [data-testid="folder-tree"] tbody tr.leaf';
276+
const ISSUE = 'section.health .issues .issue';
277+
278+
test('Overview and folder view on a 10,000-node project', async ({ page }) => {
279+
test.setTimeout(300_000);
280+
// The mock client's reply latency (`latencyMs`).
281+
await page.addInitScript(holdReads, 120);
282+
const cdp = await open(page, '/?mock&huge&still', ISSUE);
283+
const quiet = async () => {
284+
await page.waitForLoadState('networkidle');
285+
await frames(page, 4);
286+
};
287+
judge(
288+
'10K open the folder view',
289+
await cost(page, cdp, FOLDER_ROW, async () => {
290+
await page.getByTestId('all-folders').click();
291+
await page.locator(FOLDER_ROW).nth(19).waitFor();
292+
}),
293+
BUDGETS['10K open the folder view']
294+
);
295+
judge(
296+
'10K expand all',
297+
await cost(page, cdp, FOLDER_ROW, async () => {
298+
await page.getByRole('button', { name: 'Expand all' }).click();
299+
await page.locator('[data-testid="folder-tree"] tbody tr.leaf, [data-testid="folder-more"]').first().waitFor();
300+
}),
301+
BUDGETS['10K expand all']
302+
);
303+
await page.getByRole('button', { name: 'Collapse all' }).click();
304+
await quiet();
305+
judge(
306+
'10K open one folder',
307+
await cost(page, cdp, FOLDER_ROW, async () => {
308+
await page.getByTestId('folder-toggle').first().click();
309+
await page.locator('[data-testid="folder-toggle"][aria-expanded="true"]').first().waitFor();
310+
}),
311+
BUDGETS['10K open one folder']
312+
);
313+
await page.getByRole('button', { name: 'Expand all' }).click();
314+
await quiet();
315+
const tree = (await page.getByTestId('folder-tree').locator('tbody').boundingBox())!;
316+
judge(
317+
'10K opened tree scroll',
318+
await cost(page, cdp, FOLDER_ROW, () => wheel(page, { x: tree.x + tree.width / 2, y: Math.min(tree.y + 200, 800) }, 20, (i) => (i < 10 ? 400 : -400))),
319+
BUDGETS['10K opened tree scroll']
320+
);
321+
judge(
322+
'10K back to the Overview',
323+
await cost(page, cdp, ISSUE, async () => {
324+
await page.locator('nav a', { hasText: 'Overview' }).first().click();
325+
await page.locator(ISSUE).first().waitFor();
326+
}),
327+
BUDGETS['10K back to the Overview']
328+
);
329+
const stale = page.locator(ISSUE, { hasText: 'out of date' });
330+
let listedWhileReading = -1;
331+
judge(
332+
'10K acknowledge nodes out of date',
333+
await cost(page, cdp, ISSUE, async () => {
334+
// The Overview's read that follows is held: the item must leave the list without waiting for it.
335+
await holdMockReads(page, true);
336+
await stale.getByRole('button', { name: 'Acknowledge' }).click();
337+
await frames(page, 4);
338+
listedWhileReading = await stale.count();
339+
await holdMockReads(page, false);
340+
await page.waitForFunction(() => ![...document.querySelectorAll('section.health .issues .issue')].some((e) => e.textContent?.includes('out of date')));
341+
}),
342+
BUDGETS['10K acknowledge nodes out of date']
343+
);
344+
console.info(`BUDGET 10K acknowledged item still listed while the Overview reads again: ${listedWhileReading}`);
345+
expect.soft(listedWhileReading, 'an acknowledged item leaves the list at once, not after the Overview is read again').toBe(0);
346+
});
347+
252348
// Measured on 10 runs each at 1× and 6× CPU (Chrome throttling), with the breakdown traced from the
253349
// mutation records (`BUDGET_TRACE=1`). The graph's settle timer is held while a gesture is counted and
254350
// run once at its end, so DOM changes and reads are the same on every run and get 2 of headroom.
@@ -285,5 +381,27 @@ const BUDGETS: Record<string, Budget> = {
285381
'Plan section unchanged': { layouts: 4, styles: 8, mutations: 117, nodes: 2500, drawn: 50, reads: 1 },
286382
'Plan section changed': { layouts: 3, styles: 7, mutations: 113, nodes: 2850, drawn: 50, reads: 0 },
287383
// Show more reads the next page once and adds its 50 rows. Measured layouts 2, styles 8–9, mutations 54.
288-
'Plan show more': { layouts: 4, styles: 12, mutations: 56, nodes: 3400, drawn: 100, reads: 1 }
384+
'Plan show more': { layouts: 4, styles: 12, mutations: 56, nodes: 3400, drawn: 100, reads: 1 },
385+
// The 10,000-node project (`?huge`), measured the same way: DOM changes, nodes, rows and reads the
386+
// same in every run but one (141 against 140 DOM changes going back to the Overview at 6×). The folder
387+
// tree windows its rows like any long list; drawing every folder or node instead adds thousands of rows.
388+
// Opening the folder view reads the selection vocabulary once and draws 40 rows: 320 cell class writes,
389+
// 40 rows' label and wrap classes, the rest the tab switch. Measured layouts 3, styles 12–17.
390+
'10K open the folder view': { layouts: 5, styles: 24, mutations: 456, nodes: 7300, drawn: 44, reads: 1 },
391+
// Expand all swaps the window's rows for the expanded tree's (316 row insertions and removals) and
392+
// rewrites their cells' classes. Measured layouts 1, styles 11–16.
393+
'10K expand all': { layouts: 3, styles: 23, mutations: 577, nodes: 5700, drawn: 28, reads: 0 },
394+
// Opening one folder inserts its 20 subfolder rows and rewrites the window's cell classes (440).
395+
// Measured layouts 1–2, styles 9–15.
396+
'10K open one folder': { layouts: 5, styles: 23, mutations: 469, nodes: 7500, drawn: 48, reads: 0 },
397+
// 20 wheel steps of 400 px over the expanded tree: like the Checks list, each step swaps rows in and out
398+
// of the window (2,142) and rewrites the recycled cells' classes (6,579), one layout per step.
399+
// Measured layouts 20, styles 45–53, mutations 8,800.
400+
'10K opened tree scroll': { layouts: 22, styles: 63, mutations: 8802, nodes: 5700, drawn: 28, reads: 0 },
401+
// Reads the Overview, its timeline and the cost summary once each, and draws the attention card's 9
402+
// items and the timeline. Measured layouts 3–4, styles 22–31, mutations 140–141.
403+
'10K back to the Overview': { layouts: 7, styles: 42, mutations: 143, nodes: 4600, drawn: 12, reads: 3 },
404+
// The acknowledgement and the Overview's read that follows it; the item leaves the list at once (the
405+
// test holds that read back to check), so 6 DOM changes. Measured layouts 1, styles 6–7.
406+
'10K acknowledge nodes out of date': { layouts: 3, styles: 10, mutations: 8, nodes: 4700, drawn: 11, reads: 2 }
289407
};

0 commit comments

Comments
 (0)