#!/usr/bin/env node
import {
  ARROW_DOWN,
  ENTER,
  ESCAPE,
  INPUT_DELAY_MS,
  RENDER_DELAY_MS,
  SPACE,
  delay
} from "../../chunk-YZTWZVGX.js";
import {
  render
} from "../../chunk-66UDJBF6.js";
import {
  afterEach,
  beforeEach,
  describe,
  globalExpect,
  it
} from "../../chunk-XY3XDVMI.js";
import {
  StepAgents
} from "../../chunk-WWSKP5SR.js";
import "../../chunk-K77I4XGL.js";
import "../../chunk-KWWLPPHF.js";
import {
  useWizardStore
} from "../../chunk-FYNMNY4P.js";
import "../../chunk-KZNPPUQG.js";
import "../../chunk-ZECXM7LP.js";
import "../../chunk-T4EXUIBY.js";
import "../../chunk-473YHDYQ.js";
import "../../chunk-FVN5PFFY.js";
import {
  init_esm_shims
} from "../../chunk-DHET7RCE.js";

// src/cli/components/wizard/step-agents.test.tsx
init_esm_shims();
import { jsx } from "react/jsx-runtime";
describe("StepAgents component", () => {
  let cleanup;
  beforeEach(() => {
    useWizardStore.getState().reset();
  });
  afterEach(() => {
    cleanup?.();
    cleanup = void 0;
  });
  describe("rendering", () => {
    it("should render title", () => {
      const { lastFrame, unmount } = render(/* @__PURE__ */ jsx(StepAgents, {}));
      cleanup = unmount;
      const output = lastFrame();
      globalExpect(output).toContain("Select agents to compile:");
    });
    it("should render all agents", () => {
      const { lastFrame, unmount } = render(/* @__PURE__ */ jsx(StepAgents, {}));
      cleanup = unmount;
      const output = lastFrame();
      globalExpect(output).toContain("Web Developer");
      globalExpect(output).toContain("API Developer");
      globalExpect(output).toContain("CLI Developer");
      globalExpect(output).toContain("Web Architecture");
      globalExpect(output).toContain("Web Reviewer");
      globalExpect(output).toContain("API Reviewer");
      globalExpect(output).toContain("CLI Reviewer");
      globalExpect(output).toContain("Web Researcher");
      globalExpect(output).toContain("API Researcher");
      globalExpect(output).toContain("Web Tester");
      globalExpect(output).toContain("CLI Tester");
      globalExpect(output).toContain("Web PM");
      globalExpect(output).toContain("Pattern Scout");
      globalExpect(output).toContain("Pattern Critique");
      globalExpect(output).toContain("Agent Summoner");
      globalExpect(output).toContain("Skill Summoner");
      globalExpect(output).toContain("Documentor");
      globalExpect(output).toContain("CLI Migrator");
    });
    it("should render agent descriptions", () => {
      const { lastFrame, unmount } = render(/* @__PURE__ */ jsx(StepAgents, {}));
      cleanup = unmount;
      const output = lastFrame();
      globalExpect(output).toContain("Frontend features, components, TypeScript");
      globalExpect(output).toContain("Backend routes, database, middleware");
      globalExpect(output).toContain("CLI commands, interactive prompts");
    });
    it("should render group headers", () => {
      const { lastFrame, unmount } = render(/* @__PURE__ */ jsx(StepAgents, {}));
      cleanup = unmount;
      const output = lastFrame();
      globalExpect(output).toContain("Web");
      globalExpect(output).toContain("API");
      globalExpect(output).toContain("CLI");
      globalExpect(output).toContain("Meta");
    });
    it("should show continue arrow", () => {
      const { lastFrame, unmount } = render(/* @__PURE__ */ jsx(StepAgents, {}));
      cleanup = unmount;
      const output = lastFrame();
      globalExpect(output).toContain("\u2192");
      globalExpect(output).toContain("Continue");
    });
    it("should show continue option with agent count when agents selected", () => {
      const store = useWizardStore.getState();
      store.toggleAgent("web-developer");
      store.toggleAgent("api-developer");
      store.toggleAgent("web-reviewer");
      const { lastFrame, unmount } = render(/* @__PURE__ */ jsx(StepAgents, {}));
      cleanup = unmount;
      const output = lastFrame();
      globalExpect(output).toContain("Continue with 3 agent(s)");
    });
    it("should show 'Continue without agents' when no agents selected", () => {
      const { lastFrame, unmount } = render(/* @__PURE__ */ jsx(StepAgents, {}));
      cleanup = unmount;
      const output = lastFrame();
      globalExpect(output).toContain("Continue without agents");
    });
  });
  describe("keyboard interaction", () => {
    it("should toggle agent on SPACE", async () => {
      const { stdin, lastFrame, unmount } = render(/* @__PURE__ */ jsx(StepAgents, {}));
      cleanup = unmount;
      await delay(RENDER_DELAY_MS);
      stdin.write(SPACE);
      await delay(INPUT_DELAY_MS);
      const store = useWizardStore.getState();
      globalExpect(store.selectedAgents).toContain("web-developer");
    });
    it("should toggle correct agent after navigation", async () => {
      const { stdin, unmount } = render(/* @__PURE__ */ jsx(StepAgents, {}));
      cleanup = unmount;
      await delay(RENDER_DELAY_MS);
      stdin.write(ARROW_DOWN);
      await delay(INPUT_DELAY_MS);
      stdin.write(SPACE);
      await delay(INPUT_DELAY_MS);
      const store = useWizardStore.getState();
      globalExpect(store.selectedAgents).toContain("web-reviewer");
    });
    it("should navigate to confirm on ENTER when agents selected", async () => {
      const store = useWizardStore.getState();
      store.toggleAgent("web-developer");
      store.setStep("agents");
      const { stdin, unmount } = render(/* @__PURE__ */ jsx(StepAgents, {}));
      cleanup = unmount;
      await delay(RENDER_DELAY_MS);
      stdin.write(ENTER);
      await delay(INPUT_DELAY_MS);
      const updatedStore = useWizardStore.getState();
      globalExpect(updatedStore.step).toBe("confirm");
    });
    it("should navigate to confirm on ENTER even with no agents selected", async () => {
      const store = useWizardStore.getState();
      store.setStep("agents");
      const { stdin, unmount } = render(/* @__PURE__ */ jsx(StepAgents, {}));
      cleanup = unmount;
      await delay(RENDER_DELAY_MS);
      stdin.write(ENTER);
      await delay(INPUT_DELAY_MS);
      const updatedStore = useWizardStore.getState();
      globalExpect(updatedStore.step).toBe("confirm");
    });
    it("should go back on ESC", async () => {
      const store = useWizardStore.getState();
      store.setStep("sources");
      store.setStep("agents");
      const { stdin, unmount } = render(/* @__PURE__ */ jsx(StepAgents, {}));
      cleanup = unmount;
      await delay(RENDER_DELAY_MS);
      stdin.write(ESCAPE);
      await delay(INPUT_DELAY_MS);
      const updatedStore = useWizardStore.getState();
      globalExpect(updatedStore.step).toBe("sources");
    });
    it("should toggle agent off when already selected", async () => {
      const store = useWizardStore.getState();
      store.toggleAgent("web-developer");
      const { stdin, unmount } = render(/* @__PURE__ */ jsx(StepAgents, {}));
      cleanup = unmount;
      await delay(RENDER_DELAY_MS);
      stdin.write(SPACE);
      await delay(INPUT_DELAY_MS);
      const updatedStore = useWizardStore.getState();
      globalExpect(updatedStore.selectedAgents).not.toContain("web-developer");
    });
  });
});
//# sourceMappingURL=step-agents.test.js.map