@@ -1406,6 +1406,99 @@ describe('WebClient', () => {
14061406 }
14071407 scope . done ( ) ;
14081408 } ) ;
1409+ it ( 'flushes chunks without buffered markdown_text' , async ( ) => {
1410+ const scope = nock ( 'https://slack.com' )
1411+ . post ( '/api/chat.startStream' , {
1412+ channel : 'C0123456789' ,
1413+ thread_ts : '123.000' ,
1414+ chunks : JSON . stringify ( [ { type : 'markdown_text' , text : 'chunk content' } ] ) ,
1415+ } )
1416+ . reply ( 200 , {
1417+ ok : true ,
1418+ ts : '123.123' ,
1419+ } )
1420+ . post ( '/api/chat.stopStream' , {
1421+ channel : 'C0123456789' ,
1422+ ts : '123.123' ,
1423+ chunks : JSON . stringify ( [ ] ) ,
1424+ } )
1425+ . reply ( 200 , {
1426+ ok : true ,
1427+ } ) ;
1428+ const streamer = client . chatStream ( {
1429+ channel : 'C0123456789' ,
1430+ thread_ts : '123.000' ,
1431+ } ) ;
1432+ // append only chunks, no markdown_text
1433+ await streamer . append ( {
1434+ chunks : [ { type : 'markdown_text' , text : 'chunk content' } ] ,
1435+ } ) ;
1436+ await streamer . stop ( ) ;
1437+ scope . done ( ) ;
1438+ } ) ;
1439+ it ( 'flushes both buffered markdown_text and chunks together' , async ( ) => {
1440+ const scope = nock ( 'https://slack.com' )
1441+ . post ( '/api/chat.startStream' , {
1442+ channel : 'C0123456789' ,
1443+ thread_ts : '123.000' ,
1444+ chunks : JSON . stringify ( [
1445+ { type : 'markdown_text' , text : 'buffered text' } ,
1446+ { type : 'markdown_text' , text : 'chunk content' } ,
1447+ ] ) ,
1448+ } )
1449+ . reply ( 200 , {
1450+ ok : true ,
1451+ ts : '123.123' ,
1452+ } )
1453+ . post ( '/api/chat.stopStream' , {
1454+ channel : 'C0123456789' ,
1455+ ts : '123.123' ,
1456+ chunks : JSON . stringify ( [ ] ) ,
1457+ } )
1458+ . reply ( 200 , {
1459+ ok : true ,
1460+ } ) ;
1461+ const streamer = client . chatStream ( {
1462+ channel : 'C0123456789' ,
1463+ thread_ts : '123.000' ,
1464+ buffer_size : 256 ,
1465+ } ) ;
1466+ await streamer . append ( {
1467+ markdown_text : 'buffered text' ,
1468+ } ) ;
1469+ await streamer . append ( {
1470+ chunks : [ { type : 'markdown_text' , text : 'chunk content' } ] ,
1471+ } ) ;
1472+ await streamer . stop ( ) ;
1473+ scope . done ( ) ;
1474+ } ) ;
1475+ it ( 'stops stream with chunks argument' , async ( ) => {
1476+ const scope = nock ( 'https://slack.com' )
1477+ . post ( '/api/chat.startStream' , {
1478+ channel : 'C0123456789' ,
1479+ thread_ts : '123.000' ,
1480+ } )
1481+ . reply ( 200 , {
1482+ ok : true ,
1483+ ts : '123.123' ,
1484+ } )
1485+ . post ( '/api/chat.stopStream' , {
1486+ channel : 'C0123456789' ,
1487+ ts : '123.123' ,
1488+ chunks : JSON . stringify ( [ { type : 'markdown_text' , text : 'stop chunk' } ] ) ,
1489+ } )
1490+ . reply ( 200 , {
1491+ ok : true ,
1492+ } ) ;
1493+ const streamer = client . chatStream ( {
1494+ channel : 'C0123456789' ,
1495+ thread_ts : '123.000' ,
1496+ } ) ;
1497+ await streamer . stop ( {
1498+ chunks : [ { type : 'markdown_text' , text : 'stop chunk' } ] ,
1499+ } ) ;
1500+ scope . done ( ) ;
1501+ } ) ;
14091502 } ) ;
14101503
14111504 describe ( 'filesUploadV2' , ( ) => {
0 commit comments