import { describe, expect, test } from "bun:test"; import { archiveReasonForFalseAlarm, defaultActionFor, isCurrentTriage, parseReopenTriage } from "@bbbug/shared/reopen_triage"; import { isOutOfScopeReason } from "@bbbug/shared/archive_reasons"; describe("reopen triage", () => { test("parse: verdict, reason from the matching list, note required for other, action only for false alarms", () => { expect(parseReopenTriage({ taskId: "t", verdict: "fix_wrong", reason: "incomplete", action: "resolved" })) .toEqual({ taskId: "t", verdict: "fix_wrong", reason: "incomplete", note: null, action: null }); expect(parseReopenTriage({ taskId: "t", verdict: "false_alarm", reason: "wrong_build", action: "resolved", note: " 47.1.0 " })) .toEqual({ taskId: "t", verdict: "false_alarm", reason: "wrong_build", note: "47.1.0", action: "resolved" }); expect(parseReopenTriage({ taskId: "t", verdict: "fix_wrong", reason: "wrong_build" })).toHaveProperty("error"); expect(parseReopenTriage({ taskId: "t", verdict: "false_alarm", reason: "env" })).toHaveProperty("error"); expect(parseReopenTriage({ taskId: "t", verdict: "fix_wrong", reason: "other" })).toHaveProperty("error"); expect(parseReopenTriage({ taskId: "t", verdict: "fix_wrong", reason: "other", note: "x" })).not.toHaveProperty("error"); expect(parseReopenTriage({ verdict: "fix_wrong", reason: "incomplete" })).toHaveProperty("error"); expect(parseReopenTriage({ taskId: "t", verdict: "maybe", reason: "incomplete" })).toHaveProperty("error"); }); test("false alarms that aren't the client's problem default to archive, as out-of-scope categories", () => { expect(defaultActionFor("server_side")).toBe("archived"); expect(defaultActionFor("as_designed")).toBe("archived"); expect(defaultActionFor("wrong_build")).toBe("resolved"); expect(isOutOfScopeReason(archiveReasonForFalseAlarm("server_side"))).toBe(true); expect(isOutOfScopeReason(archiveReasonForFalseAlarm("as_designed"))).toBe(true); }); test("only a wrong-fix verdict from after the latest approval describes the current reopen", () => { expect(isCurrentTriage({ verdict: "fix_wrong", at: 200 }, 100)).toBe(true); expect(isCurrentTriage({ verdict: "fix_wrong", at: 50 }, 100)).toBe(false); expect(isCurrentTriage({ verdict: "fix_wrong", at: 50 }, null)).toBe(true); // 误报当时就流转走了;又出现在打回里 = QA 又打回了一次 expect(isCurrentTriage({ verdict: "false_alarm", at: 200 }, 100)).toBe(false); }); });