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
Unified · Split
| @@ -167,26 +167,36 @@ describe("buildThreadActionItems", () => { · 166 unmodified lines | ||
| 167 | 167 | }); |
| 168 | 168 | |
| 169 | 169 | describe("getBrowsePrefetchPaths", () => { |
| 170 | − it("prefetches the parent path and an exact typed child path", () => { | |
| 170 | + it("prefetches child path when query has no trailing separator and an exact entry matches", () => { | |
| 171 | 171 | expect( |
| 172 | 172 | getBrowsePrefetchPaths({ |
| 173 | 173 | browseQuery: "~/Downloads", |
| 174 | − canBrowseUp: true, | |
| 174 | + canBrowseUp: false, | |
| 175 | 175 | exactEntry: { |
| 176 | 176 | name: "Downloads", |
| 177 | 177 | fullPath: "/Users/test/Downloads", |
| 178 | 178 | }, |
| 179 | 179 | }), |
| 180 | − ).toEqual(["~/", "~/Downloads/"]); | |
| 180 | + ).toEqual(["~/Downloads/"]); | |
| 181 | 181 | }); |
| 182 | 182 | |
| 183 | − it("does not prefetch a child path when the user only has a highlighted browse row", () => { | |
| 183 | + it("prefetches parent path when query has a trailing separator", () => { | |
| 184 | 184 | expect( |
| 185 | 185 | getBrowsePrefetchPaths({ |
| 186 | − browseQuery: "~/Do", | |
| 186 | + browseQuery: "~/Downloads/", | |
| 187 | 187 | canBrowseUp: true, |
| 188 | 188 | exactEntry: null, |
| 189 | 189 | }), |
| 190 | 190 | ).toEqual(["~/"]); |
| 191 | 191 | }); |
| 192 | + | |
| 193 | + it("returns no paths for a partial query with no exact match", () => { | |
| 194 | + expect( | |
| 195 | + getBrowsePrefetchPaths({ | |
| 196 | + browseQuery: "~/Do", | |
| 197 | + canBrowseUp: false, | |
| 198 | + exactEntry: null, | |
| 199 | + }), | |
| 200 | + ).toEqual([]); | |
| 201 | + }); | |
| 192 | 202 | }); |