Fix getBrowsePrefetchPaths tests to use reachable state combinations

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
This commit is contained in:
Cursor Agent committed 2026-04-17 05:43:59 +00:00
1 parent 11192b698d
commit f6ccddbfd3
1 file changed
+15 -5
@@ -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([]);
});
});