@@ -3,12 +3,12 @@ import fetch from 'node-fetch';
33import { ConnectionStatus } from '../../src/directLine' ;
44import { DirectLineStreaming } from '../../src/directLineStreaming' ;
55import activityTimestampComparer from './__setup__/activityTimestampComparer' ;
6+ import waitFor from './__setup__/external/testing-library/waitFor' ;
67import mockObserver from './__setup__/mockObserver' ;
78import setupBotProxy from './__setup__/setupBotProxy' ;
8- import waitFor from './__setup__/external/testing-library/waitFor' ;
99
10- const MOCKBOT3_URL = 'https://webchat-mockbot3.azurewebsites.net/' ;
11- const TOKEN_URL = 'https://webchat-mockbot3.azurewebsites.net /api/token/directlinease' ;
10+ const TOKEN_URL =
11+ 'https://hawo-mockbot4-token-app.blueriver-ce85e8f0.westus.azurecontainerapps.io /api/token/directlinease?bot=echo%20bot ' ;
1212
1313afterEach ( ( ) => jest . useRealTimers ( ) ) ;
1414
@@ -24,10 +24,12 @@ test.each([['with stable connection'], ['without stable connection']])(
2424 return Date . now ( ) ;
2525 } ) ;
2626
27- const [ { closeAllWebSocketConnections, directLineStreamingURL } , { token } ] = await Promise . all ( [
28- setupBotProxy ( { onUpgrade, streamingBotURL : MOCKBOT3_URL } ) ,
29- fetch ( TOKEN_URL , { method : 'POST' } ) . then ( res => res . json ( ) )
30- ] ) ;
27+ const { domain, token } = await fetch ( TOKEN_URL , { method : 'POST' } ) . then ( res => res . json ( ) ) ;
28+
29+ const { closeAllWebSocketConnections, directLineStreamingURL } = await setupBotProxy ( {
30+ onUpgrade,
31+ streamingBotURL : new URL ( '/' , domain ) . href
32+ } ) ;
3133
3234 // GIVEN: A Direct Line Streaming chat adapter.
3335 const activityObserver = mockObserver ( ) ;
@@ -119,19 +121,21 @@ test.each([['with stable connection'], ['without stable connection']])(
119121 ) ;
120122
121123 // THEN: Bot should reply and the activity should echo back.
122- await waitFor ( ( ) => {
123- expect ( [ ...activityObserver . observations ] . sort ( ( [ , , x ] , [ , , y ] ) => activityTimestampComparer ( x , y ) ) ) . toEqual ( [
124- [ expect . any ( Number ) , 'next' , expect . activityContaining ( 'Hello and welcome!' ) ] ,
125- [ expect . any ( Number ) , 'next' , expect . activityContaining ( 'Hello and welcome!' ) ] ,
126- [
127- expect . any ( Number ) ,
128- 'next' ,
129- expect . activityContaining ( 'Hello, World!' , { id : postActivityObserver . observations [ 0 ] [ 2 ] } )
130- ] ,
131- [ expect . any ( Number ) , 'next' , expect . activityContaining ( 'Echo: Hello, World!' ) ]
132- ] ) ,
133- { timeout : 5000 } ;
134- } ) ;
124+ await waitFor (
125+ ( ) => {
126+ expect ( [ ...activityObserver . observations ] . sort ( ( [ , , x ] , [ , , y ] ) => activityTimestampComparer ( x , y ) ) ) . toEqual ( [
127+ [ expect . any ( Number ) , 'next' , expect . activityContaining ( 'Hello and welcome!' ) ] ,
128+ [ expect . any ( Number ) , 'next' , expect . activityContaining ( 'Hello and welcome!' ) ] ,
129+ [
130+ expect . any ( Number ) ,
131+ 'next' ,
132+ expect . activityContaining ( 'Hello, World!' , { id : postActivityObserver . observations [ 0 ] [ 2 ] } )
133+ ] ,
134+ [ expect . any ( Number ) , 'next' , expect . activityContaining ( 'Echo: Hello, World!' ) ]
135+ ] ) ;
136+ } ,
137+ { timeout : 5000 }
138+ ) ;
135139 } ,
136140 15000
137141) ;
0 commit comments