muse-agent-example/web/tests/旅程/规划生成.spec.ts
zizi cf0f4fb985 W20–W24:保存知识方法、迁移框架、审校修订与案例行为的集成成果
接续 88dd570,保存 W20–W24 已实现的共享接口、业务入口、迁移、工作台、测试与文档。
W20/W22/W23 保持 in_progress,W21/W24 保持 verified;此提交不宣称方法或规则正式启用、多轮返修、真实角色评测完成。

W25 新增实验、标定、逐调用交付与角色执行及其迁移/测试/索引留在实施工作树,原有私人和旧实现保留项不纳入。

验证:离线 571、前端 33 通过;PG 469 项通过、2 项浏览器未启用,2 项误带入的 W25 用例已移出本提交;最终任务与交付边界 37 项通过。make 检查、最终类型、84 项资源及 diff 检查通过。未重跑浏览器或 Pi 宿主,不以合成调用认证外部模型效果。
独立整体审查四维通过;证据保存在 R2-20260909/提交W20-W24。
2026-09-13 16:24:42 +08:00

63 lines
2.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.

/** 真 HTTP/PG 与真实浏览器;模型交付由隔离环境的合成宿主预先产生。 */
import { readFileSync, writeFileSync } from "node:fs";
import { expect, test } from "@playwright/test";
test.use({ trace: "off" });
test("NC-browser-planning-shadow:创建真实任务与确认模型规划候选", async ({
page,
}, info) => {
if (!process.env.MUSE_WORKBENCH_URL || !process.env.MUSE_AUTHOR_PASSWORD_FILE)
throw new Error("需要隔离后端和作者口令文件,不连接默认服务。");
const errors: string[] = [];
page.on("pageerror", (e) => errors.push(String(e)));
await page.goto("/");
await page
.getByLabel("访问口令")
.fill(readFileSync(process.env.MUSE_AUTHOR_PASSWORD_FILE, "utf8").trim());
await page.getByRole("button", { name: "进入工作台" }).click();
await page.getByRole("link", { name: /任务记录/ }).waitFor();
page.on("console", (m) => {
if (m.type() === "error" && !/favicon/.test(m.text()))
errors.push(m.text());
});
await page.goto("/works/gen-work/plans?node=ch-3&schema=fine_outline");
await expect(page.getByText(/模型规划 · 待决定/)).toBeVisible();
await page.getByLabel("规划要求").fill("保留本章方向,再比较一个承接方案");
await page.getByLabel("规划模型配置").fill("plan-config");
const 要求框 = await page.getByLabel("规划要求").boundingBox();
const 配置框 = await page.getByLabel("规划模型配置").boundingBox();
if (!要求框 || !配置框) throw new Error("规划输入控件不可见");
expect(配置框.y).toBeGreaterThan(要求框.y + 要求框.height);
const created = page.waitForResponse(
(r) =>
r.url().endsWith("/planning-tasks") && r.request().method() === "POST",
);
await page.getByRole("button", { name: "创建规划任务" }).click();
const response = await created;
expect(response.status()).toBe(201);
const receipt = await response.json();
await expect(
page.getByText(new RegExp("任务已创建:" + receipt.task_id)),
).toBeVisible();
await page.screenshot({
path: `${info.outputDir}/规划任务与模型候选.png`,
fullPage: true,
});
await page.getByRole("button", { name: /模型规划 · 待决定/ }).click();
await page.getByRole("button", { name: "确认这份规划", exact: true }).click();
await expect(
page.getByText("这份规划已确认。", { exact: true }),
).toBeVisible();
await expect(page.getByText(/模型规划 · 已确认/)).toBeVisible();
await page.screenshot({
path: `${info.outputDir}/规划确认结果.png`,
fullPage: true,
});
writeFileSync(
`${info.outputDir}/规划回执.json`,
JSON.stringify({ created_task_id: receipt.task_id }),
);
expect(errors, "不得有页面异常或未预期的接口失败").toEqual([]);
});