import { describe, expect, it } from "vitest";
import { classifyTaskViability, describeTaskViabilityReason, } from "../task-viability.js";
describe("classifyTaskViability", () => {
    it("is viable when a published version exists and is not archived", () => {
        const state = {
            hasPublishedVersion: true,
            hasDraftVersion: false,
            status: "active",
        };
        expect(classifyTaskViability(state)).toStrictEqual({ viable: true });
    });
    it("is viable for a published task with no status field", () => {
        expect(classifyTaskViability({
            hasPublishedVersion: true,
            hasDraftVersion: false,
        })).toStrictEqual({ viable: true });
    });
    it("is viable when a published version coexists with an unpublished draft", () => {
        expect(classifyTaskViability({
            hasPublishedVersion: true,
            hasDraftVersion: true,
            status: "active",
        })).toStrictEqual({ viable: true });
    });
    it("is archived when the published version is archived (runner excludes it)", () => {
        expect(classifyTaskViability({
            hasPublishedVersion: true,
            hasDraftVersion: false,
            status: "archived",
        })).toStrictEqual({ reason: "archived", viable: false });
    });
    it("is unpublished-draft when only a draft version exists", () => {
        expect(classifyTaskViability({
            hasPublishedVersion: false,
            hasDraftVersion: true,
            status: "draft",
        })).toStrictEqual({ reason: "unpublished-draft", viable: false });
    });
    it("is not-found when neither a published nor a draft version exists", () => {
        expect(classifyTaskViability({
            hasPublishedVersion: false,
            hasDraftVersion: false,
        })).toStrictEqual({ reason: "not-found", viable: false });
    });
});
describe("describeTaskViabilityReason", () => {
    it("gives an actionable, distinct message per reason", () => {
        const messages = [
            describeTaskViabilityReason("archived"),
            describeTaskViabilityReason("not-found"),
            describeTaskViabilityReason("unpublished-draft"),
        ];
        expect(new Set(messages).size).toBe(3);
        expect(describeTaskViabilityReason("unpublished-draft")).toContain("publish");
    });
});
