Files
openworker/surfaces/gui/e2e-live/approval.spec.ts
T
Rohit C PrasadandDevika 2b45018ffa OpenWorker: initial import
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>
2026-07-21 11:09:41 -07:00

33 lines
1.7 KiB
TypeScript

import { test, expect } from "@playwright/test";
import { readFileSync } from "fs";
import { newestFile, scratchBaseIfReady, sendTask, startCoworkSession } from "./helpers";
// LIVE #1 — the approval gate. In the default "Ask for approval" mode a tool call must block on an
// in-transcript approval card; approving it lets execution proceed. (fib.md skips this via Full
// access.) Excluded from CI — run with `npm run e2e:live`.
test("live: a write blocks on an approval card, then completes once approved", async ({ page }) => {
const scratchBase = await scratchBaseIfReady();
test.skip(!scratchBase, "live backend not ready — start coworker-server and configure a model");
// Unique filename per run so the "doesn't exist before approval" check can't see a prior run's file.
const name = `hello-${Date.now()}.txt`;
await startCoworkSession(page);
// Leave the default "Ask for approval" mode — the write should gate.
await sendTask(page, `Create a file named ${name} containing exactly the text: hello world`);
// The tool call blocks on an approval card, and the file does not exist yet.
await expect(page.getByText("Permission required")).toBeVisible({ timeout: 120_000 });
expect(newestFile(scratchBase!, name), "file must not exist before approval").toBeNull();
// Approve it.
await page.getByRole("button", { name: "Allow once" }).click();
// Now it runs to completion and the artifact lands on disk.
await expect(page.getByText(/Artifacts \(\d+\)/)).toBeVisible({ timeout: 120_000 });
const file = newestFile(scratchBase!, name);
expect(file, `no ${name} found under ${scratchBase}`).toBeTruthy();
expect(readFileSync(file!, "utf8").toLowerCase()).toContain("hello world");
});