- 移除 Header 左侧折叠按钮,改用 TDesign Menu operations 渲染底部折叠按钮 - Header 品牌名与版本号使用 brand-group 基线对齐 - 侧边栏折叠宽度从 80px 对齐 TDesign 默认 64px - 更新相关测试和 DEVELOPMENT.md 文档
65 lines
2.1 KiB
TypeScript
65 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);
|
|
expect(screen.getAllByText("系统设置").length).toBeGreaterThan(0);
|
|
});
|
|
|
|
test("Header 不包含侧边栏折叠按钮", () => {
|
|
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 toggleButtons = document.querySelectorAll(".app-sidebar-toggle");
|
|
expect(toggleButtons.length).toBe(0);
|
|
});
|
|
});
|