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

122 lines
5.4 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 { afterEach, expect, it, vi } from "vitest";
import { cleanup, fireEvent, render, screen } from "@testing-library/react";
import { Ui独立比较 } from "../../src/功能/审校修订/独立比较";
afterEach(() => {
cleanup();
vi.unstubAllGlobals();
});
const record = {
receipt_id: "receipt-a",
proof: {
version: "revision-comparison-proof-v1",
source: {
session_id: "session-a",
round: 1,
candidate: { candidate_id: "candidate-a" },
},
outcome: "incomplete",
comparison_complete: false,
validation_modes: ["offline_contract"],
calibration_status: "uncalibrated",
decisions: [],
},
current: {
stopped: false,
selection: "original",
automatic_adoption: false,
reasons: ["unknown_cost"],
},
};
function answer(value: unknown) {
return new Response(JSON.stringify(value), {
headers: { "Content-Type": "application/json" },
});
}
// @muse-case {"case_id":"NC-revision-proof-incomplete","environment":"离线","given":"具名作者、固定来源、隔离测试配置与真实模块存储","when":"通过实际公开入口执行并核对拒绝、状态及持久结果","then":["NC-revision-proof-incomplete:缺判断和未标定保持可见,读取不派发或采纳"],"contract":"docs/系统架构/新版设计/模块设计/B06-审校修订.md"}
it("NC-revision-proof-incomplete:缺判断和未标定保持可见,读取不派发或采纳", async () => {
const calls: Request[] = [];
vi.stubGlobal(
"fetch",
vi.fn(async (req: Request) => {
calls.push(req);
return answer(record);
}),
);
render(
<Ui独立比较 sessionId="session-a" round={1} candidateId="candidate-a" />,
);
expect(calls).toHaveLength(0);
fireEvent.change(screen.getByLabelText("比较回执编号"), {
target: { value: "receipt-a" },
});
fireEvent.click(screen.getByRole("button", { name: "核对比较记录" }));
await screen.findByText(/当前建议保留原文/);
expect(screen.getByText(/缺少完整独立判断/)).toBeTruthy();
expect(screen.getByText(/尚未经文学标定/)).toBeTruthy();
expect(screen.getByText(/只覆盖工程合同验证/)).toBeTruthy();
expect(calls).toHaveLength(1);
expect(calls[0].method).toBe("GET");
});
// @muse-case {"case_id":"NC-revision-proof-scope","environment":"离线","given":"具名作者、固定来源、隔离测试配置与真实模块存储","when":"通过实际公开入口执行并核对拒绝、状态及持久结果","then":["NC-revision-proof-scope:其他会话的证明不能显示为当前候选的建议"],"contract":"docs/系统架构/新版设计/模块设计/B06-审校修订.md"}
it("NC-revision-proof-scope:其他会话的证明不能显示为当前候选的建议", async () => {
vi.stubGlobal(
"fetch",
vi.fn(async () =>
answer({
...record,
proof: {
...record.proof,
source: { ...record.proof.source, session_id: "other-session" },
},
}),
),
);
render(
<Ui独立比较 sessionId="session-a" round={1} candidateId="candidate-a" />,
);
fireEvent.change(screen.getByLabelText("比较回执编号"), {
target: { value: "receipt-a" },
});
fireEvent.click(screen.getByRole("button", { name: "核对比较记录" }));
await screen.findByText(/返回记录与本次返修不一致/);
expect(screen.queryByText(/当前建议/)).toBeNull();
});
// @muse-case {"case_id":"NC-revision-proof-selection","environment":"离线","given":"具名作者、固定来源、隔离测试配置与真实模块存储","when":"通过实际公开入口执行并核对拒绝、状态及持久结果","then":["NC-revision-proof-selection:作者选段的二版比较记录仍绑定本轮确切候选"],"contract":"docs/系统架构/新版设计/模块设计/B06-审校修订.md"}
it("NC-revision-proof-selection:作者选段的二版比较记录仍绑定本轮确切候选", async () => {
vi.stubGlobal(
"fetch",
vi.fn(async () =>
answer({
...record,
proof: { ...record.proof, version: "revision-comparison-proof-v2" },
}),
),
);
render(
<Ui独立比较 sessionId="session-a" round={1} candidateId="candidate-a" />,
);
fireEvent.change(screen.getByLabelText("比较回执编号"), {
target: { value: "receipt-a" },
});
fireEvent.click(screen.getByRole("button", { name: "核对比较记录" }));
await screen.findByText(/当前建议保留原文/);
});
// @muse-case {"case_id":"NC-revision-proof-candidate","environment":"离线","given":"具名作者、固定来源、隔离测试配置与真实模块存储","when":"通过实际公开入口执行并核对拒绝、状态及持久结果","then":["NC-revision-proof-candidate:同会话上一轮候选的证明不能冒充本轮结果"],"contract":"docs/系统架构/新版设计/模块设计/B06-审校修订.md"}
it("NC-revision-proof-candidate:同会话上一轮候选的证明不能冒充本轮结果", async () => {
vi.stubGlobal(
"fetch",
vi.fn(async () => answer(record)),
);
render(
<Ui独立比较 sessionId="session-a" round={2} candidateId="candidate-b" />,
);
fireEvent.change(screen.getByLabelText("比较回执编号"), {
target: { value: "receipt-a" },
});
fireEvent.click(screen.getByRole("button", { name: "核对比较记录" }));
await screen.findByText(/返回记录与本次返修不一致/);
expect(screen.queryByText(/当前建议/)).toBeNull();
});