From 1f12ee95a1a61651a726cbd5db97c63a793eaf57 Mon Sep 17 00:00:00 2001 From: Mohamed Boudra Date: Thu, 15 Oct 2026 18:35:05 +0200 Subject: [PATCH] test(markdown): require growth while holding a streaming paragraph --- .../browser/agent-timeline-scroll-smoothness.spec.ts | 4 ++++ .../e2e/support/helpers/timeline-scroll-smoothness.ts | 10 +++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/packages/app/e2e/browser/agent-timeline-scroll-smoothness.spec.ts b/packages/app/e2e/browser/agent-timeline-scroll-smoothness.spec.ts index f3cddf3617..d5dd99e43f 100644 --- a/packages/app/e2e/browser/agent-timeline-scroll-smoothness.spec.ts +++ b/packages/app/e2e/browser/agent-timeline-scroll-smoothness.spec.ts @@ -156,6 +156,10 @@ test("reserves image space before its response arrives", async ({ page }, testIn test("holds a paragraph still while a mixed response streams and completes", async ({ page }) => { await withStreamingReader(async (agent) => { const reading = await holdParagraphThroughCompletion(page, agent); + expect( + reading.textGrowth, + "the held reader must observe an actively growing response", + ).toBeGreaterThan(1000); expect( reading.maxFollowGap, "follow-bottom must catch each streamed commit before the next frame", diff --git a/packages/app/e2e/support/helpers/timeline-scroll-smoothness.ts b/packages/app/e2e/support/helpers/timeline-scroll-smoothness.ts index 1b7522e54c..dbbbd8e7a3 100644 --- a/packages/app/e2e/support/helpers/timeline-scroll-smoothness.ts +++ b/packages/app/e2e/support/helpers/timeline-scroll-smoothness.ts @@ -100,11 +100,16 @@ export async function holdParagraphThroughCompletion(page: Page, agent: MockAgen const paragraph = page.getByRole("heading", { name: "Long section 3", exact: true }); await paragraph.waitFor({ state: "attached" }); const recording = await paragraph.evaluateHandle((heading) => { + if (!document.querySelector('[data-testid="turn-working-indicator"]')) { + throw new Error("The stream completed before the reader detached"); + } const viewport = document.querySelector('[data-testid="agent-chat-scroll"]')!; const clip = viewport.getBoundingClientRect(); viewport.scrollTop += heading.getBoundingClientRect().y - (clip.top + clip.height / 2); const baseline = heading.getBoundingClientRect().y; - const result = { maxDrift: 0, retained: true, done: false }; + const initialTextLength = heading.closest('[data-testid="assistant-message"]')!.textContent! + .length; + const result = { maxDrift: 0, retained: true, textGrowth: 0, done: false }; let stableAt = performance.now(); let signature = ""; const frame = (now: number) => { @@ -112,6 +117,9 @@ export async function holdParagraphThroughCompletion(page: Page, agent: MockAgen const current = [...document.querySelectorAll("h2")].find( (n) => n.textContent === "Long section 3", ); + const textLength = + current?.closest('[data-testid="assistant-message"]')?.textContent?.length ?? 0; + result.textGrowth = Math.max(result.textGrowth, textLength - initialTextLength); if (current) result.maxDrift = Math.max( result.maxDrift,