mirror of
https://github.com/getpaseo/paseo.git
synced 2026-11-03 15:12:48 +00:00
test(markdown): require growth while holding a streaming paragraph
This commit is contained in:
@@ -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",
|
||||
|
||||
@@ -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<HTMLElement>('[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,
|
||||
|
||||
Reference in New Issue
Block a user