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
167});167});
168 168
169describe("getBrowsePrefetchPaths", () => {169describe("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 expect(171 expect(
172 getBrowsePrefetchPaths({172 getBrowsePrefetchPaths({
173 browseQuery: "~/Downloads",173 browseQuery: "~/Downloads",
174 canBrowseUp: true,174 canBrowseUp: false,
175 exactEntry: {175 exactEntry: {
176 name: "Downloads",176 name: "Downloads",
177 fullPath: "/Users/test/Downloads",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 expect(184 expect(
185 getBrowsePrefetchPaths({185 getBrowsePrefetchPaths({
186 browseQuery: "~/Do",186 browseQuery: "~/Downloads/",
187 canBrowseUp: true,187 canBrowseUp: true,
188 exactEntry: null,188 exactEntry: null,
189 }),189 }),
190 ).toEqual(["~/"]);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});

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