refactor(workbench): remove redundant notification state
This commit is contained in:
@@ -1,31 +1,22 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { getOperationalNotificationRoute } from "./operational-notification-routing";
|
||||
import { getOperationalNotificationSeverity } from "./operational-notification-routing";
|
||||
|
||||
describe("getOperationalNotificationRoute", () => {
|
||||
describe("getOperationalNotificationSeverity", () => {
|
||||
it.each(["task_created", "report_updated", "task_completed"] as const)(
|
||||
"keeps normal lifecycle notification %s out of exception handling",
|
||||
(kind) => expect(getOperationalNotificationRoute(kind)).toBeNull()
|
||||
(kind) => expect(getOperationalNotificationSeverity(kind)).toBeNull()
|
||||
);
|
||||
|
||||
it("routes failures, approvals, human input, and external coordination", () => {
|
||||
expect(getOperationalNotificationRoute("task_failed")).toEqual({
|
||||
category: "task_exception",
|
||||
severity: "critical"
|
||||
});
|
||||
expect(getOperationalNotificationRoute("access_approval_pending")?.category)
|
||||
.toBe("human_approval");
|
||||
expect(getOperationalNotificationRoute("action_approval_pending")?.category)
|
||||
.toBe("human_approval");
|
||||
expect(getOperationalNotificationRoute("human_input_required")?.category)
|
||||
.toBe("human_input");
|
||||
expect(getOperationalNotificationRoute("external_coordination_failed")).toEqual({
|
||||
category: "external_coordination",
|
||||
severity: "critical"
|
||||
});
|
||||
it("maps actionable notifications to their displayed severity", () => {
|
||||
expect(getOperationalNotificationSeverity("task_failed")).toBe("critical");
|
||||
expect(getOperationalNotificationSeverity("run_delivery_degraded")).toBe("critical");
|
||||
expect(getOperationalNotificationSeverity("access_approval_pending")).toBe("warning");
|
||||
expect(getOperationalNotificationSeverity("action_approval_pending")).toBe("warning");
|
||||
expect(getOperationalNotificationSeverity("human_input_required")).toBe("warning");
|
||||
expect(getOperationalNotificationSeverity("external_coordination_failed")).toBe("critical");
|
||||
});
|
||||
|
||||
it("keeps legacy action notifications visible during the database rollout", () => {
|
||||
expect(getOperationalNotificationRoute("action_pending")?.category)
|
||||
.toBe("human_approval");
|
||||
expect(getOperationalNotificationSeverity("action_pending")).toBe("warning");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,33 +1,19 @@
|
||||
import type { OperationalTaskNotification } from "../api/operational-task-client";
|
||||
|
||||
export type OperationalNotificationCategory =
|
||||
| "task_exception"
|
||||
| "human_approval"
|
||||
| "human_input"
|
||||
| "external_coordination";
|
||||
|
||||
export type OperationalNotificationRoute = {
|
||||
category: OperationalNotificationCategory;
|
||||
severity: "warning" | "critical";
|
||||
};
|
||||
|
||||
const NOTIFICATION_ROUTES: Partial<
|
||||
Record<OperationalTaskNotification["kind"], OperationalNotificationRoute>
|
||||
const NOTIFICATION_SEVERITIES: Partial<
|
||||
Record<OperationalTaskNotification["kind"], "warning" | "critical">
|
||||
> = {
|
||||
task_failed: { category: "task_exception", severity: "critical" },
|
||||
run_delivery_degraded: { category: "task_exception", severity: "critical" },
|
||||
action_pending: { category: "human_approval", severity: "warning" },
|
||||
access_approval_pending: { category: "human_approval", severity: "warning" },
|
||||
action_approval_pending: { category: "human_approval", severity: "warning" },
|
||||
human_input_required: { category: "human_input", severity: "warning" },
|
||||
external_coordination_failed: {
|
||||
category: "external_coordination",
|
||||
severity: "critical"
|
||||
}
|
||||
task_failed: "critical",
|
||||
run_delivery_degraded: "critical",
|
||||
action_pending: "warning",
|
||||
access_approval_pending: "warning",
|
||||
action_approval_pending: "warning",
|
||||
human_input_required: "warning",
|
||||
external_coordination_failed: "critical"
|
||||
};
|
||||
|
||||
export function getOperationalNotificationRoute(
|
||||
export function getOperationalNotificationSeverity(
|
||||
kind: OperationalTaskNotification["kind"]
|
||||
): OperationalNotificationRoute | null {
|
||||
return NOTIFICATION_ROUTES[kind] ?? null;
|
||||
): "warning" | "critical" | null {
|
||||
return NOTIFICATION_SEVERITIES[kind] ?? null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user