feat(inbox): 素材持久化 CRUD — 数据库表 + API + 前端接入
- 新增 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
This commit is contained in:
@@ -2,28 +2,39 @@ import { screen } from "@testing-library/react";
|
||||
import { describe, expect, test } from "bun:test";
|
||||
import { createElement } from "react";
|
||||
|
||||
import type { Material } from "../../../../src/web/features/inbox/types";
|
||||
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: new Date().toISOString(),
|
||||
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: null }));
|
||||
expect(screen.getByText("请在左侧选择素材")).not.toBeNull();
|
||||
});
|
||||
|
||||
test("选中时展示素材详情", () => {
|
||||
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();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user