- 引入 React Router v7 (Declarative mode) 实现 SPA 路由 - 重构 Layout 为 Header + 侧边栏 + 内容区的企业 Admin 布局 - 新增侧边栏菜单组件,支持折叠/展开,状态持久化到 localStorage - 新增示例页面:仪表盘、用户管理、系统设置、404 - 菜单配置与路由统一为单一数据源 (menu.tsx) - Vite code splitting 新增 vendor-router 组 - 更新 DEVELOPMENT.md 和 README.md 文档
42 lines
1.5 KiB
TypeScript
42 lines
1.5 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() }), {
|
|
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() }), {
|
|
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);
|
|
expect(screen.getAllByText("系统设置").length).toBeGreaterThan(0);
|
|
});
|
|
});
|