import { renderToStaticMarkup } from "react-dom/server";
import { describe, expect, it, vi } from "vitest";
import type { WorkPackage } from "@/lib/work-package-types";
import { WorkPackageDetail } from "./WorkPackageDetail";

const workPackage: WorkPackage = {
  id: "wp-srs",
  title: "System Requirements Specification",
  shortName: "SRS",
  phase: "Specify Product",
  objective:
    "Translate CRS into traceable system-level requirements, components, interfaces, specifications, and verification methods.",
  inputFiles: ["Product brief", "CRS traceability input"],
  outputFiles: ["System Requirements Specification"],
  coreSections: ["Verification Method", "Acceptance Criteria"],
  tasks: [
    {
      id: "task-1",
      title: "Translate CRS into system requirements",
      description: "Produce traceable system-level requirements with verification logic.",
      type: "generation",
      executable: true,
      status: "todo",
    },
  ],
  outputs: [
    {
      id: "out-1",
      title: "SRS Draft",
      type: "table",
      content: "Verification Method means how the requirement will be checked.",
      createdAt: "2026-01-01T00:00:00.000Z",
      executionMode: "simulated",
      disclaimer: "Simulated.",
    },
  ],
  status: "todo",
  priority: "high",
};

describe("WorkPackageDetail", () => {
  it("renders ask-about-this controls for detailed package content", () => {
    const html = renderToStaticMarkup(
      <WorkPackageDetail
        workPackage={workPackage}
        onPrefill={vi.fn()}
        onBack={vi.fn()}
      />,
    );

    expect(html).toContain("Ask about objective");
    expect(html).toContain("Ask about latest output");
    expect(html).toContain("Ask about this paragraph");
    expect(html).toContain("Ask about this task");
  });
});
