@@ -2284,8 +2284,8 @@ describe('Task-based execution', () => {
22842284
22852285 await Promise . all ( [ client . connect ( clientTransport ) , server . connect ( serverTransport ) ] ) ;
22862286
2287- // Create a task on client
2288- const pending = server . request (
2287+ // Create a task on client and wait for completion
2288+ const result = await server . request (
22892289 {
22902290 method : 'elicitation/create' ,
22912291 params : {
@@ -2301,6 +2301,10 @@ describe('Task-based execution', () => {
23012301 { task : { ttl : 60000 } }
23022302 ) ;
23032303
2304+ // Verify the result was returned correctly
2305+ expect ( result . action ) . toBe ( 'accept' ) ;
2306+ expect ( result . content ) . toEqual ( { username : 'list-user' } ) ;
2307+
23042308 // Get the task ID from the task list since it's generated automatically
23052309 const taskList = await server . listTasks ( ) ;
23062310 expect ( taskList . tasks . length ) . toBeGreaterThan ( 0 ) ;
@@ -2376,8 +2380,8 @@ describe('Task-based execution', () => {
23762380
23772381 await Promise . all ( [ client . connect ( clientTransport ) , server . connect ( serverTransport ) ] ) ;
23782382
2379- // Create a task on client
2380- const pending = server . request (
2383+ // Create a task on client and wait for completion
2384+ const result = await server . request (
23812385 {
23822386 method : 'elicitation/create' ,
23832387 params : {
@@ -2393,15 +2397,19 @@ describe('Task-based execution', () => {
23932397 { task : { ttl : 60000 } }
23942398 ) ;
23952399
2400+ // Verify the result was returned correctly
2401+ expect ( result . action ) . toBe ( 'accept' ) ;
2402+ expect ( result . content ) . toEqual ( { username : 'result-user' } ) ;
2403+
23962404 // Get the task ID from the task list since it's generated automatically
23972405 const taskList = await server . listTasks ( ) ;
23982406 expect ( taskList . tasks . length ) . toBeGreaterThan ( 0 ) ;
23992407 const taskId = taskList . tasks [ 0 ] . taskId ;
24002408
2401- // Query task result
2402- const result = await server . getTaskResult ( { taskId } , ElicitResultSchema ) ;
2403- expect ( result . action ) . toBe ( 'accept' ) ;
2404- expect ( result . content ) . toEqual ( { username : 'result-user' } ) ;
2409+ // Query task result using getTaskResult as well
2410+ const taskResult = await server . getTaskResult ( { taskId } , ElicitResultSchema ) ;
2411+ expect ( taskResult . action ) . toBe ( 'accept' ) ;
2412+ expect ( taskResult . content ) . toEqual ( { username : 'result-user' } ) ;
24052413 } ) ;
24062414
24072415 test ( 'should query task list from client using listTasks' , async ( ) => {
@@ -2470,7 +2478,7 @@ describe('Task-based execution', () => {
24702478 // Create multiple tasks on client
24712479 const createdTaskIds : string [ ] = [ ] ;
24722480 for ( let i = 0 ; i < 2 ; i ++ ) {
2473- const pending = server . request (
2481+ const result = await server . request (
24742482 {
24752483 method : 'elicitation/create' ,
24762484 params : {
@@ -2486,6 +2494,10 @@ describe('Task-based execution', () => {
24862494 { task : { ttl : 60000 } }
24872495 ) ;
24882496
2497+ // Verify the result was returned correctly
2498+ expect ( result . action ) . toBe ( 'accept' ) ;
2499+ expect ( result . content ) . toEqual ( { username : 'list-user' } ) ;
2500+
24892501 // Get the task ID from the task list
24902502 const taskList = await server . listTasks ( ) ;
24912503 const newTask = taskList . tasks . find ( t => ! createdTaskIds . includes ( t . taskId ) ) ;
0 commit comments