From 072676a620263a57c98a3b7548a94d282a12b7a1 Mon Sep 17 00:00:00 2001 From: "Molecule AI Dev Engineer A (Kimi)" Date: Sun, 14 Jun 2026 20:03:17 +0000 Subject: [PATCH] fix(canvas/e2e): assert seeded chat history text, not arbitrary div count CR2 #11826 + Researcher #11827 RC: the previous hasHistory check used , which is an arbitrary heuristic and not a real proof that the seeded transcript hydrated. Replace it with explicit Playwright visibility assertions for the seeded user + agent messages, and assert the empty-state placeholder is hidden. - desktop: assert 'Hello from seed' / 'Echo: Hello from seed' visible. - mobile: assert 'Hello from mobile seed' / 'Echo: Hello from mobile seed' visible. - Both: assert empty-state text is hidden. The path-filter trigger for canvas/e2e/chat-*.spec.ts is already in .gitea/workflows/e2e-chat.yml (chat-spec-direct block) so this PR will execute the real Playwright E2E Chat lane. --- canvas/e2e/chat-desktop.spec.ts | 14 +++++++------- canvas/e2e/chat-mobile.spec.ts | 14 +++++++------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/canvas/e2e/chat-desktop.spec.ts b/canvas/e2e/chat-desktop.spec.ts index 9d3cc896..0a550bcb 100644 --- a/canvas/e2e/chat-desktop.spec.ts +++ b/canvas/e2e/chat-desktop.spec.ts @@ -72,14 +72,14 @@ test.describe("Desktop ChatTab", () => { }); test("chat panel loads without error", async ({ page }) => { - const hasEmptyState = await page.getByText("Send a message to start chatting.").isVisible().catch(() => false); - const hasHistory = await page.locator("#panel-chat [data-testid='chat-panel']:visible").locator("div").count() > 3; + const chat = page.locator("#panel-chat [data-testid='chat-panel']:visible"); + const emptyState = chat.getByText("Send a message to start chatting."); // The workspace is seeded with chat history; empty-state here is a - // hydration/render failure, not a valid initial condition. Require - // history AND reject empty state to avoid the false-green where the - // panel renders the empty placeholder but no seeded transcript. - expect(hasHistory, "seeded chat history should be visible in the panel").toBeTruthy(); - expect(hasEmptyState, "empty state should not appear when seeded history exists").toBeFalsy(); + // hydration/render failure, not a valid initial condition. Assert the + // seeded transcript renders AND the empty placeholder is absent. + await expect(chat.getByText("Hello from seed", { exact: true })).toBeVisible({ timeout: 5_000 }); + await expect(chat.getByText("Echo: Hello from seed")).toBeVisible({ timeout: 5_000 }); + await expect(emptyState).toBeHidden(); }); test("echo fixture workspace is configured for push delivery", async () => { diff --git a/canvas/e2e/chat-mobile.spec.ts b/canvas/e2e/chat-mobile.spec.ts index d8fda59f..611be44a 100644 --- a/canvas/e2e/chat-mobile.spec.ts +++ b/canvas/e2e/chat-mobile.spec.ts @@ -51,14 +51,14 @@ test.describe("MobileChat", () => { }); test("chat panel loads without error", async ({ page }) => { - const hasEmptyState = await page.getByText("Send a message to start chatting.").isVisible().catch(() => false); - const hasHistory = await page.locator("[data-testid='chat-panel']").locator("div").count() > 3; + const chat = page.locator("[data-testid='chat-panel']"); + const emptyState = chat.getByText("Send a message to start chatting."); // The workspace is seeded with chat history; empty-state here is a - // hydration/render failure, not a valid initial condition. Require - // history AND reject empty state to avoid the false-green where the - // panel renders the empty placeholder but no seeded transcript. - expect(hasHistory, "seeded chat history should be visible in the panel").toBeTruthy(); - expect(hasEmptyState, "empty state should not appear when seeded history exists").toBeFalsy(); + // hydration/render failure, not a valid initial condition. Assert the + // seeded transcript renders AND the empty placeholder is absent. + await expect(chat.getByText("Hello from mobile seed", { exact: true })).toBeVisible({ timeout: 5_000 }); + await expect(chat.getByText("Echo: Hello from mobile seed")).toBeVisible({ timeout: 5_000 }); + await expect(emptyState).toBeHidden(); }); test("send text message and receive echo response", async ({ page }) => { -- 2.52.0