Skip to content

Commit af0aefc

Browse files
only21milclaude
andcommitted
test(server): assert the refreshed live finder answers the second search
The refresh regression test only checked that the second search matched. It now also checks that one finder was created and rescanned once, so the match comes from the live index after a timed-out refresh wait rather than from a rebuild. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent e9adc6c commit af0aefc

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

‎apps/server/src/workspace/WorkspaceEntries.test.ts‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -576,11 +576,19 @@ it.layer(layerTest, { excludeTestServices: true })("WorkspaceEntries", (it) => {
576576
const cwd = yield* makeTempDir({ prefix: "t3code-workspace-content-refresh-" });
577577
yield* writeTextFile(cwd, "src/notes.ts", "const needle = 1;\n");
578578
let scansOutlastWait = false;
579+
let finders = 0;
580+
let rescans = 0;
579581
const createFinder = FileFinder.create.bind(FileFinder);
580582
vi.spyOn(FileFinder, "create").mockImplementation((options) => {
581583
const created = createFinder(options);
582584
if (created.ok) {
583585
const finder = created.value;
586+
finders += 1;
587+
const scanFiles = finder.scanFiles.bind(finder);
588+
finder.scanFiles = () => {
589+
rescans += 1;
590+
return scanFiles();
591+
};
584592
const waitForIndexReady = finder.waitForIndexReady.bind(finder);
585593
finder.waitForIndexReady = (timeoutMs) =>
586594
scansOutlastWait
@@ -605,6 +613,8 @@ it.layer(layerTest, { excludeTestServices: true })("WorkspaceEntries", (it) => {
605613
const result = yield* searchNeedle;
606614

607615
expect(result.matches.map((match) => match.path)).toEqual(["src/notes.ts"]);
616+
// The second search ran on the rescanned live finder, not a rebuild.
617+
expect({ finders, rescans }).toEqual({ finders: 1, rescans: 1 });
608618
}),
609619
);
610620
});

0 commit comments

Comments
 (0)