History

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

Cursor Agent committed 7 months ago

Commit f6ccddb1 parent 11192b61 file · +15 −5Browse files

Unified · Split

apps/web/src/components/CommandPalette.logic.test.ts+15−5
@@ -167,26 +167,36 @@ describe("buildThreadActionItems", () => { · 166 unmodified lines
167167 });
168168
169169 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", () => {
171171 expect(
172172 getBrowsePrefetchPaths({
173173 browseQuery: "~/Downloads",
174− canBrowseUp: true,
174+ canBrowseUp: false,
175175 exactEntry: {
176176 name: "Downloads",
177177 fullPath: "/Users/test/Downloads",
178178 },
179179 }),
180− ).toEqual(["~/", "~/Downloads/"]);
180+ ).toEqual(["~/Downloads/"]);
181181 });
182182
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", () => {
184184 expect(
185185 getBrowsePrefetchPaths({
186− browseQuery: "~/Do",
186+ browseQuery: "~/Downloads/",
187187 canBrowseUp: true,
188188 exactEntry: null,
189189 }),
190190 ).toEqual(["~/"]);
191191 });
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+ });
192202 });

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t