import { describe, expect, test } from "vitest";

import {
  getProjectWorkNextAction,
  getProjectWorkProgress,
  getProjectWorkStatus,
} from "./project-work";

describe("project work state mapping", () => {
  test("maps issue and run statuses to the same product language", () => {
    expect(getProjectWorkStatus("working")).toEqual({
      label: "In progress",
      phase: "active",
      verification: "running",
    });
    expect(getProjectWorkStatus("needs-input")).toEqual({
      label: "Needs your input",
      phase: "waiting",
      verification: "blocked",
    });
  });

  test("keeps progress monotonic through the normal loop", () => {
    expect(getProjectWorkProgress("open")).toBeLessThan(
      getProjectWorkProgress("queued")
    );
    expect(getProjectWorkProgress("queued")).toBeLessThan(
      getProjectWorkProgress("working")
    );
    expect(getProjectWorkProgress("working")).toBeLessThan(
      getProjectWorkProgress("completed")
    );
  });

  test("maps each state to the next product action", () => {
    expect(getProjectWorkNextAction("open")).toBe("Start the project manager");
    expect(getProjectWorkNextAction("failed")).toBe(
      "Review the failure and retry"
    );
    expect(getProjectWorkNextAction("completed")).toBe(
      "Review the pull request"
    );
  });
});
