feat(workbench): integrate runtime data and map tooling
This commit is contained in:
@@ -0,0 +1,83 @@
|
||||
import { cleanup, fireEvent, render, screen } from "@testing-library/react";
|
||||
import { afterEach, describe, expect, it, vi } from "vitest";
|
||||
import type { ScheduledConditionRecord } from "../types";
|
||||
import { ConditionDetailPanel } from "./scheduled-condition-detail-panel";
|
||||
|
||||
const baseCondition: ScheduledConditionRecord = {
|
||||
id: "schedule-run-1",
|
||||
kind: "condition",
|
||||
taskId: "backend-schedule",
|
||||
dataSource: "scheduled_tasks",
|
||||
sessionId: "scheduled-condition-schedule-run-1",
|
||||
title: "演示 低压调查",
|
||||
summary: "后端调查运行",
|
||||
status: "error",
|
||||
riskLevel: "critical",
|
||||
scheduledAt: "2026-09-17T02:10:00Z",
|
||||
updatedAt: Date.parse("2026-09-17T02:20:00Z"),
|
||||
detail: "调查执行状态:异常。",
|
||||
recommendation: "请检查调查任务的输入参数与服务端执行日志。",
|
||||
evidence: ["运行 ID:schedule-run-1", "运行状态:failed"],
|
||||
modelName: "TJWater scheduler"
|
||||
};
|
||||
|
||||
describe("scheduled condition backend boundaries", () => {
|
||||
afterEach(cleanup);
|
||||
|
||||
it("shows only persisted evidence for a failed backend condition", () => {
|
||||
render(
|
||||
<ConditionDetailPanel
|
||||
condition={baseCondition}
|
||||
dataSource="scheduled_tasks"
|
||||
workOrderDataSource="backend"
|
||||
onContinueConversation={vi.fn()}
|
||||
/>
|
||||
);
|
||||
|
||||
expect(screen.getByText("后端持久化工况")).toBeVisible();
|
||||
expect(screen.getByText("运行 ID:schedule-run-1")).toBeVisible();
|
||||
expect(screen.getByText("正式工单边界")).toBeVisible();
|
||||
expect(screen.getByText(/只有后端同步的工单才会显示/)).toBeVisible();
|
||||
expect(screen.queryByText("演示异常判断")).not.toBeInTheDocument();
|
||||
expect(screen.queryByRole("button", { name: "生成演示工单草稿" })).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("does not synthesize workflow progress for a running backend condition", () => {
|
||||
render(
|
||||
<ConditionDetailPanel
|
||||
condition={{ ...baseCondition, status: "running", riskLevel: "normal" }}
|
||||
dataSource="scheduled_tasks"
|
||||
onContinueConversation={vi.fn()}
|
||||
/>
|
||||
);
|
||||
|
||||
expect(screen.getByText("后端运行状态")).toBeVisible();
|
||||
expect(screen.getByText(/不按经过时间推算百分比/)).toBeVisible();
|
||||
expect(screen.queryByText(/演示执行流程/)).not.toBeInTheDocument();
|
||||
expect(screen.queryByText("演示进度")).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("keeps the mock work-order interaction but labels it as a local demo draft", () => {
|
||||
render(
|
||||
<ConditionDetailPanel
|
||||
condition={{
|
||||
...baseCondition,
|
||||
id: "mock-scada-error",
|
||||
taskId: "scada-diagnosis",
|
||||
dataSource: "mock",
|
||||
title: "SCADA 数据诊断",
|
||||
modelName: "供水时序诊断"
|
||||
}}
|
||||
dataSource="mock"
|
||||
onContinueConversation={vi.fn()}
|
||||
/>
|
||||
);
|
||||
|
||||
expect(screen.getByText("演示异常判断")).toBeVisible();
|
||||
expect(screen.getByText("演示处置方案")).toBeVisible();
|
||||
fireEvent.click(screen.getByRole("button", { name: "生成演示工单草稿" }));
|
||||
expect(screen.getByRole("button", { name: "演示草稿已生成" })).toBeDisabled();
|
||||
expect(screen.getByText(/只保存在当前页面/)).toBeVisible();
|
||||
expect(screen.queryByText("系统工单已提交")).not.toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user