// Task 443 — tests for the per-account-root delete reservation gate.
import { describe, it, expect } from "vitest";
import { checkLabelDeleteGate, RESERVED_LABEL_DELETE_REFUSAL } from "../label-delete-gate.js";
describe("checkLabelDeleteGate", () => {
    it("(a) system origin deleting LocalBusiness → ok", () => {
        const r = checkLabelDeleteGate({
            labels: ["LocalBusiness"],
            origin: "system",
            accountId: "acct-12345678",
            elementId: "4:eid:1",
            tool: "memory-delete",
        });
        expect(r.ok).toBe(true);
    });
    it("(b) non-system origin deleting LocalBusiness → rejected with literal message", () => {
        const r = checkLabelDeleteGate({
            labels: ["LocalBusiness"],
            accountId: "acct-12345678",
            elementId: "4:eid:1",
            tool: "memory-delete",
        });
        expect(r.ok).toBe(false);
        if (r.ok)
            return;
        expect(r.reason).toBe("reserved-label");
        expect(r.message).toBe(RESERVED_LABEL_DELETE_REFUSAL);
        expect(r.message).toContain("Delete blocked (reserved-label)");
        expect(r.message).toContain("LocalBusiness is the per-account root");
        expect(r.message).toContain("held immutable");
        expect(r.message).toContain("schema-base.md");
    });
    it("(c) non-system origin deleting non-reserved label → ok", () => {
        const r = checkLabelDeleteGate({
            labels: ["Organization"],
            accountId: "acct-12345678",
            elementId: "4:eid:1",
            tool: "memory-delete",
        });
        expect(r.ok).toBe(true);
    });
    it("(d) non-system memory-empty-trash candidate carrying LocalBusiness → rejected", () => {
        const r = checkLabelDeleteGate({
            labels: ["LocalBusiness"],
            accountId: "acct-12345678",
            elementId: "4:eid:1",
            tool: "memory-empty-trash",
        });
        expect(r.ok).toBe(false);
        if (r.ok)
            return;
        expect(r.reason).toBe("reserved-label");
    });
    it("empty origin string is not system → rejected", () => {
        const r = checkLabelDeleteGate({
            labels: ["LocalBusiness"],
            origin: "",
            tool: "memory-delete",
        });
        expect(r.ok).toBe(false);
    });
});
//# sourceMappingURL=label-delete-gate.test.js.map