feat: WEB-04 domain composition cases and production delivery trial
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
This commit was merged in pull request #4.
This commit is contained in:
1 parent
df4324f3e3
commit
7a2c9280c0
26 files changed
+1559
-3
No files matched your search
@@ -0,0 +1,88 @@
|
||||
// Production API acceptance: real server, real file persistence, real HTTP.
|
||||
import test from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { mkdtempSync, readFileSync, rmSync } from "node:fs";
|
||||
import { tmpdir } from "node:os";
|
||||
import { join } from "node:path";
|
||||
import { createApp } from "../server.js";
|
||||
|
||||
async function withServer(run) {
|
||||
const dir = mkdtempSync(join(tmpdir(), "workbench-"));
|
||||
const dataFile = join(dir, "data.json");
|
||||
const app = createApp({ dataFile });
|
||||
const server = app.listen(0, "127.0.0.1");
|
||||
await new Promise((resolve) => server.once("listening", resolve));
|
||||
const base = `http://127.0.0.1:${server.address().port}`;
|
||||
try {
|
||||
await run({ base, dataFile });
|
||||
} finally {
|
||||
await new Promise((resolve) => server.close(resolve));
|
||||
rmSync(dir, { recursive: true, force: true });
|
||||
}
|
||||
}
|
||||
|
||||
test("creates, searches, updates and reports linked statistics with persistence", async () => {
|
||||
await withServer(async ({ base, dataFile }) => {
|
||||
const created = await fetch(`${base}/api/tasks`, {
|
||||
method: "POST",
|
||||
headers: { "content-type": "application/json" },
|
||||
body: JSON.stringify({ title: "测量超导比特", priority: "high" }),
|
||||
});
|
||||
assert.equal(created.status, 201);
|
||||
const { task } = await created.json();
|
||||
assert.equal(task.title, "测量超导比特");
|
||||
assert.equal(task.status, "open");
|
||||
|
||||
const second = await fetch(`${base}/api/tasks`, {
|
||||
method: "POST",
|
||||
headers: { "content-type": "application/json" },
|
||||
body: JSON.stringify({ title: "整理实验记录" }),
|
||||
});
|
||||
assert.equal(second.status, 201);
|
||||
|
||||
const list = await (await fetch(`${base}/api/tasks?q=超导`)).json();
|
||||
assert.equal(list.tasks.length, 1);
|
||||
assert.equal(list.tasks[0].id, task.id);
|
||||
|
||||
const invalid = await fetch(`${base}/api/tasks`, {
|
||||
method: "POST",
|
||||
headers: { "content-type": "application/json" },
|
||||
body: JSON.stringify({ title: " " }),
|
||||
});
|
||||
assert.equal(invalid.status, 400);
|
||||
assert.equal((await invalid.json()).error.code, "task.title_required");
|
||||
|
||||
const badPriority = await fetch(`${base}/api/tasks`, {
|
||||
method: "POST",
|
||||
headers: { "content-type": "application/json" },
|
||||
body: JSON.stringify({ title: "x", priority: "urgent" }),
|
||||
});
|
||||
assert.equal(badPriority.status, 400);
|
||||
|
||||
const update = await fetch(`${base}/api/tasks/${task.id}/status`, {
|
||||
method: "PATCH",
|
||||
headers: { "content-type": "application/json" },
|
||||
body: JSON.stringify({ status: "done" }),
|
||||
});
|
||||
assert.equal(update.status, 200);
|
||||
|
||||
const missing = await fetch(`${base}/api/tasks/999/status`, {
|
||||
method: "PATCH",
|
||||
headers: { "content-type": "application/json" },
|
||||
body: JSON.stringify({ status: "done" }),
|
||||
});
|
||||
assert.equal(missing.status, 404);
|
||||
assert.equal((await missing.json()).error.code, "task.not_found");
|
||||
|
||||
const stats = await (await fetch(`${base}/api/stats`)).json();
|
||||
assert.equal(stats.total, 2);
|
||||
assert.equal(stats.byStatus.done, 1);
|
||||
assert.equal(stats.byStatus.open, 1);
|
||||
assert.equal(stats.byPriority.high, 1);
|
||||
|
||||
// Persistence is a real file: a new app instance reads the same state.
|
||||
const reloaded = JSON.parse(readFileSync(dataFile, "utf8"));
|
||||
assert.equal(reloaded.tasks.length, 2);
|
||||
assert.equal(reloaded.nextId, 3);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user