feat: 全局设置系统 — settings 表、CRUD 路由、主题偏好持久化
This commit is contained in:
36
tests/web/components/ConsoleShell.test.tsx
Normal file
36
tests/web/components/ConsoleShell.test.tsx
Normal file
@@ -0,0 +1,36 @@
|
||||
import { screen } from "@testing-library/react";
|
||||
import { describe, expect, test } from "bun:test";
|
||||
import { createElement } from "react";
|
||||
|
||||
import { ConsoleShell } from "../../../src/web/shared/components/ConsoleShell/ConsoleShell";
|
||||
import { installFetchMock, jsonResponse, mockMetaResponse, renderWithProviders } from "../test-utils";
|
||||
|
||||
function mockSettingsResponse(): Response {
|
||||
return jsonResponse({ theme: "system" });
|
||||
}
|
||||
|
||||
describe("ConsoleShell", () => {
|
||||
test("Header 不再渲染主题 Segmented", () => {
|
||||
installFetchMock((call) => {
|
||||
if (call.url.includes("/api/settings")) return mockSettingsResponse();
|
||||
if (call.url.includes("/api/meta")) return mockMetaResponse();
|
||||
return jsonResponse({});
|
||||
});
|
||||
|
||||
renderWithProviders(createElement(ConsoleShell, { menuItems: [], title: "测试" }));
|
||||
|
||||
expect(screen.queryByText("系统")).toBeNull();
|
||||
});
|
||||
|
||||
test("渲染品牌标题", () => {
|
||||
installFetchMock((call) => {
|
||||
if (call.url.includes("/api/settings")) return mockSettingsResponse();
|
||||
if (call.url.includes("/api/meta")) return mockMetaResponse();
|
||||
return jsonResponse({});
|
||||
});
|
||||
|
||||
renderWithProviders(createElement(ConsoleShell, { menuItems: [], title: "控制台" }));
|
||||
|
||||
expect(screen.getByText("控制台")).not.toBeNull();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user