shoc-frontend-new/src/test/domain/work-orders/utils/severity-escalation.test.ts
Arthur Bassi 27ddeb2903 feat(work-orders): align inline type correction with the board AAP
Keep type correction on the board: Type & severity, SEV toast, and audit copy.
2026-09-03 16:30:10 -03:00

32 lines
1.1 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("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.",
);
});
});