import { screen } from "@testing-library/react";
import { describe, expect, it, vi } from "vitest";
import { renderWithProviders } from "../utils/testHelpers";
import { PublicNotePage } from "./PublicNotePage";

vi.mock("../hooks/notes", () => ({
  usePublicNote: () => ({
    note: {
      id: "test-note-id",
      title: "Test Public Note",
      content:
        '[{"id":"c046f706-1a5a-4a4e-a2e9-54c7009a912a","type":"paragraph","props":{"backgroundColor":"default","textColor":"default","textAlignment":"left"},"content":[{"type":"text","text":"let\'s go","styles":{}}],"children":[]},{"id":"78ed0476-0fe5-48a2-b329-965d81596964","type":"paragraph","props":{"backgroundColor":"default","textColor":"default","textAlignment":"left"},"content":[],"children":[]}]',
      created_at: "2023-01-01",
    },
    isLoading: false,
    error: null,
  }),
}));

describe("PublicNotePage", () => {
  beforeEach(() => {
    vi.clearAllMocks();
  });

  it("renders without crashing", () => {
    const { container } = renderWithProviders(<PublicNotePage />);
    expect(container).toBeInTheDocument();
  });

  it("displays note title", () => {
    renderWithProviders(<PublicNotePage />);

    expect(screen.getByText("Test Public Note")).toBeInTheDocument();
  });

  it("displays note content", () => {
    const { container } = renderWithProviders(<PublicNotePage />);
    // The BlockNoteView should render the note content
    expect(container).toBeInTheDocument();
  });
});

// Note: Testing loading and error states would require re-mocking the hook with different values.
// The current test suite covers the happy path. State testing is better handled with integration tests.
