fix(sql): preserve file associations and list selection
This commit is contained in:
25 files changed
+558
-186
No files matched your search
@@ -0,0 +1,24 @@
|
||||
import { readFileSync } from "node:fs";
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
const panelSource = readFileSync(new URL("../SqlFilePanel.vue", import.meta.url), "utf8");
|
||||
|
||||
describe("SqlFilePanel selection", () => {
|
||||
it("uses the shared ordered-list selection behavior", () => {
|
||||
expect(panelSource).toContain("orderedListSelectionIntent(event)");
|
||||
expect(panelSource).toContain("orderedListRangeAnchorIndex(visibleItems.value");
|
||||
expect(panelSource).not.toContain("anchorIndex ?? 0");
|
||||
});
|
||||
|
||||
it("does not open or expand rows during modifier selection", () => {
|
||||
expect(panelSource).toMatch(/if \(selectionIntent === "range"\)[\s\S]*selectRangeTo\(currentIndex\);[\s\S]*return;/);
|
||||
expect(panelSource).toMatch(/if \(selectionIntent === "toggle"\)[\s\S]*selectionAnchorIndex\.value = currentIndex;[\s\S]*return;/);
|
||||
expect(panelSource).toMatch(/selectionAnchorIndex\.value = currentIndex;[\s\S]*activate\(\);/);
|
||||
});
|
||||
|
||||
it("clears selection when a non-row area is clicked", () => {
|
||||
expect(panelSource).toContain('@click="handlePanelClick"');
|
||||
expect(panelSource).toContain("[data-sql-file-row='true']");
|
||||
expect(panelSource).toContain('data-sql-file-row="true"');
|
||||
});
|
||||
});
|
||||
@@ -9,4 +9,21 @@ describe("SqlLibraryPanel selection contrast", () => {
|
||||
expect(panelSource).toMatch(/function fileMetaClass[\s\S]*\? "text-accent-foreground" : "text-muted-foreground";/);
|
||||
expect(panelSource).not.toContain('contextFile(fileId) ? "text-foreground/70"');
|
||||
});
|
||||
|
||||
it("lets a plain click reliably exit batch selection", () => {
|
||||
expect(panelSource).toMatch(/function handleDragMouseDown[\s\S]*if \(hasSelection\.value \|\| event\.shiftKey \|\| event\.metaKey \|\| event\.ctrlKey\) return;/);
|
||||
expect(panelSource).toMatch(/function handleFileClick[\s\S]*else \{[\s\S]*clearSelection\(\);[\s\S]*lastClickedItemIndex\.value = currentIndex;[\s\S]*setActiveItem\(file\.id, "file"\);/);
|
||||
expect(panelSource).toMatch(/function handleFolderClick[\s\S]*else \{[\s\S]*clearSelection\(\);[\s\S]*lastClickedItemIndex\.value = currentIndex;[\s\S]*setActiveItem\(folder\.id, "folder"\);/);
|
||||
});
|
||||
|
||||
it("clears row selection when the blank panel area is clicked", () => {
|
||||
expect(panelSource).toContain('@click.self="clearPanelSelection"');
|
||||
expect(panelSource).toMatch(/function clearPanelSelection[\s\S]*clearSelection\(\);[\s\S]*activeItemId\.value = null;[\s\S]*activeItemType\.value = null;/);
|
||||
});
|
||||
|
||||
it("does not use the first row as an implicit Shift selection anchor", () => {
|
||||
expect(panelSource).toContain("const anchorIndex = rangeAnchorIndex();");
|
||||
expect(panelSource).toMatch(/if \(anchorIndex === null\)[\s\S]*lastClickedItemIndex\.value = currentIndex;[\s\S]*return;/);
|
||||
expect(panelSource).not.toContain("lastClickedItemIndex.value ?? 0");
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user