mirror of
https://github.com/multica-ai/multica.git
synced 2026-06-17 03:38:32 +02:00
The sidebar search trigger, quick-create-issue modal, and feedback modal hardcoded the Mac glyphs (⌘, ↵) for their keyboard hints, so Windows and Linux users always saw Mac shortcuts even though the underlying handlers already accept metaKey || ctrlKey. Extract a small platform helper (isMac, modKey, enterKey, formatShortcut) in packages/core/platform/keyboard.ts and route all four affected sites (plus the editor bubble menu, which had the same logic inlined) through it, so non-Mac users see Ctrl+K, Ctrl+Enter, etc. Closes multica-ai/multica#2056
52 lines
1.6 KiB
TypeScript
52 lines
1.6 KiB
TypeScript
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
|
|
afterEach(() => {
|
|
vi.unstubAllGlobals();
|
|
vi.resetModules();
|
|
});
|
|
|
|
beforeEach(() => {
|
|
vi.resetModules();
|
|
});
|
|
|
|
describe("keyboard platform helper", () => {
|
|
it("renders Mac symbols when navigator.platform is MacIntel", async () => {
|
|
vi.stubGlobal("navigator", { platform: "MacIntel" });
|
|
const mod = await import("./keyboard");
|
|
|
|
expect(mod.isMac).toBe(true);
|
|
expect(mod.modKey).toBe("⌘");
|
|
expect(mod.enterKey).toBe("↵");
|
|
expect(mod.formatShortcut(mod.modKey, "K")).toBe("⌘K");
|
|
expect(mod.formatShortcut(mod.modKey, mod.enterKey)).toBe("⌘↵");
|
|
});
|
|
|
|
it("renders Ctrl/Enter on Windows", async () => {
|
|
vi.stubGlobal("navigator", { platform: "Win32" });
|
|
const mod = await import("./keyboard");
|
|
|
|
expect(mod.isMac).toBe(false);
|
|
expect(mod.modKey).toBe("Ctrl");
|
|
expect(mod.enterKey).toBe("Enter");
|
|
expect(mod.formatShortcut(mod.modKey, "K")).toBe("Ctrl+K");
|
|
expect(mod.formatShortcut(mod.modKey, mod.enterKey)).toBe("Ctrl+Enter");
|
|
});
|
|
|
|
it("renders Ctrl/Enter on Linux", async () => {
|
|
vi.stubGlobal("navigator", { platform: "Linux x86_64" });
|
|
const mod = await import("./keyboard");
|
|
|
|
expect(mod.isMac).toBe(false);
|
|
expect(mod.modKey).toBe("Ctrl");
|
|
expect(mod.formatShortcut("Ctrl", "Shift", "P")).toBe("Ctrl+Shift+P");
|
|
});
|
|
|
|
it("falls back to non-Mac when navigator is unavailable (SSR)", async () => {
|
|
vi.stubGlobal("navigator", undefined);
|
|
const mod = await import("./keyboard");
|
|
|
|
expect(mod.isMac).toBe(false);
|
|
expect(mod.modKey).toBe("Ctrl");
|
|
});
|
|
});
|