#!/usr/bin/env node
import {
  StepRefine
} from "../../chunk-OLZBZAW4.js";
import {
  ARROW_DOWN,
  ARROW_UP,
  ENTER,
  ESCAPE,
  INPUT_DELAY_MS,
  RENDER_DELAY_MS,
  delay
} from "../../chunk-YZTWZVGX.js";
import {
  render
} from "../../chunk-66UDJBF6.js";
import {
  afterEach,
  describe,
  globalExpect,
  it,
  vi
} from "../../chunk-XY3XDVMI.js";
import {
  DEFAULT_BRANDING
} from "../../chunk-FVN5PFFY.js";
import {
  init_esm_shims
} from "../../chunk-DHET7RCE.js";

// src/cli/components/wizard/step-refine.test.tsx
init_esm_shims();
import { jsx } from "react/jsx-runtime";
var defaultProps = {
  technologyCount: 12,
  refineAction: "all-recommended",
  onSelectAction: vi.fn(),
  onContinue: vi.fn(),
  onBack: vi.fn()
};
var renderStepRefine = (props = {}) => {
  return render(/* @__PURE__ */ jsx(StepRefine, { ...defaultProps, ...props }));
};
describe("StepRefine component", () => {
  let cleanup;
  afterEach(() => {
    cleanup?.();
    cleanup = void 0;
  });
  describe("rendering", () => {
    it("should render technology count correctly", () => {
      const { lastFrame, unmount } = renderStepRefine({ technologyCount: 12 });
      cleanup = unmount;
      const output = lastFrame();
      globalExpect(output).toContain("12");
      globalExpect(output).toContain("technologies");
    });
    it("should render different technology count", () => {
      const { lastFrame, unmount } = renderStepRefine({ technologyCount: 5 });
      cleanup = unmount;
      const output = lastFrame();
      globalExpect(output).toContain("5");
      globalExpect(output).toContain("technologies");
    });
    it("should render 'Use all recommended' option", () => {
      const { lastFrame, unmount } = renderStepRefine();
      cleanup = unmount;
      const output = lastFrame();
      globalExpect(output).toContain("Use all recommended skills (verified)");
    });
    it("should show 'Use all recommended' option as highlighted", () => {
      const { lastFrame, unmount } = renderStepRefine({
        refineAction: "all-recommended"
      });
      cleanup = unmount;
      const output = lastFrame();
      globalExpect(output).toContain(">");
      globalExpect(output).toContain("Use all recommended skills");
    });
    it("should render verification description", () => {
      const { lastFrame, unmount } = renderStepRefine();
      cleanup = unmount;
      const output = lastFrame();
      globalExpect(output).toContain("fastest option");
      globalExpect(output).toContain("verified");
      globalExpect(output).toContain(DEFAULT_BRANDING.NAME);
    });
  });
  describe("customize option", () => {
    it("should show 'Customize' option as disabled/grayed", () => {
      const { lastFrame, unmount } = renderStepRefine();
      cleanup = unmount;
      const output = lastFrame();
      globalExpect(output).toContain("Customize skill sources");
    });
    it("should show customize option without coming soon label", () => {
      const { lastFrame, unmount } = renderStepRefine();
      cleanup = unmount;
      const output = lastFrame();
      globalExpect(output).toContain("Customize skill sources");
      globalExpect(output).not.toContain("(coming soon)");
    });
    it("should show customize description", () => {
      const { lastFrame, unmount } = renderStepRefine();
      cleanup = unmount;
      const output = lastFrame();
      globalExpect(output).toContain("Choose alternative skills for each technology");
    });
  });
  describe("keyboard shortcuts display", () => {
    it("should render recommended option content", () => {
      const { lastFrame, unmount } = renderStepRefine();
      cleanup = unmount;
      const output = lastFrame();
      globalExpect(output).toContain("Use all recommended");
      globalExpect(output).toContain("Customize skill sources");
    });
  });
  describe("keyboard navigation", () => {
    it("should call onContinue when Enter key is pressed", async () => {
      const onContinue = vi.fn();
      const { stdin, unmount } = renderStepRefine({ onContinue });
      cleanup = unmount;
      await delay(RENDER_DELAY_MS);
      stdin.write(ENTER);
      await delay(INPUT_DELAY_MS);
      globalExpect(onContinue).toHaveBeenCalledTimes(1);
    });
    it("should call onBack when Escape key is pressed", async () => {
      const onBack = vi.fn();
      const { stdin, unmount } = renderStepRefine({ onBack });
      cleanup = unmount;
      await delay(RENDER_DELAY_MS);
      stdin.write(ESCAPE);
      await delay(INPUT_DELAY_MS);
      globalExpect(onBack).toHaveBeenCalledTimes(1);
    });
    it("should toggle to 'customize' on arrow up when recommended is selected", async () => {
      const onSelectAction = vi.fn();
      const { stdin, unmount } = renderStepRefine({
        onSelectAction,
        refineAction: "all-recommended"
      });
      cleanup = unmount;
      await delay(RENDER_DELAY_MS);
      stdin.write(ARROW_UP);
      await delay(INPUT_DELAY_MS);
      globalExpect(onSelectAction).toHaveBeenCalledWith("customize");
    });
    it("should toggle to 'all-recommended' on arrow down when customize is selected", async () => {
      const onSelectAction = vi.fn();
      const { stdin, unmount } = renderStepRefine({
        onSelectAction,
        refineAction: "customize"
      });
      cleanup = unmount;
      await delay(RENDER_DELAY_MS);
      stdin.write(ARROW_DOWN);
      await delay(INPUT_DELAY_MS);
      globalExpect(onSelectAction).toHaveBeenCalledWith("all-recommended");
    });
  });
  describe("selection state", () => {
    it("should handle null refineAction (defaults to recommended)", () => {
      const { lastFrame, unmount } = renderStepRefine({ refineAction: null });
      cleanup = unmount;
      const output = lastFrame();
      globalExpect(output).toContain(">");
      globalExpect(output).toContain("Use all recommended");
    });
    it("should handle 'all-recommended' refineAction", () => {
      const { lastFrame, unmount } = renderStepRefine({
        refineAction: "all-recommended"
      });
      cleanup = unmount;
      const output = lastFrame();
      globalExpect(output).toContain("Use all recommended");
    });
    it("should handle 'customize' refineAction (even though disabled)", () => {
      const { lastFrame, unmount } = renderStepRefine({
        refineAction: "customize"
      });
      cleanup = unmount;
      const output = lastFrame();
      globalExpect(output).toContain("Use all recommended");
      globalExpect(output).toContain("Customize skill sources");
    });
  });
  describe("edge cases", () => {
    it("should handle zero technology count", () => {
      const { lastFrame, unmount } = renderStepRefine({ technologyCount: 0 });
      cleanup = unmount;
      const output = lastFrame();
      globalExpect(output).toContain("0");
      globalExpect(output).toContain("technologies");
    });
    it("should handle single technology count", () => {
      const { lastFrame, unmount } = renderStepRefine({ technologyCount: 1 });
      cleanup = unmount;
      const output = lastFrame();
      globalExpect(output).toContain("1");
      globalExpect(output).toContain("technologies");
    });
    it("should handle large technology count", () => {
      const { lastFrame, unmount } = renderStepRefine({ technologyCount: 100 });
      cleanup = unmount;
      const output = lastFrame();
      globalExpect(output).toContain("100");
      globalExpect(output).toContain("technologies");
    });
  });
  describe("multiple keyboard events", () => {
    it("should allow multiple Enter presses", async () => {
      const onContinue = vi.fn();
      const { stdin, unmount } = renderStepRefine({ onContinue });
      cleanup = unmount;
      await delay(RENDER_DELAY_MS);
      stdin.write(ENTER);
      await delay(INPUT_DELAY_MS);
      stdin.write(ENTER);
      await delay(INPUT_DELAY_MS);
      globalExpect(onContinue).toHaveBeenCalledTimes(2);
    });
    it("should allow multiple Escape presses", async () => {
      const onBack = vi.fn();
      const { stdin, unmount } = renderStepRefine({ onBack });
      cleanup = unmount;
      await delay(RENDER_DELAY_MS);
      stdin.write(ESCAPE);
      await delay(INPUT_DELAY_MS);
      stdin.write(ESCAPE);
      await delay(INPUT_DELAY_MS);
      globalExpect(onBack).toHaveBeenCalledTimes(2);
    });
  });
});
//# sourceMappingURL=step-refine.test.js.map