import { screen } from "@testing-library/react";
import { describe, expect, test } from "bun:test";
import { createElement } from "react";

import type { Material } from "../../../../src/shared/api";

import { MaterialContent } from "../../../../src/web/features/inbox/components/MaterialContent";
import { renderWithProviders } from "../../test-utils";

const MOCK_MATERIAL: Material = {
  associatedDate: "2026-06-03",
  createdAt: "2026-06-03T00:00:00.000Z",
  description: "详细描述内容",
  id: "test-id",
  projectId: "project-1",
  status: "pending",
  updatedAt: "2026-06-03T00:00:00.000Z",
};

describe("MaterialContent", () => {
  test("展示素材详情和状态", () => {
    renderWithProviders(createElement(MaterialContent, { material: MOCK_MATERIAL }));
    expect(screen.getByText("素材详情")).not.toBeNull();
    expect(screen.getByText("详细描述内容")).not.toBeNull();
    expect(screen.getByText("2026-06-03")).not.toBeNull();
    expect(screen.getByText("待审核")).not.toBeNull();
  });

  test("展示已通过状态", () => {
    const approved: Material = { ...MOCK_MATERIAL, status: "approved" };
    renderWithProviders(createElement(MaterialContent, { material: approved }));
    expect(screen.getByText("已通过")).not.toBeNull();
  });

  test("展示已放弃状态", () => {
    const discarded: Material = { ...MOCK_MATERIAL, status: "discarded" };
    renderWithProviders(createElement(MaterialContent, { material: discarded }));
    expect(screen.getByText("已放弃")).not.toBeNull();
  });
});
