import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import { render, screen } from "@testing-library/react";
import { describe, expect, it, vi } from "vitest";
import { AdminContentPanel } from "./AdminContentPanel";

vi.mock("@modules/content/api/contentApi", () => ({
  getAdminPages: vi.fn(async () => [
    { id: "1", slug: "about", title: "About", body: "<p>x</p>", status: "published" }
  ]),
  createContentPage: vi.fn(),
  updateContentPage: vi.fn(),
  deleteContentPage: vi.fn()
}));

describe("AdminContentPanel", () => {
  it("renders content management form", async () => {
    const queryClient = new QueryClient();
    render(
      <QueryClientProvider client={queryClient}>
        <AdminContentPanel />
      </QueryClientProvider>
    );
    expect(await screen.findByText("About")).toBeInTheDocument();
    expect(screen.getByRole("button", { name: "Create page" })).toBeInTheDocument();
  });
});
