// CurrentRunBanner: hidden when no run is in flight; with a live run it
// shows the run id, start stamp, and region progress. Fabricated props.

import { describe, expect, it } from "vitest";
import { render, screen } from "@testing-library/react";
import { CurrentRunBanner } from "@/components/runs/CurrentRunBanner";
import type { OverviewResponse } from "@/lib/api-types";

const current: NonNullable<OverviewResponse["currentRun"]> = {
  runId: "run-20260901T020000",
  status: "running",
  startedAt: "2026-09-01T02:00:00Z",
  regionsCompleted: 3,
  regionsTotal: 5,
};

describe("CurrentRunBanner", () => {
  it("renders nothing when no run is in flight", () => {
    const { container } = render(<CurrentRunBanner current={null} />);
    expect(container.firstChild).toBeNull();
  });

  it("shows the run id, start stamp, and region progress", () => {
    render(<CurrentRunBanner current={current} />);
    expect(screen.getByText("Run in progress")).toBeTruthy();
    expect(screen.getByText(/run-20260901T020000/)).toBeTruthy();
    expect(screen.getByText(/started 2026-09-01 10:00 UTC\+8/)).toBeTruthy();
    expect(screen.getByText("3/5 regions")).toBeTruthy();
  });
});
