feat: add interactive timeline legend
This commit is contained in:
@@ -4,15 +4,31 @@ import {
|
||||
canCenterTimelineBesideMapScale,
|
||||
clusterOperationalEvents,
|
||||
createOperationalEvents,
|
||||
DEFAULT_OPERATIONAL_EVENT_VISIBILITY,
|
||||
filterOperationalEvents,
|
||||
OPERATIONAL_TIMELINE_LAYOUT,
|
||||
resolveTimelineScaleLayout
|
||||
} from "./operational-timeline-model";
|
||||
|
||||
const workOrder: ScheduledConditionItem = {
|
||||
id: "work-1", kind: "work_order", code: "WO-1", scheduledAt: "2026-08-19T10:00:00.000Z",
|
||||
title: "阀门调整", summary: "调整阀门", status: "running", riskLevel: "attention", updatedAt: 1,
|
||||
durationMinutes: 40, source: "调度方案", location: "边界阀门 BV-07", dispatcher: "调度",
|
||||
assignee: "班组", priority: "urgent", replyWindowMinutes: 20, stages: [], replyRequirements: []
|
||||
id: "work-1",
|
||||
kind: "work_order",
|
||||
code: "WO-1",
|
||||
scheduledAt: "2026-08-19T10:00:00.000Z",
|
||||
title: "阀门调整",
|
||||
summary: "调整阀门",
|
||||
status: "running",
|
||||
riskLevel: "attention",
|
||||
updatedAt: 1,
|
||||
durationMinutes: 40,
|
||||
source: "调度方案",
|
||||
location: "边界阀门 BV-07",
|
||||
dispatcher: "调度",
|
||||
assignee: "班组",
|
||||
priority: "urgent",
|
||||
replyWindowMinutes: 20,
|
||||
stages: [],
|
||||
replyRequirements: []
|
||||
};
|
||||
|
||||
describe("operational timeline model", () => {
|
||||
@@ -26,13 +42,35 @@ describe("operational timeline model", () => {
|
||||
expect(events[0].correlationId).toBe(events[1].correlationId);
|
||||
});
|
||||
|
||||
it("filters event lanes from the interactive legend", () => {
|
||||
const events = createOperationalEvents([workOrder]);
|
||||
const filtered = filterOperationalEvents(events, {
|
||||
...DEFAULT_OPERATIONAL_EVENT_VISIBILITY,
|
||||
actual: false
|
||||
});
|
||||
|
||||
expect(filtered.map((event) => event.lane)).toEqual(["plan"]);
|
||||
});
|
||||
|
||||
it("only promotes abnormal condition runs into exception events", () => {
|
||||
const normal = {
|
||||
id: "condition-normal", kind: "condition", taskId: "scada-diagnosis", sessionId: "s-1",
|
||||
scheduledAt: "2026-08-19T10:00:00.000Z", title: "诊断", summary: "正常", status: "completed",
|
||||
riskLevel: "normal", updatedAt: 1
|
||||
id: "condition-normal",
|
||||
kind: "condition",
|
||||
taskId: "scada-diagnosis",
|
||||
sessionId: "s-1",
|
||||
scheduledAt: "2026-08-19T10:00:00.000Z",
|
||||
title: "诊断",
|
||||
summary: "正常",
|
||||
status: "completed",
|
||||
riskLevel: "normal",
|
||||
updatedAt: 1
|
||||
} satisfies ScheduledConditionItem;
|
||||
const abnormal = {
|
||||
...normal,
|
||||
id: "condition-error",
|
||||
status: "error",
|
||||
riskLevel: "critical"
|
||||
} satisfies ScheduledConditionItem;
|
||||
const abnormal = { ...normal, id: "condition-error", status: "error", riskLevel: "critical" } satisfies ScheduledConditionItem;
|
||||
|
||||
expect(createOperationalEvents([normal])).toHaveLength(0);
|
||||
expect(createOperationalEvents([abnormal])[0].lane).toBe("exception");
|
||||
|
||||
Reference in New Issue
Block a user