@@ -1399,105 +1399,6 @@ describe("Cline", () => {
1399
1399
} )
1400
1400
} )
1401
1401
1402
- describe ( "Ask Operation Abort Handling" , ( ) => {
1403
- let mockProvider : any
1404
- let mockApiConfig : any
1405
-
1406
- beforeEach ( ( ) => {
1407
- vi . clearAllMocks ( )
1408
-
1409
- mockApiConfig = {
1410
- apiProvider : "anthropic" ,
1411
- apiKey : "test-key" ,
1412
- }
1413
-
1414
- mockProvider = {
1415
- context : {
1416
- globalStorageUri : { fsPath : "/test/storage" } ,
1417
- } ,
1418
- getState : vi . fn ( ) . mockResolvedValue ( { } ) ,
1419
- postMessageToWebview : vi . fn ( ) ,
1420
- postStateToWebview : vi . fn ( ) . mockResolvedValue ( undefined ) ,
1421
- }
1422
- } )
1423
-
1424
- it ( "should handle pending ask operations gracefully when task is aborted" , async ( ) => {
1425
- const [ cline , taskPromise ] = Task . create ( {
1426
- provider : mockProvider ,
1427
- apiConfiguration : mockApiConfig ,
1428
- task : "test task" ,
1429
- } )
1430
-
1431
- // Handle the task promise to prevent unhandled rejection
1432
- taskPromise . catch ( ( ) => {
1433
- // Expected error when task is aborted
1434
- } )
1435
-
1436
- // Start an ask operation but don't respond to it
1437
- const askPromise = cline . ask ( "tool" , "Test question" )
1438
-
1439
- // Abort the task while ask is pending
1440
- await cline . abortTask ( )
1441
-
1442
- // The ask should resolve with a default response instead of throwing
1443
- const result = await askPromise
1444
- expect ( result . response ) . toBe ( "messageResponse" )
1445
- expect ( result . text ) . toBeUndefined ( )
1446
- expect ( result . images ) . toBeUndefined ( )
1447
-
1448
- // Ensure the task was properly aborted
1449
- expect ( cline . abort ) . toBe ( true )
1450
- } )
1451
-
1452
- it ( "should not throw 'Current ask promise was ignored' error when task is aborted" , async ( ) => {
1453
- const [ cline , taskPromise ] = Task . create ( {
1454
- provider : mockProvider ,
1455
- apiConfiguration : mockApiConfig ,
1456
- task : "test task" ,
1457
- } )
1458
-
1459
- // Handle the task promise to prevent unhandled rejection
1460
- taskPromise . catch ( ( ) => {
1461
- // Expected error when task is aborted
1462
- } )
1463
-
1464
- // Start multiple ask operations
1465
- const askPromise1 = cline . ask ( "tool" , "Question 1" )
1466
- const askPromise2 = cline . ask ( "tool" , "Question 2" )
1467
-
1468
- // Abort the task
1469
- await cline . abortTask ( )
1470
-
1471
- // Both asks should resolve without throwing
1472
- await expect ( askPromise1 ) . resolves . toBeTruthy ( )
1473
- await expect ( askPromise2 ) . resolves . toBeTruthy ( )
1474
- } )
1475
-
1476
- it ( "should resolve pending ask with messageResponse when abortTask is called" , async ( ) => {
1477
- const [ cline , taskPromise ] = Task . create ( {
1478
- provider : mockProvider ,
1479
- apiConfiguration : mockApiConfig ,
1480
- task : "test task" ,
1481
- } )
1482
-
1483
- // Handle the task promise to prevent unhandled rejection
1484
- taskPromise . catch ( ( ) => {
1485
- // Expected error when task is aborted
1486
- } )
1487
-
1488
- // Spy on the ask response properties
1489
- // Start an ask operation
1490
- const askPromise = cline . ask ( "tool" , "Test question" )
1491
-
1492
- // Abort the task
1493
- await cline . abortTask ( )
1494
-
1495
- // The ask response should have been set to messageResponse
1496
- const result = await askPromise
1497
- expect ( result . response ) . toBe ( "messageResponse" )
1498
- } )
1499
- } )
1500
-
1501
1402
describe ( "getApiProtocol" , ( ) => {
1502
1403
it ( "should determine API protocol based on provider and model" , async ( ) => {
1503
1404
// Test with Anthropic provider
0 commit comments