From f6ccddbfd36ae05be24e73ad018dcab93d882d34 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Fri, 17 Apr 2026 05:43:59 +0000 Subject: [PATCH] Fix getBrowsePrefetchPaths tests to use reachable state combinations MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The tests were passing canBrowseUp: true for queries without trailing path separators, but in the actual CommandPalette.tsx code, canBrowseUp is computed via canNavigateUp(query) which requires hasTrailingPathSeparator(query). This made canBrowseUp: true and non-null exactEntry mutually exclusive conditions that could never occur together. Updated tests to reflect realistic scenarios: - No trailing separator + exact entry match → prefetch child path only - Trailing separator + no exact entry → prefetch parent path only - Partial query with no match → no prefetch paths --- .../components/CommandPalette.logic.test.ts | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/apps/web/src/components/CommandPalette.logic.test.ts b/apps/web/src/components/CommandPalette.logic.test.ts index 4517d18a1e..4e3a9293ed 100644 --- a/apps/web/src/components/CommandPalette.logic.test.ts +++ b/apps/web/src/components/CommandPalette.logic.test.ts @@ -167,26 +167,36 @@ describe("buildThreadActionItems", () => { }); describe("getBrowsePrefetchPaths", () => { - it("prefetches the parent path and an exact typed child path", () => { + it("prefetches child path when query has no trailing separator and an exact entry matches", () => { expect( getBrowsePrefetchPaths({ browseQuery: "~/Downloads", - canBrowseUp: true, + canBrowseUp: false, exactEntry: { name: "Downloads", fullPath: "/Users/test/Downloads", }, }), - ).toEqual(["~/", "~/Downloads/"]); + ).toEqual(["~/Downloads/"]); }); - it("does not prefetch a child path when the user only has a highlighted browse row", () => { + it("prefetches parent path when query has a trailing separator", () => { expect( getBrowsePrefetchPaths({ - browseQuery: "~/Do", + browseQuery: "~/Downloads/", canBrowseUp: true, exactEntry: null, }), ).toEqual(["~/"]); }); + + it("returns no paths for a partial query with no exact match", () => { + expect( + getBrowsePrefetchPaths({ + browseQuery: "~/Do", + canBrowseUp: false, + exactEntry: null, + }), + ).toEqual([]); + }); });