import { render, screen } from "@testing-library/react";
import userEvent from "@testing-library/user-event";
import { describe, expect, test, vi } from "vitest";
import { BannerCreateDialog } from "./BannerCreateDialog.jsx";

describe("BannerCreateDialog", () => {
  test("uses the shared structured app jump field and unified time range picker", async () => {
    const user = userEvent.setup();
    render(<BannerCreateDialog open onClose={vi.fn()} onSubmit={vi.fn()} />);

    expect(screen.getByRole("textbox", { name: "Parameter (H5 URL)" })).toBeInTheDocument();
    expect(screen.getByText("Schedule")).toBeInTheDocument();

    await user.click(screen.getByRole("combobox", { name: "Destination type" }));
    await user.click(await screen.findByRole("option", { name: "APP" }));

    expect(screen.getByRole("combobox", { name: "App destination" })).toBeInTheDocument();
    expect(screen.getByRole("textbox", { name: "Parameter (App navigation JSON)" })).toHaveValue(JSON.stringify({ type: "wallet" }));
    expect(screen.queryByText("App navigation parameters are generated as JSON. You can edit the JSON directly for custom parameters.")).not.toBeInTheDocument();
  });
});
