import { describe, expect, it, vi } from "vitest";
import { renderWithProviders } from "../utils/testHelpers";
import { TabloDiscussionSection } from "./TabloDiscussionSection";

// Mock Stream Chat
vi.mock("stream-chat-react", () => ({
  Chat: ({ children }: { children: React.ReactNode }) => <div data-testid="chat">{children}</div>,
  Channel: ({ children }: { children: React.ReactNode }) => (
    <div data-testid="channel">{children}</div>
  ),
  Window: ({ children }: { children: React.ReactNode }) => (
    <div data-testid="window">{children}</div>
  ),
  MessageList: () => <div data-testid="message-list">Messages</div>,
  MessageInput: () => <div data-testid="message-input">Input</div>,
  useChannelStateContext: () => ({ channel: null }),
  useCreateChatClient: () => null,
  useChatContext: () => ({
    client: null,
    setActiveChannel: vi.fn(),
  }),
}));

vi.mock("../providers/ChatProvider", () => ({
  useChatContext: () => ({
    client: null,
    setActiveChannel: vi.fn(),
  }),
  default: ({ children }: { children: React.ReactNode }) => <>{children}</>,
}));

describe("TabloDiscussionSection", () => {
  const mockTablo = {
    id: "test-tablo-id",
    name: "Test Tablo",
    color: "bg-blue-500",
    user_id: "test-user-id",
    access_level: "admin",
    is_admin: true,
    created_at: "2024-01-01T00:00:00Z",
    deleted_at: "2024-01-01T00:00:00Z",
    position: 0,
    status: "active",
    image: null,
  };

  it("renders without crashing", () => {
    const { container } = renderWithProviders(
      <TabloDiscussionSection tablo={mockTablo} isAdmin={true} />
    );
    expect(container).toBeInTheDocument();
  });
});
