Q189: search says how many match, pages through all of them, and says when nothing matches
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
1b7106d511
commit
bc7e214b65
12 files changed
+163
-27
No files matched your search
@@ -0,0 +1,17 @@
|
||||
import { describe, expect, test } from "vitest";
|
||||
import { withNextPage, type SearchAnswer } from "../../src/renderer/src/shared/search-pages";
|
||||
|
||||
const hit = (id: string) => ({ entityType: "task" as const, entityId: id, title: id, preview: "", facets: {} });
|
||||
|
||||
describe("search pages", () => {
|
||||
test("a later page joins its own answer; a success after a failure clears the failure", () => {
|
||||
const shown: SearchAnswer = { key: "org|all|lantern", results: [hit("a")], total: 3, error: null };
|
||||
const failed = withNextPage(shown, "org|all|lantern", { error: "IPC failed" });
|
||||
expect(failed).toEqual({ ...shown, error: "IPC failed" });
|
||||
const recovered = withNextPage(failed, "org|all|lantern", { page: { results: [hit("b"), hit("c")], total: 3 } });
|
||||
expect(recovered).toEqual({ key: "org|all|lantern", results: [hit("a"), hit("b"), hit("c")], total: 3, error: null });
|
||||
// A page asked for other words never lands in this answer.
|
||||
expect(withNextPage(recovered, "org|all|other", { page: { results: [hit("z")], total: 9 } })).toBe(recovered);
|
||||
expect(withNextPage(null, "org|all|lantern", { page: { results: [hit("z")], total: 1 } })).toBeNull();
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user