From 2a696be49a4c76721a407bb0928c4dd6453ea73e Mon Sep 17 00:00:00 2001 From: t8y2 <1156263951@qq.com> Date: Sat, 30 May 2026 16:58:19 +0800 Subject: [PATCH] fix(test): update sidebar target test for query-context type Query tabs now return a query-context target so the locate-in-sidebar button can find and expand the matching database or schema node. --- .../app-tests/sidebarActiveTabTarget.test.ts | 23 ++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/packages/app-tests/sidebarActiveTabTarget.test.ts b/packages/app-tests/sidebarActiveTabTarget.test.ts index 979151c5d..469c3263b 100644 --- a/packages/app-tests/sidebarActiveTabTarget.test.ts +++ b/packages/app-tests/sidebarActiveTabTarget.test.ts @@ -81,7 +81,7 @@ test("saved SQL tabs target the matching visible saved SQL file node", () => { assert.equal(findSidebarNodeForActiveTab(tab, [flat(file)])?.id, "file-node"); }); -test("query tabs without a saved SQL file have no sidebar target", () => { +test("query tabs target their database node in the sidebar", () => { const tab: QueryTab = { id: "tab-1", title: "Query 1", @@ -92,10 +92,27 @@ test("query tabs without a saved SQL file have no sidebar target", () => { mode: "query", }; - assert.equal(activeTabSidebarTarget(tab), null); - assert.equal(findSidebarNodeForActiveTab(tab, []), null); + assert.deepEqual(activeTabSidebarTarget(tab), { + type: "query-context", + connectionId: "conn-1", + database: "app", + schema: undefined, + }); }); +test("query tabs without connectionId have no sidebar target", () => { + const tab: QueryTab = { + id: "tab-1", + title: "Query 1", + connectionId: "", + database: "", + sql: "select 1", + isExecuting: false, + mode: "query", + }; + + assert.equal(activeTabSidebarTarget(tab), null); +}); test("sidebar target lookup only uses the current flat visible tree", () => { const tab: QueryTab = { id: "tab-1",