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

87 lines
3.8 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";
// @muse-case {"case_id":"NC-browser-system-release","environment":"浏览器","given":"明确隔离配置、发布包和受控测试资料","when":"经实际入口执行对应操作并读回","then":["NC-browser-system-release:安装包系统状态草案保存与重读"],"contract":"docs/系统架构/新版设计/文件设计/工程配置与部署.md"}
test("NC-browser-system-release:安装包系统状态草案保存与重读", async ({
page,
}, info) => {
const password = process.env.MUSE_AUTHOR_PASSWORD_FILE;
if (!password) throw new Error("需要隔离作者口令文件");
const errors: string[] = [];
page.on("pageerror", (error) => errors.push(error.message));
await page.goto("/");
await page.getByLabel("访问口令").fill(readFileSync(password, "utf8").trim());
await page.getByRole("button", { name: "进入工作台" }).click();
await page.getByRole("link", { name: "系统管理" }).click();
await expect(
page.getByRole("heading", { name: "连接与模型", exact: true }),
).toBeVisible();
await expect(page.getByText("已就绪", { exact: true })).toBeVisible();
await expect(
page
.getByRole("region", { name: "角色模型策略" })
.getByRole("heading", { level: 3 }),
).toHaveCount(5);
for (const [label, value] of Object.entries({
配置编号: "installed-browser",
配置版本: "1",
宿主版本: "1",
提供方身份: "synthetic-provider",
模型身份: "synthetic-not-called",
思考策略: "high",
提供方地址: "https://example.invalid/api",
凭据引用名称: "synthetic-secret-ref",
预算策略引用: "synthetic-budget",
计价版本: "synthetic-pricing",
角色策略版本引用: "role-policy-v1",
资源发布版本引用: "muse-foundation-r2",
}))
await page.getByLabel(label, { exact: true }).fill(value);
await page.getByRole("combobox", { name: "执行宿主", exact: true }).selectOption("direct");
await page.getByRole("combobox", { name: "角色", exact: true }).selectOption("writer");
await page
.getByRole("combobox", { name: "提供方协议", exact: true })
.selectOption("responses");
await page
.getByRole("combobox", { name: "凭据引用来源", exact: true })
.selectOption("受控存储");
await page
.getByLabel("受控存储绝对路径", { exact: true })
.fill("/nonexistent/synthetic-reference");
await page.getByRole("button", { name: "保存新版本草案" }).click();
await expect(
page.getByText("已保存 installed-browser · 1 草案;当前仍未启用。"),
).toBeVisible();
await page.reload();
const summary = page.getByRole("region", { name: "已登记运行配置" });
await expect(
summary.getByRole("heading", { name: "installed-browser · 1" }),
).toBeVisible();
await expect(
summary.getByText("direct 1 · 未启用", { exact: true }),
).toBeVisible();
await expect(summary).not.toContainText("example.invalid");
await page.screenshot({
path: info.outputPath("连接与模型.png"),
fullPage: true,
});
await page.getByRole("link", { name: "数据管理", exact: true }).click();
await expect(
page.getByRole("heading", { name: "数据管理", exact: true }),
).toBeVisible();
await expect(
page.getByRole("heading", { name: "work-candidate", exact: true }),
).toBeVisible();
await expect(page.getByText("已完成", { exact: true })).toBeVisible();
await page.screenshot({
path: info.outputPath("数据盘点.png"),
fullPage: true,
});
await page.getByRole("link", { name: "备份与恢复", exact: true }).click();
await expect(page.getByText("未盘点", { exact: true })).toBeVisible();
await expect(
page.getByRole("button", { name: "恢复", exact: true }),
).toHaveCount(0);
expect(errors).toEqual([]);
});