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

57 lines
3.0 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-w19-browser","environment":"真实隔离库 + Chrome","given":"隔离浏览器环境与预置作品/实体","when":"浏览世界资料/人物关系/时间伏笔三页并展开轨迹与影响","then":["实体与轨迹可见","弧线分区呈现","影响计数可见"],"contract":"docs/系统架构/新版设计/模块设计/B02-故事世界.md"}
test("NC-w19-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(`/works/${workId}/world`);
const 清单 = page.locator('section[aria-label="实体清单"]');
await expect(清单.getByText(/2 个对象/)).toBeVisible({ timeout: 15_000 });
await 清单.getByRole("button", { name: /char-lin/ }).first().click();
await expect(page.locator('section[aria-label="版本轨迹"]').getByText(/r1/)).toBeVisible();
await expect(
page.locator('section[aria-label="修订影响"]').getByText(/受影响事实:\d+ 个/),
).toBeVisible();
await page.screenshot({ path: `${info.outputDir}/世界资料页.png`, fullPage: true });
// 人物关系页:人物分组可见;弧线按已发生/计划分区。
await page.goto(`/works/${workId}/world/relations`);
await expect(page.locator('section[aria-label="人物分组"]').getByText(/character/)).toBeVisible();
await page
.locator('section[aria-label="人物分组"]')
.getByRole("button", { name: /char-lin/ })
.first()
.click();
await expect(
page.locator('section[aria-label="人物弧线"]').getByText(/已发生(\d+)/),
).toBeVisible();
await page.screenshot({ path: `${info.outputDir}/人物关系页.png`, fullPage: true });
// 时间与伏笔页:时点查询表单与说明可见。
await page.goto(`/works/${workId}/world/timeline`);
await expect(page.getByRole("button", { name: "查询时点世界" })).toBeVisible();
await expect(page.locator('section[aria-label="伏笔与承诺"]')).toBeVisible();
await page.screenshot({ path: `${info.outputDir}/时间与伏笔页.png`, fullPage: true });
expect(
consoleErrors.filter((文本) => !文本.includes("favicon")),
"页面不得出现控制台错误",
).toEqual([]);
});