shoc-frontend-new/src/test/domain/work-orders/utils/severity-escalation.test.ts

47 lines
1.6 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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);
});
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);
});
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.",
);
});
});