77} from "@ff-labs/fff-node" ;
88import { afterEach , expect , it } from "@effect/vitest" ;
99import * as Effect from "effect/Effect" ;
10- import * as TestClock from "effect/testing/TestClock" ;
1110import { vi } from "vite-plus/test" ;
1211
1312import * as WorkspaceSearchIndex from "./WorkspaceSearchIndex.ts" ;
@@ -29,44 +28,6 @@ function fileItem(relativePath: string): FileItem {
2928 } ;
3029}
3130
32- it . effect ( "reads never rescan after the former recovery interval" , ( ) =>
33- Effect . scoped (
34- Effect . gen ( function * ( ) {
35- const scanFiles = vi . fn ( ( ) => ( { ok : true as const , value : undefined } ) ) ;
36- const finder = {
37- destroy : vi . fn ( ) ,
38- waitForIndexReady : vi . fn ( async ( ) => ( { ok : true as const , value : true } ) ) ,
39- scanFiles,
40- mixedSearch : ( ) => ( { ok : true as const , value : { items : [ ] , totalMatched : 0 } } ) ,
41- fileSearch : ( ) => ( {
42- ok : true as const ,
43- value : { items : [ fileItem ( "watched.ts" ) ] , scores : [ ] , totalMatched : 1 , totalFiles : 1 } ,
44- } ) ,
45- grep : ( ) => ( { ok : true as const , value : { items : [ ] , nextCursor : null } } ) ,
46- } as unknown as FileFinder ;
47- vi . spyOn ( FileFinder , "create" ) . mockReturnValueOnce ( { ok : true , value : finder } ) ;
48- const index = yield * WorkspaceSearchIndex . make ( "/workspace/project" ) ;
49- yield * TestClock . adjust ( "10 minutes" ) ;
50- expect ( yield * index . list ( ) ) . toEqual ( { entries : [ ] , truncated : false } ) ;
51- expect ( ( yield * index . search ( "" , 10 , "file" ) ) . entries ) . toEqual ( [
52- { path : "watched.ts" , kind : "file" } ,
53- ] ) ;
54- expect (
55- yield * index . searchContents ( {
56- query : "needle" ,
57- limit : 1 ,
58- caseSensitive : true ,
59- wholeWord : false ,
60- useRegex : false ,
61- } ) ,
62- ) . toEqual ( { matches : [ ] , truncated : false } ) ;
63- expect ( scanFiles ) . not . toHaveBeenCalled ( ) ;
64- yield * index . refresh ( ) ;
65- expect ( scanFiles ) . toHaveBeenCalledTimes ( 1 ) ;
66- } ) ,
67- ) ,
68- ) ;
69-
7031it . effect ( "filters image searches before applying the result limit" , ( ) =>
7132 Effect . scoped (
7233 Effect . gen ( function * ( ) {
0 commit comments