import { describe, expect, it } from "vitest";
import { phaseFVerdict, type ProbeVerdictInput } from "../spikes/android-browser/verdict.js";

const pass = (): ProbeVerdictInput => ({ ok: true, offers: [{}] });
const fail = (): ProbeVerdictInput => ({ ok: false, offers: [] });

describe("phaseFVerdict", () => {
  it("passes an Autodoc-only cold and warm run", () => {
    expect(phaseFVerdict([], [pass(), pass()])).toMatchObject({ state: "passed" });
  });

  it("passes an open-store-only run", () => {
    expect(phaseFVerdict(Array.from({ length: 5 }, pass), [])).toMatchObject({ state: "passed" });
  });

  it("fails when the warm Autodoc probe fails", () => {
    expect(phaseFVerdict([], [pass(), fail()])).toMatchObject({ state: "failed" });
  });

  it("surfaces an interactive solve without requiring open-store results", () => {
    expect(phaseFVerdict([], [{ ok: false, offers: [], needsSolve: true }])).toMatchObject({
      state: "needs-solve",
    });
  });
});
