perf(tests): remove timed output and synchronize browser fixtures

This commit is contained in:
morluto
2026-10-11 13:20:16 +08:00
parent d3088c3795
commit 693ed332b5
3 changed files with 38 additions and 13 deletions
@@ -224,6 +224,7 @@ describe("CdpBrowserProvider: explicitly requested text and payload shapes", ()
const browser = await startFakeCdpBrowser({
sensitiveShapes: true,
binaryWebSocketEvent: true,
eventsBeforeReply: ["Network.enable"],
});
trackBrowser(browser);
const result = await new CdpBrowserProvider().inspectPage(
@@ -63,30 +63,29 @@ const capture = async (
};
itWithCaptureCapability.each(["cli", "mcp"] as const)(
"localizes sparse rendered-state exhaustion through %s",
"localizes rendered-state expansion exhaustion through %s",
async (adapter) => {
const root = await createTestTempDirectory("rea-rendered-budget-");
// CSI REP expands a small raw burst into a full screen, so rendered
// exhaustion does not depend on how the PTY batches output chunks.
const output = "x\u001b[79b".repeat(24);
const result = await capture(adapter, {
executable: process.execPath,
working_directory: root,
arguments: [
"-e",
"let n=0;const timer=setInterval(()=>{console.log('board '+String(n).padStart(2,'0')+' completed; score '+String(n*10));if(++n===65)clearInterval(timer)},20)",
],
arguments: ["-e", `process.stdout.write(${JSON.stringify(output)})`],
terminal: { columns: 80, rows: 24, scrollback: 0 },
normalization: {
ports: false,
pids: false,
paths: false,
time_bucket_ms: 1,
},
limits: { output_bytes: 30_000 },
limits: { output_bytes: 1_000 },
});
const details = result.truncation_details;
if (details === undefined) throw new Error("Expected producer coverage");
expect(result.frames.map(({ data }) => data).join("")).toContain(
"board 64 completed; score 640",
);
expect(details.raw_terminal.observed_bytes).toBe(2004);
expect(result.frames.map(({ data }) => data).join("")).toBe(output);
expect(details.raw_terminal.observed_bytes).toBe(Buffer.byteLength(output));
expect(details.raw_terminal.retained_bytes).toBe(
details.raw_terminal.observed_bytes,
);
@@ -94,9 +93,7 @@ itWithCaptureCapability.each(["cli", "mcp"] as const)(
expect(details.rendered_terminal.observed_frames).toBeGreaterThan(
result.rendered_frames.length,
);
expect(details.rendered_terminal.retained_bytes).toBeLessThanOrEqual(
30_000,
);
expect(details.rendered_terminal.retained_bytes).toBeLessThanOrEqual(1_000);
expect(details.process.coverage).toBe("sampled");
expect(processSourceTruncated(result, "terminal_raw")).toBe(false);
expect(processSourceTruncated(result, "terminal_rendered")).toBe(true);