muse-agent-example/web/tests/旅程/方法库.spec.ts
zizi ae02fd1732 前端:工作台页面、事件标签与旅程用例
- 上下文清单、任务列表与详情、恢复控制、运行观察、创作对话与消息流、正式变更决策面板、正文写作与候选审阅、资料研究等页面同步本轮后端能力。
- 事件标签表补齐后端事件类型;查询键与生成客户端随 HTTP 契约重新生成。
- 依赖调整后 lockfile 同步;交互用例与浏览器旅程 spec 一并更新。
- 证据:make 前端检查(lint + typecheck + Pi 工具桥 tsc)exit 0;make 前端测试 37 文件 / 120 用例通过。
2026-09-18 01:15:07 +08:00

49 lines
2.7 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/** 真实浏览器与隔离库:方法库、检索与版本绑定的维护旅程。 */
import { readFileSync } from "node:fs";
import { expect, test } from "@playwright/test";
test.use({ trace: "off" });
// @muse-case {"case_id":"NC-w20-browser","environment":"真实隔离库 + Chrome","given":"隔离浏览器环境与已启用绑定方法","when":"浏览方法库与版本绑定页并执行混合检索","then":["清单与类型过滤可见","检索命中并标注绑定","绑定固定版本可见"],"contract":"docs/系统架构/新版设计/模块设计/B04-知识方法.md"}
test("NC-w20-browser:方法库与绑定旅程", async ({ page }, info) => {
if (!process.env.MUSE_WORKBENCH_URL || !process.env.MUSE_AUTHOR_PASSWORD_FILE)
throw new Error("需要明确的隔离后端和作者口令文件。");
const workId = process.env.MUSE_WORK_ID!;
if (!workId) throw new Error("需要预置作品编号。");
const consoleErrors: string[] = [];
page.on("pageerror", (error) => consoleErrors.push(String(error)));
await page.goto("/");
await page
.getByLabel("访问口令")
.fill(readFileSync(process.env.MUSE_AUTHOR_PASSWORD_FILE, "utf8").trim());
await page.getByRole("button", { name: "进入工作台" }).click();
// 方法库页:类型过滤、方法清单、索引状态与混合检索。
await page.goto(`/methods?work=${workId}`);
const 清单 = page.locator('section[aria-label="方法清单"]');
await expect(清单.getByText(/1 张卡/)).toBeVisible({ timeout: 15_000 });
await expect(清单.getByRole("button", { name: /叙事技法/ })).toBeVisible();
await expect(清单.getByText(/契诃夫之枪/)).toBeVisible();
const 索引 = page.locator('section[aria-label="索引状态"]');
await expect(索引.getByText("新鲜")).toBeVisible();
const 检索 = page.locator('section[aria-label="混合检索"]');
await 检索.locator("input").fill("埋设 引爆");
await expect(检索.getByText(/契诃夫之枪/)).toBeVisible();
await expect(检索.getByText(/已绑定本书/)).toBeVisible();
await page.screenshot({ path: `${info.outputDir}/方法库页.png`, fullPage: true });
// 版本绑定页:绑定清单呈现固定版本。
await page.goto(`/works/${workId}/methods`);
const 绑定 = page.locator('section[aria-label="绑定清单"]');
await expect(绑定.getByText(/1 条生效/)).toBeVisible({ timeout: 15_000 });
await expect(绑定.getByText(/契诃夫之枪/)).toBeVisible();
await expect(绑定.getByText(/v1/)).toBeVisible();
await page.screenshot({ path: `${info.outputDir}/版本绑定页.png`, fullPage: true });
expect(
consoleErrors.filter((文本) => !文本.includes("favicon")),
"页面不得出现控制台错误",
).toEqual([]);
});