Files
OpenMesh/surfaces/gui/e2e-live/fib.spec.ts
zhaolei 6f402ffcee
Some checks failed
CI / pytest (push) Has been cancelled
CI / gui-unit (push) Has been cancelled
CI / gui-e2e (push) Has been cancelled
feat: OpenMesh 基础平台与 MD/PDF 转换技能
- 后端: coworker 智能体框架, WS API, 文件上传, 附件处理
- 前端: Open WebUI, 文件全量走 upload API (含 MD/TXT/JSON 等文本类)
- 技能: md-to-office (pandoc + wkhtmltopdf)
- 修复: 上传文件路径丢失, Agent 搜索浪费, 输出文件跑到 uploads/
- 打包: PyInstaller one-dir, 预打包 pandoc/wkhtmltopdf/chromium
2026-09-13 23:41:04 +08:00

34 lines
1.7 KiB
TypeScript

import { test, expect } from "@playwright/test";
import { readFileSync } from "fs";
import { newestFile, scratchBaseIfReady, selectMode, sendTask, startCoworkSession } from "./helpers";
// LIVE end-to-end smoke: drive the real app against the real backend + a real model, ask it to
// produce a file in Full-access mode, and verify the artifact lands on disk with correct contents.
// This is the vertical the hermetic suite mocks (model, tool execution, file I/O, WS streaming).
// Excluded from CI (separate config/dir) — run with `npm run e2e:live`.
const PROMPT =
"Compute the first 20 Fibonacci numbers and write them to fib.md with a one-line explanation at the top.";
// Distinctive Fibonacci values unlikely to appear in prose — a format-tolerant correctness check.
const EXPECTED = ["144", "377", "987", "4181"];
test("live: agent writes fib.md to its scratch workspace, verified on disk", async ({ page }) => {
const scratchBase = await scratchBaseIfReady();
test.skip(!scratchBase, "live backend not ready — start openworker-server and configure a model");
await startCoworkSession(page);
await selectMode(page, "Full access"); // run the write without an approval gate
await sendTask(page, PROMPT);
// The artifact rail gains a file once the write tool has run (model + tool time).
await expect(page.getByText(/Artifacts \(\d+\)/)).toBeVisible({ timeout: 150_000 });
// Verify on disk — the strongest signal that the whole stack worked.
const file = newestFile(scratchBase!, "fib.md");
expect(file, `no fib.md found under ${scratchBase}`).toBeTruthy();
const text = readFileSync(file!, "utf8");
for (const n of EXPECTED) {
expect(text, `fib.md should contain Fibonacci value ${n}`).toContain(n);
}
});