fix(ci): sync frontend tests with grid changes

This commit is contained in:
t8y2 committed 2026-08-25 11:02:27 +08:00
1 parent 4be1928d15
commit 08365d73eb
8 files changed
+25 -10

No files matched your search

@@ -14,6 +14,7 @@ const mocks = vi.hoisted(() => ({
executeQuery: vi.fn(), executeQuery: vi.fn(),
listDataTypes: vi.fn(), listDataTypes: vi.fn(),
buildTableStructureChangeSql: vi.fn(), buildTableStructureChangeSql: vi.fn(),
buildMysqlAutoIncrementSql: vi.fn(),
updateEditorSettings: vi.fn(), updateEditorSettings: vi.fn(),
loadObjectDdl: vi.fn(), loadObjectDdl: vi.fn(),
invalidateObjectDdl: vi.fn(), invalidateObjectDdl: vi.fn(),
@@ -227,6 +228,7 @@ vi.mock("@/lib/backend/api", () => ({
executeQuery: mocks.executeQuery, executeQuery: mocks.executeQuery,
listDataTypes: mocks.listDataTypes, listDataTypes: mocks.listDataTypes,
buildTableStructureChangeSql: mocks.buildTableStructureChangeSql, buildTableStructureChangeSql: mocks.buildTableStructureChangeSql,
buildMysqlAutoIncrementSql: mocks.buildMysqlAutoIncrementSql,
buildTableOwnerChangeSql: mocks.buildTableOwnerChangeSql, buildTableOwnerChangeSql: mocks.buildTableOwnerChangeSql,
getTablePartitionStatus: mocks.getTablePartitionStatus, getTablePartitionStatus: mocks.getTablePartitionStatus,
getTableOwner: mocks.getTableOwner, getTableOwner: mocks.getTableOwner,
@@ -14,6 +14,7 @@ const mocks = vi.hoisted(() => ({
executeQuery: vi.fn(), executeQuery: vi.fn(),
listDataTypes: vi.fn(), listDataTypes: vi.fn(),
buildTableStructureChangeSql: vi.fn(), buildTableStructureChangeSql: vi.fn(),
buildMysqlAutoIncrementSql: vi.fn(),
updateEditorSettings: vi.fn(), updateEditorSettings: vi.fn(),
loadObjectDdl: vi.fn(), loadObjectDdl: vi.fn(),
invalidateObjectDdl: vi.fn(), invalidateObjectDdl: vi.fn(),
@@ -242,6 +243,7 @@ vi.mock("@/lib/backend/api", () => ({
executeQuery: mocks.executeQuery, executeQuery: mocks.executeQuery,
listDataTypes: mocks.listDataTypes, listDataTypes: mocks.listDataTypes,
buildTableStructureChangeSql: mocks.buildTableStructureChangeSql, buildTableStructureChangeSql: mocks.buildTableStructureChangeSql,
buildMysqlAutoIncrementSql: mocks.buildMysqlAutoIncrementSql,
buildTableOwnerChangeSql: mocks.buildTableOwnerChangeSql, buildTableOwnerChangeSql: mocks.buildTableOwnerChangeSql,
getTablePartitionStatus: mocks.getTablePartitionStatus, getTablePartitionStatus: mocks.getTablePartitionStatus,
getTableOwner: mocks.getTableOwner, getTableOwner: mocks.getTableOwner,
@@ -67,7 +67,16 @@ describe("gridSelection", () => {
["single cell", [[8]], 1, 1, 8], ["single cell", [[8]], 1, 1, 8],
["row", [[1, 3]], 2, 1, 2], ["row", [[1, 3]], 2, 1, 2],
["column", [[1], [3]], 2, 2, 2], ["column", [[1], [3]], 2, 2, 2],
["range", [[1, 2], [3, 4]], 4, 2, 2.5], [
"range",
[
[1, 2],
[3, 4],
],
4,
2,
2.5,
],
] as const)("averages a %s selection without changing its counts", (_label, rows, cellCount, rowCount, average) => { ] as const)("averages a %s selection without changing its counts", (_label, rows, cellCount, rowCount, average) => {
expect(summarizeSelection({ columns: [], rows: rows.map((row) => [...row]) })).toMatchObject({ cellCount, rowCount, average }); expect(summarizeSelection({ columns: [], rows: rows.map((row) => [...row]) })).toMatchObject({ cellCount, rowCount, average });
}); });
@@ -97,9 +97,9 @@ describe("keyboard shortcut matching", () => {
}); });
it("matches only the configured go-to-column shortcut", () => { it("matches only the configured go-to-column shortcut", () => {
expect(isGoToColumnShortcut({ key: "g", ctrlKey: true }, { goToColumn: "Mod+G" })).toBe(true); expect(isGoToColumnShortcut({ key: "g", ctrlKey: true }, { goToColumn: "Mod+G" }, "Win32")).toBe(true);
expect(isGoToColumnShortcut({ key: "g", ctrlKey: true, shiftKey: true }, { goToColumn: "Mod+G" })).toBe(false); expect(isGoToColumnShortcut({ key: "g", ctrlKey: true, shiftKey: true }, { goToColumn: "Mod+G" }, "Win32")).toBe(false);
expect(isGoToColumnShortcut({ key: "j", ctrlKey: true }, { goToColumn: "Mod+G" })).toBe(false); expect(isGoToColumnShortcut({ key: "j", ctrlKey: true }, { goToColumn: "Mod+G" }, "Win32")).toBe(false);
}); });
it("does not match an empty or composing go-to-column shortcut", () => { it("does not match an empty or composing go-to-column shortcut", () => {
@@ -211,8 +211,8 @@ export function isDeleteCurrentRowShortcut(event: ShortcutLikeEvent, shortcuts?:
return matchesShortcut(event, actionShortcut("deleteCurrentRow", shortcuts)); return matchesShortcut(event, actionShortcut("deleteCurrentRow", shortcuts));
} }
export function isGoToColumnShortcut(event: ShortcutLikeEvent, shortcuts?: Partial<ShortcutSettings>): boolean { export function isGoToColumnShortcut(event: ShortcutLikeEvent, shortcuts?: Partial<ShortcutSettings>, platform = globalThis.navigator?.platform || ""): boolean {
return matchesShortcut(event, actionShortcut("goToColumn", shortcuts)); return matchesShortcut(event, actionShortcut("goToColumn", shortcuts, platform), platform);
} }
export function isGoToFirstPageShortcut(event: ShortcutLikeEvent, shortcuts?: Partial<ShortcutSettings>): boolean { export function isGoToFirstPageShortcut(event: ShortcutLikeEvent, shortcuts?: Partial<ShortcutSettings>): boolean {
+1 -1
View File
@@ -47,7 +47,7 @@ test("DataGrid forwards hover action reservation only for right-aligned canvas c
const source = readFileSync("apps/desktop/src/components/grid/DataGrid.vue", "utf8"); const source = readFileSync("apps/desktop/src/components/grid/DataGrid.vue", "utf8");
assert.match(source, /columnAligns\.value\[cell\.visibleColIdx\] !== "right"/); assert.match(source, /columnAligns\.value\[cell\.visibleColIdx\] !== "right"/);
assert.match(source, /reservedWidth: canvasDataGridActionReservedWidth\(cell\.canQuickDownload, !!cell\.foreignKey\)/); assert.match(source, /reservedWidth: canvasDataGridActionReservedWidth\(cell\.canQuickDownload, !!cell\.foreignKey, cellDetailButtonEnabled\.value\)/);
assert.match(source, /rightAlignedActionCell: canvasRightAlignedActionCell\.value/); assert.match(source, /rightAlignedActionCell: canvasRightAlignedActionCell\.value/);
}); });
+3 -2
View File
@@ -392,8 +392,9 @@ test("matches Cmd+S for saving", () => {
assert.equal(isSaveShortcut({ key: "s", metaKey: true }), true); assert.equal(isSaveShortcut({ key: "s", metaKey: true }), true);
}); });
test("matches Mod+D for copying current row", () => { test("leaves copy current row disabled by default while honoring custom shortcuts", () => {
assert.equal(isCopyCurrentRowShortcut({ key: "d", metaKey: true }), true); assert.equal(isCopyCurrentRowShortcut({ key: "d", metaKey: true }), false);
assert.equal(isCopyCurrentRowShortcut({ key: "d", altKey: true }, { copyCurrentRow: "Alt+D" }), true);
}); });
test("matches Delete for deleting current row", () => { test("matches Delete for deleting current row", () => {
+2 -1
View File
@@ -390,7 +390,8 @@ test("defaults shortcut settings", () => {
assert.equal(settings.shortcuts.executeSql, "Mod+Enter"); assert.equal(settings.shortcuts.executeSql, "Mod+Enter");
assert.equal(settings.shortcuts.saveSql, "Mod+S"); assert.equal(settings.shortcuts.saveSql, "Mod+S");
assert.equal(settings.shortcuts.extendSelection, "Alt+W"); assert.equal(settings.shortcuts.extendSelection, "Alt+W");
assert.equal(settings.shortcuts.copyCurrentRow, "Mod+D"); assert.equal(settings.shortcuts.editTableStructure, "Mod+D");
assert.equal(settings.shortcuts.copyCurrentRow, "");
assert.equal(settings.shortcuts.deleteCurrentRow, "Delete"); assert.equal(settings.shortcuts.deleteCurrentRow, "Delete");
assert.equal(settings.shortcuts.goToFirstPage, ""); assert.equal(settings.shortcuts.goToFirstPage, "");
assert.equal(settings.shortcuts.goToPreviousPage, ""); assert.equal(settings.shortcuts.goToPreviousPage, "");