From b43ecc2870a294ba603a250ce724f773d664ce75 Mon Sep 17 00:00:00 2001 From: 4gray Date: Mon, 28 Sep 2026 10:46:18 +0200 Subject: [PATCH] test(perf): bound J2's late-request check by the quiet sample's mark The late-activity check compared requests against a fresh ledger mark taken after waitForQuiet returned. A request that arrived while the final quiet sample was still reading the IPC capture advanced that mark and escaped the check. The boundary is now the ledger position read by the accepted sample itself, like its DOM and IPC counts. Co-Authored-By: Claude Opus 5.5 --- .../src/journeys/open-source-journey-app.ts | 30 ++++++++++++------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/apps/electron-backend-e2e/src/journeys/open-source-journey-app.ts b/apps/electron-backend-e2e/src/journeys/open-source-journey-app.ts index 108882406..f8ef080bd 100644 --- a/apps/electron-backend-e2e/src/journeys/open-source-journey-app.ts +++ b/apps/electron-backend-e2e/src/journeys/open-source-journey-app.ts @@ -76,7 +76,11 @@ async function waitForQuiet( page: Page, ledger: JourneyMockRequestLedger, probeStateKey: string -): Promise { +): Promise<{ + /** Ledger position read by the accepted quiet sample itself. */ + readonly ledgerMark: number; + readonly settle: OpenSourceJourneySettle; +}> { const armMark = ledger.mark(); const sample = async (): Promise => { const launchCapture = await peekJourneyMainIpcCapture( @@ -111,11 +115,14 @@ async function waitForQuiet( timeoutMs: SETTLE_TIMEOUT_MS, }); return { - preStartDomMutations: quiet.domMutations, - preStartHttpRequests: quiet.httpRequests - armMark, - preStartIpcCalls: quiet.ipcCalls, - quietMs: QUIET_MS, - waitedMs, + ledgerMark: quiet.httpRequests, + settle: { + preStartDomMutations: quiet.domMutations, + preStartHttpRequests: quiet.httpRequests - armMark, + preStartIpcCalls: quiet.ipcCalls, + quietMs: QUIET_MS, + waitedMs, + }, }; } @@ -171,15 +178,18 @@ export async function measureOpenSourceJourney( // Hover first so hover effects (and anything they trigger) happen // before the app settles, not inside the measured window. await card.hover({ timeout: timeoutMs }); - const settle = await waitForQuiet( + // The boundary for late requests is the ledger position the accepted + // quiet sample read, like its DOM and IPC counts; a fresh mark taken + // here would skip a request that arrived while that sample was still + // reading the IPC capture. Requests from that position on but before + // the renderer's click stamp arrived after the app settled, and the + // record rejects such an iteration. + const { ledgerMark: settledLedgerMark, settle } = await waitForQuiet( electronApp, mainWindow, ledger, probeOptions.stateKey ); - // Requests from here on but before the renderer's click stamp arrived - // after the app settled; the record rejects such an iteration. - const settledLedgerMark = ledger.mark(); await card.click({ timeout: timeoutMs }); const renderer: JourneyRendererProbeState = await waitForJourneyRendererProbe(