- 新增 materials 表(id/projectId/description/associatedDate/status/createdAt/updatedAt) - 新增 4 个后端 API 路由(list/create/get/delete)+ 13 个测试 - 新增 use-materials hooks(TanStack Query) - 收集箱页面重构为三层架构(InboxPage + MaterialSidebar + MaterialDetailPanel) - MaterialCard: Popconfirm 删除确认 + 粗粒度时间格式 - MaterialContent: 展示状态标签 + createdAt - 更新开发文档 backend.md / frontend.md
41 lines
1.5 KiB
TypeScript
41 lines
1.5 KiB
TypeScript
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();
|
|
});
|
|
});
|