fix(sql-library): hydrate restored tabs after startup
This commit is contained in:
3 files changed
+48
-2
No files matched your search
@@ -65,11 +65,13 @@ test("web startup uses the guarded initializer behind the existing authenticatio
|
||||
const webInitialization = initAppSource.indexOf("await initializeOpenTabs({");
|
||||
const optionalInitialization = initAppSource.indexOf("initializeOptionalState: () => settingsStore.initAiConfigs()", webInitialization);
|
||||
const requiredRestoration = initAppSource.indexOf("restoreOpenTabs,", optionalInitialization);
|
||||
const savedSqlHydration = initAppSource.indexOf("queryStore.hydrateSavedSqlTabs()", requiredRestoration);
|
||||
assert.ok(savedSqlInitialization >= 0);
|
||||
assert.ok(webInitialization >= 0);
|
||||
assert.ok(savedSqlInitialization < webInitialization);
|
||||
assert.ok(optionalInitialization > webInitialization);
|
||||
assert.ok(requiredRestoration > optionalInitialization);
|
||||
assert.ok(savedSqlHydration > requiredRestoration);
|
||||
assert.equal(initAppSource.includes("if (!desktopOpenTabsRestorationBarrier) await settingsStore.initAiConfigs()"), false);
|
||||
|
||||
const mountedStart = appSource.indexOf("onMounted(async () =>");
|
||||
|
||||
+36
@@ -379,6 +379,42 @@ test("clean saved SQL tabs persist without duplicating SQL text", async () => {
|
||||
}
|
||||
});
|
||||
|
||||
test("clean saved SQL tabs hydrate after their tabs finish restoring", async () => {
|
||||
const restoreStorage = installMemoryStorage();
|
||||
const fullFile = {
|
||||
id: "saved-startup-race",
|
||||
connectionId: "conn-1",
|
||||
name: "startup.sql",
|
||||
database: "db",
|
||||
sql: "SELECT 1;",
|
||||
sqlLoaded: true,
|
||||
createdAt: "2026-09-27T00:00:00.000Z",
|
||||
updatedAt: "2026-09-27T00:00:00.000Z",
|
||||
};
|
||||
try {
|
||||
setActivePinia(createPinia());
|
||||
let store = useQueryStore();
|
||||
store.openSavedSql(fullFile);
|
||||
await store.flushPendingPersist();
|
||||
|
||||
disposePinia(getActivePinia()!);
|
||||
setActivePinia(createPinia());
|
||||
store = useQueryStore();
|
||||
const savedSqlStore = useSavedSqlStore();
|
||||
savedSqlStore.files = [fullFile];
|
||||
|
||||
await store.hydrateSavedSqlTabs();
|
||||
await store.initOpenTabs();
|
||||
await store.hydrateSavedSqlTabs();
|
||||
|
||||
const restored = store.tabs.find((tab) => tab.savedSqlId === fullFile.id);
|
||||
assert.equal(restored?.sql, fullFile.sql);
|
||||
assert.equal(restored?.originalSql, fullFile.sql);
|
||||
} finally {
|
||||
restoreStorage();
|
||||
}
|
||||
});
|
||||
|
||||
test("saved SQL opens with its saved execution target by default", async () => {
|
||||
const restoreStorage = installMemoryStorage();
|
||||
try {
|
||||
|
||||
Reference in new issue
Block a user