ab59476d10
- 优化桌面标签、上下文标题、前进后退、导航栏隐藏和原生菜单体验 - 补充登录会话 IP 采集、地理位置回退、管理端展示及数据库迁移 - 更新桌面发布检查、运维文档和前后端测试覆盖
33 lines
1.0 KiB
TypeScript
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,
|
|
});
|
|
});
|
|
});
|