Add three composition cases driven by the same generic web Tool: - examples/doc-site (documentation site), - examples/research-workspace (existing section 8 workbench prototype), - examples/quantum-editor (finite scenario/interaction design). Add a real production delivery trial in examples/research-workbench-app (Express + JSON persistence + static UI): validation, search, status transitions, linked statistics, JSON errors, real file persistence; node:test API acceptance and a Playwright browser E2E. The production app is not a runtime dependency of the web Tool; prototype PASS is kept separate from production PASS. docs/WEB-04-delivery.md records the design-source to implementation mapping, intentional non-goals and task splits. scripts/domain-acceptance.sh is the explicit domain entry: installs the built Tool, runs check/preview/handoff for the three cases, then installs/tests the production app incl. browser E2E, and removes the Tool. Evidence records the real CLI/Design/Preview identities and local PASS results. Pin the domain submodules to the merged Design (WEB-01/03) and Preview (WEB-02) candidates; activation and root gitlink belong to WEB-05. Refs cflmy/marqdo-ext-web#2, cflmy/marqdo#6
45 lines
2.2 KiB
JavaScript
45 lines
2.2 KiB
JavaScript
// Production E2E for the research workbench (run where a browser is available).
|
|
import { test, expect } from "@playwright/test";
|
|
|
|
test("list, search, create and statistics stay linked", async ({ page }) => {
|
|
await page.route("**/api/**", async (route) => {
|
|
const url = new URL(route.request().url());
|
|
if (url.pathname === "/api/tasks" && route.request().method() === "GET") {
|
|
const query = url.searchParams.get("q") ?? "";
|
|
const tasks = [
|
|
{ id: 1, title: "测量超导比特", priority: "high", status: "open" },
|
|
{ id: 2, title: "整理实验记录", priority: "normal", status: "done" },
|
|
].filter((task) => task.title.includes(query));
|
|
return route.fulfill({ json: { tasks } });
|
|
}
|
|
if (url.pathname === "/api/stats") {
|
|
return route.fulfill({ json: { total: 2, byStatus: { open: 1, doing: 0, done: 1 }, byPriority: { low: 0, normal: 1, high: 1 } } });
|
|
}
|
|
if (url.pathname === "/api/tasks" && route.request().method() === "POST") {
|
|
const body = route.request().postDataJSON();
|
|
if (!String(body.title ?? "").trim()) {
|
|
return route.fulfill({ status: 400, json: { error: { code: "task.title_required", message: "任务标题不能为空" } } });
|
|
}
|
|
return route.fulfill({ status: 201, json: { task: { id: 3, title: body.title, priority: "normal", status: "open" } } });
|
|
}
|
|
return route.continue();
|
|
});
|
|
|
|
await page.goto("/");
|
|
await expect(page.getByTestId("stats")).toContainText("总数 2");
|
|
await expect(page.getByTestId("tasks")).toContainText("测量超导比特");
|
|
|
|
await page.getByLabel("搜索任务").fill("实验");
|
|
await expect(page.getByTestId("tasks")).toContainText("整理实验记录");
|
|
await expect(page.getByTestId("tasks")).not.toContainText("测量超导比特");
|
|
|
|
await page.getByLabel("搜索任务").fill("");
|
|
await page.getByLabel("标题").fill("新建任务");
|
|
await page.getByRole("button", { name: "创建" }).click();
|
|
await expect(page.getByTestId("error")).toBeHidden();
|
|
|
|
await page.getByLabel("标题").fill(" ");
|
|
await page.getByRole("button", { name: "创建" }).click();
|
|
await expect(page.getByTestId("error")).toContainText("任务标题不能为空");
|
|
});
|