// @vitest-environment jsdom

import { fireEvent, render, screen } from "@testing-library/react";
import { describe, expect, it, vi } from "vitest";
import type { ExecutionEvent } from "@/lib/sync/execution/types";
import { ExecuteStepSection } from "./execute-step";

describe("ExecuteStepSection", () => {
  it("renders execution console and forwards new-bump action", () => {
    const onNewBump = vi.fn();
    const progress: ExecutionEvent[] = [
      {
        step: "precheck",
        status: "success",
        message: "Precheck done",
        at: "2026-05-27T00:00:00.000Z",
      },
    ];

    render(
      <ExecuteStepSection
        progress={progress}
        bumping={false}
        configSyncResult={null}
        onNewBump={onNewBump}
      />
    );

    expect(screen.getByText("Execution Progress")).toBeInTheDocument();
    expect(screen.getByText("New Bump")).toBeInTheDocument();

    fireEvent.click(screen.getByRole("button", { name: "New Bump" }));
    expect(onNewBump).toHaveBeenCalledTimes(1);
  });
});
