feat: add webhook case management
This commit is contained in:
@@ -5,6 +5,8 @@ import {
|
||||
TRASH_REGION_ID,
|
||||
alarmMinutesToSeconds,
|
||||
buildCalibrationPayload,
|
||||
buildCaseDisplayModel,
|
||||
buildManualHandlePayload,
|
||||
buildPolygonMap,
|
||||
buildRuntimeDisplayModel,
|
||||
classifyEvent,
|
||||
@@ -628,3 +630,58 @@ test("buildRuntimeDisplayModel uses config threshold when event omits threshold"
|
||||
source: "real",
|
||||
}]);
|
||||
});
|
||||
|
||||
test("buildCaseDisplayModel normalizes case rows and summary metrics", () => {
|
||||
const model = buildCaseDisplayModel({
|
||||
summary: {
|
||||
open_case_count: 1,
|
||||
handled_case_count: 2,
|
||||
time_alarm_case_count: 1,
|
||||
pending_disposal_case_count: 1,
|
||||
warning_escalated_case_count: 1,
|
||||
},
|
||||
cases: [
|
||||
{
|
||||
case_id: "case_batch_000001",
|
||||
case_type: "warning_escalated",
|
||||
case_status: "open",
|
||||
zone_label: "区域 1",
|
||||
batch_id: "batch_000001",
|
||||
updated_at: "2026-06-09T09:10:00+08:00",
|
||||
handled_source: "",
|
||||
},
|
||||
{
|
||||
case_id: "case_batch_000002",
|
||||
case_type: "time_alarm",
|
||||
case_status: "handled",
|
||||
zone_label: "区域 2",
|
||||
batch_id: "batch_000002",
|
||||
updated_at: "2026-06-09T09:12:00+08:00",
|
||||
handled_source: "manual",
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
assert.deepEqual(model.metrics, {
|
||||
openCaseCount: 1,
|
||||
handledCaseCount: 2,
|
||||
timeAlarmCaseCount: 1,
|
||||
pendingDisposalCaseCount: 1,
|
||||
warningEscalatedCaseCount: 1,
|
||||
});
|
||||
assert.equal(model.rows[0].caseId, "case_batch_000002");
|
||||
assert.equal(model.rows[0].statusLabel, "已处理");
|
||||
assert.equal(model.rows[0].tone, "good");
|
||||
assert.equal(model.rows[1].typeLabel, "升级警告");
|
||||
assert.equal(model.rows[1].statusLabel, "待处理");
|
||||
});
|
||||
|
||||
test("buildManualHandlePayload trims handled_by and keeps optional note", () => {
|
||||
assert.deepEqual(buildManualHandlePayload(" alice ", " checked "), {
|
||||
handled_by: "alice",
|
||||
note: "checked",
|
||||
});
|
||||
assert.deepEqual(buildManualHandlePayload("bob", ""), {
|
||||
handled_by: "bob",
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user