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: "参数（H5 链接）" })).toBeInTheDocument();
    expect(screen.getByText("投放时间")).toBeInTheDocument();

    await user.click(screen.getByRole("combobox", { name: "跳转类型" }));
    await user.click(await screen.findByRole("option", { name: "APP" }));

    expect(screen.getByRole("combobox", { name: "APP 目标" })).toBeInTheDocument();
    expect(screen.getByRole("textbox", { name: "参数（APP 公共跳转 JSON）" })).toHaveValue(JSON.stringify({ type: "wallet" }));
  });
});
