- 修正 API 响应类型,增加 ProjectResponse 包装类型 - ConfigProvider 配置中文 locale (zhCN) - 生产入口启用 ErrorBoundary,使用 Result 组件 - ReactQueryDevtools 仅开发环境渲染 - Sider 增加 collapsible 配置,使用 antd 默认折叠行为 - 项目页面拆分为 ProjectToolbar/ProjectTable/ProjectFormModal - 搜索改用 Input.Search,表单增加 whitespace 校验 - 404/ErrorBoundary/Dashboard 使用 antd Result/Typography/Card/Descriptions - 清理未使用的 ProtectedRoute 和冗余样式类 - styles.css 仅保留必要布局样式,无 antd 内部类覆盖 - 更新测试覆盖,避免依赖 antd 内部类名 - 更新 docs/development/frontend.md 开发规范
66 lines
2.1 KiB
TypeScript
66 lines
2.1 KiB
TypeScript
/* eslint-disable @typescript-eslint/require-await */
|
|
import { screen } from "@testing-library/react";
|
|
import { describe, expect, test } from "bun:test";
|
|
import { createElement } from "react";
|
|
|
|
import { APP } from "../../src/shared/app";
|
|
import { App } from "../../src/web/app";
|
|
import { renderWithProviders } from "./test-utils";
|
|
|
|
describe("App", () => {
|
|
test("渲染 Layout 骨架和品牌名", () => {
|
|
window.fetch = (async () => {
|
|
return new Response(
|
|
JSON.stringify({ ok: true, service: "test-app", timestamp: new Date().toISOString(), version: "0.1.0" }),
|
|
{
|
|
headers: { "Content-Type": "application/json" },
|
|
status: 200,
|
|
},
|
|
);
|
|
}) as unknown as typeof fetch;
|
|
|
|
renderWithProviders(createElement(App));
|
|
|
|
expect(screen.getByText(APP.title)).not.toBeNull();
|
|
expect(screen.getByText("系统")).not.toBeNull();
|
|
expect(screen.getByText("明亮")).not.toBeNull();
|
|
expect(screen.getByText("黑暗")).not.toBeNull();
|
|
});
|
|
|
|
test("渲染侧边栏菜单项", () => {
|
|
window.fetch = (async () => {
|
|
return new Response(
|
|
JSON.stringify({ ok: true, service: "test-app", timestamp: new Date().toISOString(), version: "0.1.0" }),
|
|
{
|
|
headers: { "Content-Type": "application/json" },
|
|
status: 200,
|
|
},
|
|
);
|
|
}) as unknown as typeof fetch;
|
|
|
|
renderWithProviders(createElement(App));
|
|
|
|
expect(screen.getAllByText("仪表盘").length).toBeGreaterThan(0);
|
|
expect(screen.getAllByText("项目管理").length).toBeGreaterThan(0);
|
|
});
|
|
|
|
test("Sider 渲染侧边栏菜单", () => {
|
|
window.fetch = (async () => {
|
|
return new Response(
|
|
JSON.stringify({ ok: true, service: "test-app", timestamp: new Date().toISOString(), version: "0.1.0" }),
|
|
{
|
|
headers: { "Content-Type": "application/json" },
|
|
status: 200,
|
|
},
|
|
);
|
|
}) as unknown as typeof fetch;
|
|
|
|
renderWithProviders(createElement(App));
|
|
|
|
const sider = document.querySelector(".ant-layout-sider");
|
|
expect(sider).not.toBeNull();
|
|
const menu = document.querySelector(".ant-menu");
|
|
expect(menu).not.toBeNull();
|
|
});
|
|
});
|