Files
ctms/frontend/src/runtime/desktopMenu.test.ts
T
Cheng Zhou ab59476d10
Client Quality Gates / Shared client and Web (push) Has been cancelled
Client Quality Gates / macOS Desktop (push) Has been cancelled
feat(桌面与监控): 完善工作台导航和登录活动定位
- 优化桌面标签、上下文标题、前进后退、导航栏隐藏和原生菜单体验

- 补充登录会话 IP 采集、地理位置回退、管理端展示及数据库迁移

- 更新桌面发布检查、运维文档和前后端测试覆盖
2026-07-13 16:03:20 +08:00

33 lines
1.0 KiB
TypeScript

import { afterEach, describe, expect, it, vi } from "vitest";
import { DEFAULT_DESKTOP_SHORTCUTS } from "./desktopUiPreferences";
import { syncDesktopMenuShortcuts } from "./desktopMenu";
const invokeMock = vi.hoisted(() => vi.fn());
vi.mock("@tauri-apps/api/core", () => ({
invoke: invokeMock,
}));
afterEach(() => {
invokeMock.mockReset();
Reflect.deleteProperty(window, "__TAURI_INTERNALS__");
});
describe("desktop native menu", () => {
it("does not invoke desktop commands in the web runtime", async () => {
await syncDesktopMenuShortcuts(DEFAULT_DESKTOP_SHORTCUTS);
expect(invokeMock).not.toHaveBeenCalled();
});
it("synchronizes validated shortcut preferences through the controlled command", async () => {
Object.defineProperty(window, "__TAURI_INTERNALS__", { value: {}, configurable: true });
await syncDesktopMenuShortcuts(DEFAULT_DESKTOP_SHORTCUTS);
expect(invokeMock).toHaveBeenCalledWith("desktop_menu_set_shortcuts", {
shortcuts: DEFAULT_DESKTOP_SHORTCUTS,
});
});
});