2026-09-03 16:10:59 -03:00
|
|
|
|
import { describe, expect, it } from "vitest";
|
|
|
|
|
|
import {
|
|
|
|
|
|
formatSeverityEscalationToast,
|
|
|
|
|
|
shouldAnnounceSeverityEscalation,
|
|
|
|
|
|
} from "@/domain/work-orders/utils/severity-escalation";
|
|
|
|
|
|
|
|
|
|
|
|
describe("shouldAnnounceSeverityEscalation", () => {
|
|
|
|
|
|
it("announces when severity newly enters SEV 1", () => {
|
|
|
|
|
|
expect(shouldAnnounceSeverityEscalation(3, 1)).toBe(true);
|
|
|
|
|
|
expect(shouldAnnounceSeverityEscalation(null, 1)).toBe(true);
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
it("does not announce a re-save of the same critical severity", () => {
|
|
|
|
|
|
expect(shouldAnnounceSeverityEscalation(1, 1)).toBe(false);
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
it("does not announce a de-escalation out of SEV 1/2", () => {
|
|
|
|
|
|
expect(shouldAnnounceSeverityEscalation(2, 3)).toBe(false);
|
|
|
|
|
|
});
|
|
|
|
|
|
|
2026-09-16 11:01:06 -03:00
|
|
|
|
it("announces when severity rises from SEV 3–5 into SEV 2", () => {
|
|
|
|
|
|
expect(shouldAnnounceSeverityEscalation(5, 2)).toBe(true);
|
|
|
|
|
|
expect(shouldAnnounceSeverityEscalation(4, 2)).toBe(true);
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
it("does not announce moves between SEV 3–5", () => {
|
|
|
|
|
|
expect(shouldAnnounceSeverityEscalation(5, 3)).toBe(false);
|
|
|
|
|
|
expect(shouldAnnounceSeverityEscalation(4, 3)).toBe(false);
|
|
|
|
|
|
expect(shouldAnnounceSeverityEscalation(3, 5)).toBe(false);
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
it("does not announce SEV 1 to SEV 2 (already critical)", () => {
|
|
|
|
|
|
expect(shouldAnnounceSeverityEscalation(1, 2)).toBe(false);
|
|
|
|
|
|
});
|
|
|
|
|
|
|
2026-09-03 16:10:59 -03:00
|
|
|
|
it("does not announce SEV 2 to SEV 1 (already critical)", () => {
|
|
|
|
|
|
expect(shouldAnnounceSeverityEscalation(2, 1)).toBe(false);
|
|
|
|
|
|
});
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
describe("formatSeverityEscalationToast", () => {
|
|
|
|
|
|
it("matches the AAP warning copy", () => {
|
|
|
|
|
|
expect(formatSeverityEscalationToast("00000024965", 1)).toBe(
|
|
|
|
|
|
"WO #00000024965 escalated to SEV 1.",
|
|
|
|
|
|
);
|
|
|
|
|
|
});
|
|
|
|
|
|
});
|