import { render, screen } from "@testing-library/react";
import { vi, test, expect } from "vitest";
import { HostAgencyPolicyDrawer } from "@/features/host-agency-policy/components/HostAgencyPolicyDrawer.jsx";

test("host agency policy drawer shows residual diamonds per USD and hides gift ratio input", () => {
    render(<HostAgencyPolicyDrawer page={drawerPage()} />);

    expect(screen.queryByLabelText("金币转钻石比例")).not.toBeInTheDocument();
    expect(screen.getByText("剩余钻石兑美元")).toBeInTheDocument();
    expect(screen.getByDisplayValue("100")).toBeInTheDocument();
    expect(screen.getByText("钻石=1美元")).toBeInTheDocument();
    expect(screen.getByText("0 表示不折算")).toBeInTheDocument();
});

function drawerPage() {
    return {
        abilities: {
            canCreate: true,
            canUpdate: true,
        },
        addLevel: vi.fn(),
        closeDrawer: vi.fn(),
        drawerOpen: true,
        editingPolicy: null,
        form: {
            effectiveFrom: "",
            effectiveTo: "",
            enabled: false,
            levels: [
                {
                    agencySalaryUsd: "0.5",
                    hostCoinReward: "90000",
                    hostSalaryUsd: "1.5",
                    level: "1",
                    requiredDiamonds: "350000",
                    sortOrder: "1",
                    status: "active",
                },
            ],
            name: "Lalu Host & Agency Salary Policy",
            regionId: "1001",
            residualDiamondsPerUsd: "100",
            settlementMode: "daily",
            settlementTriggerMode: "automatic",
        },
        loadingAction: "",
        loadingRegions: false,
        regionOptions: [{ label: "默认区域", value: "1001" }],
        removeLevel: vi.fn(),
        setForm: vi.fn(),
        submitPolicy: vi.fn((event) => event.preventDefault()),
        updateLevel: vi.fn(),
    };
}
