1 parent
fbaf556f3a
commit
4768dbb99a
19 files changed
+192
-7
No files matched your search
@@ -59,6 +59,28 @@ describe("queryStore switchTab", () => {
|
||||
expect(queryStore.activeTabId).toBe(tab2Id);
|
||||
});
|
||||
|
||||
it("inserts a tab after the active tab only when explicitly requested", async () => {
|
||||
const queryStore = useQueryStore();
|
||||
const firstId = queryStore.createTab("pg-1", "app", "Query 1", "query");
|
||||
const trailingId = queryStore.createTab("pg-1", "app", "Query 2", "query");
|
||||
queryStore.switchTab(firstId);
|
||||
|
||||
const dataId = queryStore.createTab("pg-1", "app", "users", "data", "public", undefined, undefined, { forceNew: true, insertAfterActive: true });
|
||||
const appendedId = queryStore.createTab("pg-1", "app", "Query 3", "query", undefined, undefined, undefined, { forceNew: true });
|
||||
|
||||
expect(queryStore.tabs.map((tab) => tab.id)).toEqual([firstId, dataId, trailingId, appendedId]);
|
||||
});
|
||||
|
||||
it("appends when adjacent insertion has no valid active tab", async () => {
|
||||
const queryStore = useQueryStore();
|
||||
const firstId = queryStore.createTab("pg-1", "app", "Query 1", "query");
|
||||
queryStore.activeTabId = "missing-tab";
|
||||
|
||||
const dataId = queryStore.createTab("pg-1", "app", "users", "data", "public", undefined, undefined, { forceNew: true, insertAfterActive: true });
|
||||
|
||||
expect(queryStore.tabs.map((tab) => tab.id)).toEqual([firstId, dataId]);
|
||||
});
|
||||
|
||||
it("deactivates settings page when reopening an existing special tab", async () => {
|
||||
const { useQueryStore } = await import("@/stores/queryStore");
|
||||
const { useSettingsStore } = await import("@/stores/settingsStore");
|
||||
|
||||
@@ -28,6 +28,14 @@ describe("normalizeEditorSettings", () => {
|
||||
expect(normalizeEditorSettings({ reuseDataTab: true } as any).dataTabReuseMode).toBe("same-table");
|
||||
});
|
||||
|
||||
it("keeps adjacent data-tab opening disabled unless explicitly enabled", () => {
|
||||
expect(normalizeEditorSettings({}).openDataTabsNextToActive).toBe(false);
|
||||
expect(normalizeEditorSettings({ openDataTabsNextToActive: true }).openDataTabsNextToActive).toBe(true);
|
||||
expect(normalizeEditorSettings({ openDataTabsNextToActive: false }).openDataTabsNextToActive).toBe(false);
|
||||
expect(normalizeEditorSettings({ openDataTabsNextToActive: "true" } as any).openDataTabsNextToActive).toBe(false);
|
||||
expect(normalizeEditorSettings({ openDataTabsNextToActive: null } as any).openDataTabsNextToActive).toBe(false);
|
||||
});
|
||||
|
||||
it("defaults and bounds the regular expression match limit", () => {
|
||||
expect(normalizeEditorSettings({}).regexMaxMatchCount).toBe(1000);
|
||||
expect(normalizeEditorSettings({ regexMaxMatchCount: 2500 }).regexMaxMatchCount).toBe(2500);
|
||||
@@ -663,6 +671,23 @@ describe("settingsStore persisted settings initialization", () => {
|
||||
);
|
||||
});
|
||||
|
||||
it("loads and persists adjacent data-tab opening", async () => {
|
||||
const loadEditorSettings = vi.fn().mockResolvedValue({ openDataTabsNextToActive: true });
|
||||
const saveEditorSettings = vi.fn().mockResolvedValue(undefined);
|
||||
vi.doMock("@/lib/backend/api", () => ({ loadEditorSettings, saveEditorSettings }));
|
||||
|
||||
const { useSettingsStore } = await import("@/stores/settingsStore");
|
||||
const store = useSettingsStore();
|
||||
await store.initEditorSettings();
|
||||
|
||||
expect(store.editorSettings.openDataTabsNextToActive).toBe(true);
|
||||
|
||||
await store.updateEditorSettingsAndPersist({ openDataTabsNextToActive: false });
|
||||
|
||||
expect(store.editorSettings.openDataTabsNextToActive).toBe(false);
|
||||
expect(saveEditorSettings).toHaveBeenLastCalledWith(expect.objectContaining({ openDataTabsNextToActive: false }));
|
||||
});
|
||||
|
||||
it("shares concurrent initialization and applies startup changes after saved settings load", async () => {
|
||||
let resolveLoad!: (value: unknown) => void;
|
||||
const loadEditorSettings = vi.fn(
|
||||
|
||||
Reference in new issue
Block a user