@@ -23,6 +23,9 @@ const svc = {
2323 create ( input ?: SessionNs . CreateInput ) {
2424 return run ( SessionNs . Service . use ( ( svc ) => svc . create ( input ) ) )
2525 } ,
26+ list ( input ?: SessionNs . ListInput ) {
27+ return run ( SessionNs . Service . use ( ( svc ) => svc . list ( input ) ) )
28+ } ,
2629}
2730
2831afterEach ( async ( ) => {
@@ -55,7 +58,7 @@ describe("session.list", () => {
5558 fn : async ( ) => svc . create ( { title : "sibling" } ) ,
5659 } )
5760
58- const ids = [ ... svc . list ( ) ] . map ( ( s ) => s . id )
61+ const ids = ( await svc . list ( ) ) . map ( ( s ) => s . id )
5962 expect ( ids ) . toContain ( root . id )
6063 expect ( ids ) . toContain ( parent . id )
6164 expect ( ids ) . toContain ( current . id )
@@ -88,7 +91,7 @@ describe("session.list", () => {
8891 fn : async ( ) => svc . create ( { title : "sibling" } ) ,
8992 } )
9093
91- const ids = [ ... svc . list ( { directory : path . join ( tmp . path , "packages" , "opencode" ) } ) ] . map ( ( s ) => s . id )
94+ const ids = ( await svc . list ( { directory : path . join ( tmp . path , "packages" , "opencode" ) } ) ) . map ( ( s ) => s . id )
9295 expect ( ids ) . not . toContain ( root . id )
9396 expect ( ids ) . not . toContain ( parent . id )
9497 expect ( ids ) . toContain ( current . id )
@@ -123,9 +126,12 @@ describe("session.list", () => {
123126 fn : async ( ) => svc . create ( { title : "sibling" } ) ,
124127 } )
125128
126- const pathIDs = [
127- ...svc . list ( { directory : path . join ( tmp . path , "packages" , "app" ) , path : "packages/opencode/src" } ) ,
128- ] . map ( ( s ) => s . id )
129+ const pathIDs = (
130+ await svc . list ( {
131+ directory : path . join ( tmp . path , "packages" , "app" ) ,
132+ path : "packages/opencode/src" ,
133+ } )
134+ ) . map ( ( s ) => s . id )
129135 expect ( pathIDs ) . not . toContain ( parent . id )
130136 expect ( pathIDs ) . toContain ( current . id )
131137 expect ( pathIDs ) . toContain ( deeper . id )
@@ -155,9 +161,12 @@ describe("session.list", () => {
155161 Database . use ( ( db ) => db . update ( SessionTable ) . set ( { path : null } ) . where ( eq ( SessionTable . id , current . id ) ) . run ( ) )
156162 Database . use ( ( db ) => db . update ( SessionTable ) . set ( { path : null } ) . where ( eq ( SessionTable . id , sibling . id ) ) . run ( ) )
157163
158- const pathIDs = [
159- ...svc . list ( { directory : path . join ( tmp . path , "packages" , "opencode" , "src" ) , path : "packages/opencode/src" } ) ,
160- ] . map ( ( s ) => s . id )
164+ const pathIDs = (
165+ await svc . list ( {
166+ directory : path . join ( tmp . path , "packages" , "opencode" , "src" ) ,
167+ path : "packages/opencode/src" ,
168+ } )
169+ ) . map ( ( s ) => s . id )
161170 expect ( pathIDs ) . toContain ( current . id )
162171 expect ( pathIDs ) . not . toContain ( sibling . id )
163172 } ,
@@ -172,7 +181,7 @@ describe("session.list", () => {
172181 const root = await svc . create ( { title : "root-session" } )
173182 const child = await svc . create ( { title : "child-session" , parentID : root . id } )
174183
175- const sessions = [ ... svc . list ( { roots : true } ) ]
184+ const sessions = await svc . list ( { roots : true } )
176185 const ids = sessions . map ( ( s ) => s . id )
177186
178187 expect ( ids ) . toContain ( root . id )
@@ -189,7 +198,7 @@ describe("session.list", () => {
189198 await svc . create ( { title : "new-session" } )
190199 const futureStart = Date . now ( ) + 86400000
191200
192- const sessions = [ ... svc . list ( { start : futureStart } ) ]
201+ const sessions = await svc . list ( { start : futureStart } )
193202 expect ( sessions . length ) . toBe ( 0 )
194203 } ,
195204 } )
@@ -203,7 +212,7 @@ describe("session.list", () => {
203212 await svc . create ( { title : "unique-search-term-abc" } )
204213 await svc . create ( { title : "other-session-xyz" } )
205214
206- const sessions = [ ... svc . list ( { search : "unique-search" } ) ]
215+ const sessions = await svc . list ( { search : "unique-search" } )
207216 const titles = sessions . map ( ( s ) => s . title )
208217
209218 expect ( titles ) . toContain ( "unique-search-term-abc" )
@@ -221,7 +230,7 @@ describe("session.list", () => {
221230 await svc . create ( { title : "session-2" } )
222231 await svc . create ( { title : "session-3" } )
223232
224- const sessions = [ ... svc . list ( { limit : 2 } ) ]
233+ const sessions = await svc . list ( { limit : 2 } )
225234 expect ( sessions . length ) . toBe ( 2 )
226235 } ,
227236 } )
0 commit comments