import { describe, it, expect, vi, beforeAll } from "vitest"; import { render, screen } from "@testing-library/react"; import { MantineProvider } from "@mantine/core"; import { IComment } from "@/features/comment/types/comment.types"; // MantineProvider reads window.matchMedia on mount, which jsdom lacks. beforeAll(() => { Object.defineProperty(window, "matchMedia", { writable: true, value: (query: string) => ({ matches: false, media: query, onchange: null, addListener: vi.fn(), removeListener: vi.fn(), addEventListener: vi.fn(), removeEventListener: vi.fn(), dispatchEvent: vi.fn(), }), }); }); // The comment mutation hooks reach out to react-query/network — stub them so the // component renders in isolation. We only assert the AI-badge rendering branch. vi.mock("@/features/comment/queries/comment-query", () => ({ useDeleteCommentMutation: () => ({ mutateAsync: vi.fn() }), useResolveCommentMutation: () => ({ mutateAsync: vi.fn() }), useUpdateCommentMutation: () => ({ mutateAsync: vi.fn() }), })); // CommentEditor pulls in the full TipTap editor stack; replace it with a stub. vi.mock("@/features/comment/components/comment-editor", () => ({ default: () =>
, })); import CommentListItem from "./comment-list-item"; const baseComment = (over?: Partial