feat: expand intelligent investigation workspace
This commit is contained in:
@@ -4,7 +4,7 @@ import { mockAgentApi } from "./support/mock-agent-api";
|
||||
import { captureReadingGeometry } from "./support/reading-geometry";
|
||||
|
||||
for (const width of [1600, 375, 320]) {
|
||||
test(`formal rich reports preserve drafts, map and versioned references at ${width}px`, async ({ page }, testInfo) => {
|
||||
test(`formal rich reports preserve drafts, map and report versions at ${width}px`, async ({ page }, testInfo) => {
|
||||
await page.setViewportSize({ width, height: 960 });
|
||||
await page.emulateMedia({ reducedMotion: "reduce" });
|
||||
await mockAgentApi(page);
|
||||
@@ -32,6 +32,10 @@ for (const width of [1600, 375, 320]) {
|
||||
title: "供水压力演练核验", current_conclusion: "当前演练数据提示压力变化,仍待现场核验。",
|
||||
conclusion_boundary: "仅覆盖已加载的演练记录。", stage: "final", outcome: "concluded",
|
||||
data_gaps: [], recommendations: ["核对现场位置及对应时段。"], pending_items: [], evidence_refs: ["DEMO-001"],
|
||||
diagram: { title: "核查流程", mermaid: "flowchart LR\nA[核对监测]", node_refs: [
|
||||
{ node_id: "A", label: "核对监测", status: "completed", evidence_refs: ["DEMO-001"], action_refs: [],
|
||||
map_targets: [{ source_id: "scada", feature_id: "DEMO-P001" }] },
|
||||
] },
|
||||
ui_blocks: [
|
||||
{ block, evidence_refs: ["DEMO-001"] },
|
||||
{ block: { version: "answer-ui@future", block_id: "future", fallback_text: "扩展分析摘要:等待下一次现场核验。", spec: {} }, evidence_refs: ["DEMO-001"] },
|
||||
@@ -59,6 +63,7 @@ for (const width of [1600, 375, 320]) {
|
||||
display: width < 1024 && reading.active ? "none" : "block",
|
||||
} }, React.createElement(InvestigationTaskReport, { task,
|
||||
onContinue: (discussion) => { Object.assign(window, { quotedReport: discussion }); },
|
||||
onLocate: (targets) => { Object.assign(window, { diagramLocatedTargets: targets }); },
|
||||
renderAction: noAction, renderEvidence: () => React.createElement("p", null, "原始演练记录"),
|
||||
onLoadReports: async () => ({ items: [report, historical], next_offset: null }),
|
||||
})),
|
||||
@@ -83,7 +88,7 @@ for (const width of [1600, 375, 320]) {
|
||||
await expect(workspace.getByRole("region", { name: "主要依据", exact: true })).toBeFocused();
|
||||
await testInfo.attach("chapter-jump-geometry", {
|
||||
body: JSON.stringify(await workspace.evaluate((root) => {
|
||||
const scroll = root.querySelector("[data-reading-scroll]")!;
|
||||
const scroll = root.querySelector('[data-reading-scroll="true"]')!;
|
||||
return {
|
||||
scrollTop: scroll.scrollTop,
|
||||
maxScroll: scroll.scrollHeight - scroll.clientHeight,
|
||||
@@ -96,7 +101,7 @@ for (const width of [1600, 375, 320]) {
|
||||
});
|
||||
await expect(chapters.getByRole("button", { name: "依据", exact: true })).toHaveAttribute("aria-current", "location");
|
||||
const navigationTop = (await chapters.boundingBox())!.y;
|
||||
const scrollTop = (await workspace.locator("[data-reading-scroll]").boundingBox())!.y;
|
||||
const scrollTop = (await workspace.locator('[data-reading-scroll="true"]').boundingBox())!.y;
|
||||
expect(Math.abs(navigationTop - scrollTop)).toBeLessThan(2);
|
||||
await chapters.getByRole("button", { name: "分析", exact: true }).click();
|
||||
await expect(workspace.getByRole("region", { name: "交互分析", exact: true })).toBeFocused();
|
||||
@@ -140,7 +145,7 @@ for (const width of [1600, 375, 320]) {
|
||||
await page.getByRole("button", { name: "返回报告", exact: true }).click();
|
||||
}
|
||||
expect(await map.evaluate((element) => element === (window as unknown as { originalMap: Element }).originalMap)).toBe(true);
|
||||
await workspace.locator("[data-reading-scroll]").evaluate((element) => { element.scrollTop = 0; });
|
||||
await workspace.locator('[data-reading-scroll="true"]').evaluate((element) => { element.scrollTop = 0; });
|
||||
await expect(chapters.getByRole("button", { name: "结论", exact: true })).toHaveAttribute("aria-current", "location");
|
||||
await page.evaluate(() => document.fonts.ready);
|
||||
const geometry = await captureReadingGeometry(workspace, testInfo);
|
||||
@@ -155,12 +160,17 @@ for (const width of [1600, 375, 320]) {
|
||||
await page.getByRole("dialog", { name: "报告版本" }).getByRole("button", { name: /报告第 2 版/ }).click();
|
||||
await expect(workspace).toContainText("历史结论:初次演练核验。");
|
||||
await workspace.getByRole("tab", { name: "数据", exact: true }).click();
|
||||
await workspace.getByRole("checkbox", { name: "选择第 2 行" }).check();
|
||||
await workspace.locator("[data-interactive-table]").getByRole("button", { name: "针对这部分提问" }).click();
|
||||
const quote = await page.evaluate(() => (window as unknown as { quotedReport: { context: { report_revision: number }; reference: { title: string; text: string } } }).quotedReport);
|
||||
expect(quote.context.report_revision).toBe(2);
|
||||
expect(quote.reference.title).toContain("报告第 2 版");
|
||||
expect(quote.reference.text).toContain("0.28");
|
||||
await expect(workspace.locator("[data-interactive-table]").getByRole("table")).toContainText("0.28");
|
||||
await expect(workspace.locator("[data-interactive-table]").getByRole("checkbox")).toHaveCount(0);
|
||||
await expect(workspace.getByRole("button", { name: /加入分析|针对这部分提问/ })).toHaveCount(0);
|
||||
const diagram = workspace.getByRole("region", { name: "调查脉络", exact: true });
|
||||
await diagram.getByRole("button", { name: /^核对监测 · 已完成/ }).click();
|
||||
const nodeDetails = diagram.getByLabel("节点详情 核对监测");
|
||||
await expect(nodeDetails).toContainText("原始演练记录");
|
||||
await expect(nodeDetails.getByRole("button", { name: "围绕此节点提问" })).toHaveCount(0);
|
||||
await nodeDetails.getByRole("button", { name: "在地图查看", exact: true }).click();
|
||||
expect(await page.evaluate(() => (window as unknown as { diagramLocatedTargets: unknown }).diagramLocatedTargets))
|
||||
.toEqual([{ source_id: "scada", feature_id: "DEMO-P001" }]);
|
||||
expect(await page.evaluate(() => document.documentElement.scrollWidth)).toBeLessThanOrEqual(width);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user