- Implemented command palette with keyboard shortcut (⌘K) for opening. - Added commands for opening, closing, setting query, and selecting items in the command palette. - Created tests for command palette commands and input handling. - Enhanced layer actions with functions for adding, grouping, and deleting layers. - Updated UI components to integrate command palette and shortcuts.
29 lines
1.0 KiB
TypeScript
29 lines
1.0 KiB
TypeScript
import { describe, expect, test } from "bun:test";
|
|
import { commandIds } from "@commands/ids";
|
|
import { handleCommandPaletteKey } from "./command-palette";
|
|
|
|
describe("command palette input", () => {
|
|
test("opens the command palette with the platform shortcut", () => {
|
|
const dispatched: unknown[] = [];
|
|
const consumed = handleCommandPaletteKey({
|
|
event: { key: "k", code: "KeyK", altKey: false, ctrlKey: false, metaKey: true, shiftKey: false },
|
|
dispatch: (commandId, payload) => {
|
|
dispatched.push({ commandId, payload });
|
|
return undefined as never;
|
|
},
|
|
});
|
|
|
|
expect(consumed).toBe(true);
|
|
expect(dispatched).toEqual([{ commandId: commandIds.commandPaletteOpen, payload: undefined }]);
|
|
});
|
|
|
|
test("ignores unmodified K so the chroma key tool keeps its shortcut", () => {
|
|
const consumed = handleCommandPaletteKey({
|
|
event: { key: "k", code: "KeyK", altKey: false, ctrlKey: false, metaKey: false, shiftKey: false },
|
|
dispatch: () => undefined as never,
|
|
});
|
|
|
|
expect(consumed).toBe(false);
|
|
});
|
|
});
|