@@ -36,9 +36,17 @@ vi.mock('@/lib/execution/payloads/large-execution-value', () => ({
3636 collectLargeValueKeys : vi . fn ( ( ) => [ ] ) ,
3737} ) )
3838
39+ import type { ServerToolContext } from '@/lib/copilot/tools/server/base-tool'
3940import { queryLogsServerTool } from './query-logs'
4041
41- const ctx = { userId : 'user-1' , workspaceId : 'ws-1' }
42+ const ctx : ServerToolContext = { userId : 'user-1' , workspaceId : 'ws-1' }
43+
44+ type QueryLogsArgs = Parameters < typeof queryLogsServerTool . execute > [ 0 ]
45+
46+ /** Fully-typed list-view args with the schema's defaulted fields spelled out. */
47+ function listArgs ( overrides : Partial < Extract < QueryLogsArgs , { view : 'list' } > > ) : QueryLogsArgs {
48+ return { view : 'list' , limit : 100 , sortBy : 'date' , sortOrder : 'desc' , ...overrides }
49+ }
4250
4351function detail ( overrides : Record < string , unknown > = { } ) {
4452 return {
@@ -218,28 +226,23 @@ describe('queryLogsServerTool', () => {
218226 it ( 'accepts a workspaceId that re-asserts the execution workspace' , async ( ) => {
219227 listLogsMock . mockResolvedValue ( { data : [ ] , nextCursor : null , total : 0 } )
220228
221- await queryLogsServerTool . execute ( { view : 'list' , workspaceId : 'ws-1' } as any , ctx )
229+ await queryLogsServerTool . execute ( listArgs ( { workspaceId : 'ws-1' } ) , ctx )
222230
223231 expect ( listLogsMock ) . toHaveBeenCalledTimes ( 1 )
224232 expect ( listLogsMock . mock . calls [ 0 ] [ 0 ] . workspaceId ) . toBe ( 'ws-1' )
225233 } )
226234
227235 it ( 'rejects a workspaceId that names a different workspace' , async ( ) => {
228236 await expect (
229- queryLogsServerTool . execute ( { view : 'list' , workspaceId : 'ws-other' } as any , ctx )
237+ queryLogsServerTool . execute ( listArgs ( { workspaceId : 'ws-other' } ) , ctx )
230238 ) . rejects . toThrow ( 'Workspace ID does not match the Copilot execution workspace' )
231239
232240 expect ( listLogsMock ) . not . toHaveBeenCalled ( )
233241 } )
234242
235243 it ( 'fails closed when the context carries no workspace' , async ( ) => {
236244 await expect (
237- queryLogsServerTool . execute (
238- { view : 'list' , workspaceId : 'ws-1' } as any ,
239- {
240- userId : 'user-1' ,
241- } as any
242- )
245+ queryLogsServerTool . execute ( listArgs ( { workspaceId : 'ws-1' } ) , { userId : 'user-1' } )
243246 ) . rejects . toThrow ( 'Copilot execution workspace is required' )
244247
245248 expect ( listLogsMock ) . not . toHaveBeenCalled ( )
0 commit comments