evOo-local/apps/web/e2e/approval-resume.spec.ts
cynarAI d1f7034aa5 fix(e2e): wait for shell-ready after group chat reload (#94)
* fix(e2e): wait for shell-ready after group chat reload

After voice/connect and full page reload on a group route, bootstrap
can still be in flight. Use waitForChatComposer (data-ready + Message
combobox) instead of asserting the composer immediately, matching #87.

Co-authored-by: cynarAI <cynarAI@users.noreply.github.com>

* fix(e2e): wait for shell before approval transcript after reload

Transcript messages are not painted until bootstrap finishes; match
group-chats and #87 by waiting on data-ready before asserting durable
approval copy survives reload.

Co-authored-by: cynarAI <cynarAI@users.noreply.github.com>

* style: format approval-resume e2e import

Co-authored-by: cynarAI <cynarAI@users.noreply.github.com>

* fix(e2e): wait for archived sidebar after space delete

After deleting a space the Archived section can appear only once
bootstrap finishes; wait for shell-ready after archive reload and assert
the Archived toggle before clicking.

Co-authored-by: cynarAI <cynarAI@users.noreply.github.com>

* fix(e2e): expect archived sidebar when last bot is archived

After archiving the only bot, the shell is ready without a Message
composer. Wait for data-ready and the Archived toggle instead of
waitForChatComposer on reload.

Co-authored-by: cynarAI <cynarAI@users.noreply.github.com>

* fix(e2e): wait for shell in composer-paste openComposer helper

Third paste spec failed when Message appeared before bootstrap finished;
reuse waitForChatComposer after navigating to /app.

Co-authored-by: cynarAI <cynarAI@users.noreply.github.com>

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: cynarAI <cynarAI@users.noreply.github.com>
2026-10-02 15:50:00 +02:00

65 lines
3.1 KiB
TypeScript

import { expect, test } from "@playwright/test";
import { captureScreenshot, completeOnboarding, signup, waitForChatComposer } from "./helpers";
test.describe.configure({ mode: "serial" });
test("approval input resumes durable work", async ({ page }, testInfo) => {
const stamp = Date.now();
await signup(page, `approval-${stamp}@rakazo.test`, "password12", "Approval");
await completeOnboarding(page);
const composer = page.getByPlaceholder(/Message/);
await composer.fill("ask me which city to use");
await page.keyboard.press("Enter");
const prompt = page.locator("p").filter({ hasText: /^Which city should I use\?$/ });
await expect(prompt).toBeVisible({ timeout: 30_000 });
await expect(page.getByText("Reply with one city name.", { exact: true })).toBeVisible();
await expect(page.getByRole("button", { name: "Send it" })).toBeVisible();
await expect(page.getByRole("button", { name: "Edit first" })).toBeVisible();
await captureScreenshot(page, testInfo, "20-approval-input-request");
await page.getByRole("button", { name: "Edit first" }).click();
const answer = page.getByRole("textbox", { name: "Answer" });
await answer.fill("ask me which city to use again");
await expect(page.getByRole("button", { name: "Send answer" })).toBeEnabled();
await captureScreenshot(page, testInfo, "21-approval-custom-answer");
await page.getByRole("button", { name: "Send answer" }).click();
await expect(prompt).toHaveCount(2, { timeout: 30_000 });
await expect(
page.getByText("Answered: ask me which city to use again", { exact: true }),
).toBeVisible();
await expect(page.getByRole("button", { name: "Send it" })).toHaveCount(1);
await captureScreenshot(page, testInfo, "22-second-approval-prompt");
await page.getByRole("button", { name: "Edit first" }).click();
await answer.fill("Paris");
await captureScreenshot(page, testInfo, "23-second-approval-answer");
await page.getByRole("button", { name: "Send answer" }).click();
const resumed = page.getByText(
"on it. i will work this in the background and come back with a result.",
{ exact: true },
);
await expect(resumed).toBeVisible({ timeout: 30_000 });
const handledAnswer = page.getByText("done. i handled: Paris", { exact: true });
await expect(handledAnswer).toBeVisible();
await expect(page.getByText("Answered: Paris", { exact: true })).toBeVisible();
await page.reload({ waitUntil: "domcontentloaded" });
await waitForChatComposer(page);
await expect(resumed).toBeVisible({ timeout: 30_000 });
await expect(handledAnswer).toBeVisible();
await expect(page.getByText("Answered: Paris", { exact: true })).toBeVisible();
await captureScreenshot(page, testInfo, "24-approval-resumed-after-reload");
await composer.fill("ask me which city to use");
await page.keyboard.press("Enter");
await expect(prompt).toHaveCount(3, { timeout: 30_000 });
await page.getByRole("button", { name: "Stop" }).click();
await expect(page.getByText("No longer active", { exact: true })).toBeVisible();
await expect(page.getByRole("button", { name: "Send it" })).toHaveCount(0);
await captureScreenshot(page, testInfo, "25-stopped-approval-prompt");
});