mirror of
https://github.com/andrewyng/openworker.git
synced 2026-09-11 06:30:25 +00:00
Imported from andrewyng/aisuite@1b4bbf303e (contents of its platform/ directory, hoisted to the repo root). Development history prior to this commit lives in that repository. Co-authored-by: Devika <devikaverma11@gmail.com>
60 lines
2.9 KiB
TypeScript
60 lines
2.9 KiB
TypeScript
import { test, expect } from "./fixtures";
|
|
|
|
// The core loop: boot-resume into the last session, send a message over the WebSocket, and render
|
|
// the streamed reply — plus the in-session approval round-trip (permission_required suspends the
|
|
// turn until Allow/Deny goes back over the socket). The fake agent lives in fixtures.ts.
|
|
|
|
test("send → user bubble → streamed echo reply renders", async ({ page }) => {
|
|
await page.goto("/");
|
|
|
|
// Boot resumes the most recent session ("Draft the launch note") and connects; the composer is
|
|
// live once the fake agent's `ready` lands.
|
|
const box = page.getByPlaceholder(/Ask the coworker/);
|
|
await expect(box).toBeVisible();
|
|
|
|
await box.fill("hello agent");
|
|
await page.getByRole("button", { name: "Send" }).click();
|
|
|
|
// Local echo of the user message, then the agent's reply (delta-streamed, then finalized).
|
|
await expect(page.getByText("hello agent", { exact: true }).first()).toBeVisible();
|
|
await expect(page.getByText(/Echo: hello agent/)).toBeVisible();
|
|
// The message carried the composer's visible model (model-per-message contract): what the
|
|
// user sees at send time is exactly what serves the turn.
|
|
await expect(page.getByText("[model=anthropic:claude-opus-4-8]")).toBeVisible();
|
|
// …and having sent, the model is now FIXED for this session (§17/§22): the composer picker is
|
|
// gone and the fact reads in the topbar's facts subtitle instead.
|
|
await expect(page.locator(".dd").filter({ hasText: "Claude Opus" })).toHaveCount(0);
|
|
await expect(page.getByTestId("session-subtitle")).toContainText("Claude Opus 4.8");
|
|
// Composer cleared and re-armed for the next turn.
|
|
await expect(box).toHaveValue("");
|
|
});
|
|
|
|
test("approval: tool request suspends the turn; Allow once resumes it", async ({ page }) => {
|
|
await page.goto("/");
|
|
const box = page.getByPlaceholder(/Ask the coworker/);
|
|
await expect(box).toBeVisible();
|
|
|
|
await box.fill("please run a tool");
|
|
await page.getByRole("button", { name: "Send" }).click();
|
|
|
|
// The approval card surfaces the tool + reason and blocks until a decision.
|
|
await expect(page.getByText("The coworker wants to run a command.").first()).toBeVisible();
|
|
await page.getByRole("button", { name: "Allow once" }).last().click();
|
|
|
|
// Decision goes back over the socket; the agent finishes the tool and the turn.
|
|
await expect(page.getByText("The command ran; 1 file found.")).toBeVisible();
|
|
});
|
|
|
|
test("approval: Deny skips the tool and the agent says so", async ({ page }) => {
|
|
await page.goto("/");
|
|
const box = page.getByPlaceholder(/Ask the coworker/);
|
|
await expect(box).toBeVisible();
|
|
|
|
await box.fill("please run a tool");
|
|
await page.getByRole("button", { name: "Send" }).click();
|
|
|
|
await expect(page.getByRole("button", { name: "Deny" }).last()).toBeVisible();
|
|
await page.getByRole("button", { name: "Deny" }).last().click();
|
|
await expect(page.getByText("Understood — skipped the command.")).toBeVisible();
|
|
});
|