1 parent
2f464e0d33
commit
44dc2a88f8
14 files changed
+334
-2
No files matched your search
@@ -2,6 +2,7 @@ import { describe, expect, it } from "vitest";
|
||||
import {
|
||||
eventToModifierOnlyShortcut,
|
||||
eventToShortcut,
|
||||
isEditTableStructureShortcut,
|
||||
isExecuteSqlInNewResultTabShortcut,
|
||||
isGoToColumnShortcut,
|
||||
isGoToFirstPageShortcut,
|
||||
@@ -107,6 +108,19 @@ describe("keyboard shortcut matching", () => {
|
||||
expect(isGoToColumnShortcut({ key: "g", ctrlKey: true, isComposing: true }, { goToColumn: "Mod+G" })).toBe(false);
|
||||
});
|
||||
|
||||
it("matches the edit-table-structure shortcut on Windows and macOS", () => {
|
||||
expect(isEditTableStructureShortcut({ key: "d", ctrlKey: true }, undefined, "Win32")).toBe(true);
|
||||
expect(isEditTableStructureShortcut({ key: "d", metaKey: true }, undefined, "MacIntel")).toBe(true);
|
||||
expect(isEditTableStructureShortcut({ key: "d", ctrlKey: true }, undefined, "MacIntel")).toBe(false);
|
||||
});
|
||||
|
||||
it("honors custom and disabled edit-table-structure shortcuts", () => {
|
||||
expect(isEditTableStructureShortcut({ key: "e", ctrlKey: true, shiftKey: true }, { editTableStructure: "Shift+Mod+E" }, "Win32")).toBe(true);
|
||||
expect(isEditTableStructureShortcut({ key: "d", ctrlKey: true }, { editTableStructure: "Shift+Mod+E" }, "Win32")).toBe(false);
|
||||
expect(isEditTableStructureShortcut({ key: "d", ctrlKey: true }, { editTableStructure: "" }, "Win32")).toBe(false);
|
||||
expect(isEditTableStructureShortcut({ key: "d", ctrlKey: true, isComposing: true }, undefined, "Win32")).toBe(false);
|
||||
});
|
||||
|
||||
it.each([
|
||||
["goToFirstPage", isGoToFirstPageShortcut, "F1"],
|
||||
["goToPreviousPage", isGoToPreviousPageShortcut, "F2"],
|
||||
|
||||
@@ -83,10 +83,32 @@ describe("shortcutRegistry editor actions", () => {
|
||||
it("detects go-to-column conflicts only within the grid scope", () => {
|
||||
const shortcuts = normalizeShortcutSettings({ goToColumn: "Mod+D" });
|
||||
|
||||
expect(findShortcutConflict("goToColumn", shortcuts.goToColumn, shortcuts)).toBe("copyCurrentRow");
|
||||
expect(findShortcutConflict("goToColumn", shortcuts.goToColumn, shortcuts)).toBe("editTableStructure");
|
||||
expect(findShortcutConflict("goToColumn", "Mod+F", shortcuts)).toBeNull();
|
||||
});
|
||||
|
||||
it("registers edit table structure as the conflict-free default Mod+D grid action", () => {
|
||||
const definition = SHORTCUT_DEFINITIONS.find((item) => item.id === "editTableStructure");
|
||||
|
||||
expect(definition).toMatchObject({
|
||||
labelKey: "settings.shortcutEditTableStructure",
|
||||
scope: "grid",
|
||||
defaultShortcut: "Mod+D",
|
||||
});
|
||||
expect(DEFAULT_SHORTCUT_SETTINGS.editTableStructure).toBe("Mod+D");
|
||||
expect(DEFAULT_SHORTCUT_SETTINGS.copyCurrentRow).toBe("");
|
||||
expect(findShortcutConflict("editTableStructure", DEFAULT_SHORTCUT_SETTINGS.editTableStructure, DEFAULT_SHORTCUT_SETTINGS)).toBeNull();
|
||||
expect(findShortcutConflict("duplicateLine", DEFAULT_SHORTCUT_SETTINGS.duplicateLine, DEFAULT_SHORTCUT_SETTINGS)).toBeNull();
|
||||
});
|
||||
|
||||
it("migrates the legacy copy-row Mod+D default without overwriting explicit shortcuts", () => {
|
||||
expect(normalizeShortcutSettings()).toMatchObject({ editTableStructure: "Mod+D", copyCurrentRow: "" });
|
||||
expect(normalizeShortcutSettings({ copyCurrentRow: "Mod+D" })).toMatchObject({ editTableStructure: "Mod+D", copyCurrentRow: "" });
|
||||
expect(normalizeShortcutSettings({ copyCurrentRow: "Shift+Mod+C" })).toMatchObject({ editTableStructure: "Mod+D", copyCurrentRow: "Shift+Mod+C" });
|
||||
expect(normalizeShortcutSettings({ editTableStructure: "", copyCurrentRow: "Mod+D" })).toMatchObject({ editTableStructure: "", copyCurrentRow: "Mod+D" });
|
||||
expect(normalizeShortcutSettings({ editTableStructure: "Shift+Mod+D", copyCurrentRow: "Mod+D" })).toMatchObject({ editTableStructure: "Shift+Mod+D", copyCurrentRow: "Mod+D" });
|
||||
});
|
||||
|
||||
it("registers the new-data-tab mouse modifier as a configurable sidebar shortcut", () => {
|
||||
const definition = SHORTCUT_DEFINITIONS.find((item) => item.id === "openDataInNewTab");
|
||||
|
||||
|
||||
Reference in new issue
Block a user