1
0

feat: 版本管理,package.json 唯一版本源、/api/meta 返回版本、Dashboard Header 展示版本号

This commit is contained in:
2026-05-20 19:14:37 +08:00
parent f3df3a203b
commit 8eac814cc6
25 changed files with 490 additions and 20 deletions

View File

@@ -69,7 +69,7 @@ function installMatchMedia(initialMatches: boolean) {
void vi.mock("../../../src/web/hooks/use-queries", () => ({
useDashboard: vi.fn(() => createDashboardResult()),
useMeta: vi.fn(() => ({
data: { checkerTypes: ["http", "cmd"] },
data: { checkerTypes: ["http", "cmd"], version: "0.1.0" },
})),
}));
@@ -208,4 +208,25 @@ describe("App", () => {
act(() => matchMediaController.setMatches(true));
await waitFor(() => expect(document.documentElement.getAttribute("theme-mode")).toBe("dark"));
});
test("Header 展示版本号", () => {
render(<App />);
expect(screen.getByText("v0.1.0")).not.toBeNull();
});
test("缺失版本时不展示版本占位", () => {
const { useMeta } = require("../../../src/web/hooks/use-queries");
useMeta.mockReturnValue({
data: { checkerTypes: ["http", "cmd"] },
});
render(<App />);
expect(screen.queryByText(/v\d+\.\d+\.\d+/)).toBeNull();
});
test("复用 useMeta 查询结果", () => {
const { useMeta } = require("../../../src/web/hooks/use-queries");
render(<App />);
expect(useMeta).toHaveBeenCalled();
});
});