mirror of
https://github.com/Sea-Haven-Industries/shoc-frontend-new.git
synced 2026-10-02 13:13:12 +00:00
47 lines
1.6 KiB
TypeScript
47 lines
1.6 KiB
TypeScript
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.",
|
||
);
|
||
});
|
||
});
|