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

58 lines
2.5 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, writeFileSync } from "node:fs";
import { expect, test } from "@playwright/test";
// @muse-case {"case_id":"NC-browser-method-enable","environment":"真实浏览器与隔离PG/S01","given":"确切方法确认版本和明确作者身份","when":"核对启用凭据并执行当前目标的作者状态操作","then":["核对已测版本并明确启用写手用途"],"contract":"docs/系统架构/新版设计/模块设计/B10-效果评测.md"}
test("NC-browser-method-enable:核对已测版本并明确启用写手用途", async ({
page,
}, info) => {
const password = process.env.MUSE_AUTHOR_PASSWORD_FILE;
const method = process.env.MUSE_METHOD_ID;
const proof = process.env.MUSE_ENABLEMENT_RECEIPT;
if (!password || !method || !proof)
throw new Error("需要隔离方法、实际证明与作者口令位置");
const errors: string[] = [];
page.on("pageerror", (e) => errors.push(e.message));
await page.goto("/");
await page.getByLabel("访问口令").fill(readFileSync(password, "utf8").trim());
await page.getByRole("button", { name: "进入工作台" }).click();
await page.goto(`/methods/${method}`);
await expect(
page.getByRole("heading", { name: "启用桥接方法", exact: true }),
).toBeVisible();
const enable = page.getByRole("button", { name: "确认启用写手用途" });
await expect(enable).toBeDisabled();
await page.getByLabel("启用凭据编号").fill(proof);
await page.getByRole("button", { name: "核对已测版本" }).click();
await expect(page.getByText(/已核对 v1 · 写手用途/)).toBeVisible();
await expect(enable).toBeEnabled();
await page.screenshot({
path: info.outputPath("方法启用核对.png"),
fullPage: true,
});
const submitted = page.waitForResponse((r) =>
r.url().endsWith(`/methods/${method}/state`),
);
await enable.click();
const response = await submitted;
expect(response.status()).toBe(200);
const receipt = await response.json();
expect(receipt.results[0].state).toBe("enabled");
expect(receipt.results[0].enablement_receipt).toBe(proof);
writeFileSync(
info.outputPath("启用回执.json"),
JSON.stringify(receipt, null, 2),
);
await page.reload();
await expect(
page.getByRole("button", { name: "停用", exact: true }),
).toBeEnabled();
await expect(
page.getByRole("button", { name: "确认启用写手用途" }),
).toHaveCount(0);
await page.screenshot({
path: info.outputPath("方法启用读回.png"),
fullPage: true,
});
expect(errors).toEqual([]);
});