Skip to content

Commit d078f33

Browse files
authored
Bump dependencies (#426)
* Bump deps and audit fix * Add entry * Update PR number * Use newer EchoBot * Audit fix * Also test on Node.js 20.x and 22.x * Fix NetworkInformation mock * Fix navigator mock * Add comment
1 parent bb3d7ee commit d078f33

12 files changed

Lines changed: 1030 additions & 2462 deletions

.github/workflows/pull-request-validation.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,26 +12,33 @@ jobs:
1212

1313
strategy:
1414
matrix:
15-
node-version: [18.x]
15+
node-version: [18.x, 20.x, 22.x]
1616

1717
steps:
1818
- uses: actions/checkout@v3
19+
1920
- name: Use Node.js ${{ matrix.node-version }}
2021
uses: actions/setup-node@v3
2122
with:
2223
node-version: ${{ matrix.node-version }}
2324
cache: 'npm'
25+
2426
- run: npm clean-install
27+
2528
- run: npm run prepublishOnly
29+
30+
- run: npm pack
31+
2632
- name: Upload tarball artifact
2733
uses: actions/upload-artifact@v3.1.1
2834
with:
2935
name: bundle
3036
path: ./dist
31-
- run: npm pack
37+
3238
- name: Upload tarball artifact
3339
uses: actions/upload-artifact@v3.1.1
3440
with:
3541
name: tarball
3642
path: ./*.tgz
43+
3744
- run: npm test

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
1616

1717
## [Unreleased]
1818

19+
### Changed
20+
21+
- Bumped dependencies, by [@compulim](https://github.com/compulim), in PR [#426](https://github.com/microsoft/BotFramework-DirectLineJS/pull/426)
22+
- Production dependencies
23+
- [`botframework-streaming@4.23.0`](https://npmjs.com/package/botframework-streaming)
24+
1925
## [0.15.5] - 2023-10-10
2026

2127
### Added

__tests__/directLineStreaming/connect.fail.story.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ import fetch from 'node-fetch';
22

33
import { ConnectionStatus } from '../../src/directLine';
44
import { DirectLineStreaming } from '../../src/directLineStreaming';
5+
import waitFor from './__setup__/external/testing-library/waitFor';
56
import mockObserver from './__setup__/mockObserver';
67
import setupBotProxy from './__setup__/setupBotProxy';
7-
import waitFor from './__setup__/external/testing-library/waitFor';
88

9-
const MOCKBOT3_URL = 'https://webchat-mockbot3.azurewebsites.net/';
10-
const TOKEN_URL = 'https://webchat-mockbot3.azurewebsites.net/api/token/directlinease';
9+
const TOKEN_URL =
10+
'https://hawo-mockbot4-token-app.blueriver-ce85e8f0.westus.azurecontainerapps.io/api/token/directlinease?bot=echo%20bot';
1111

1212
afterEach(() => jest.useRealTimers());
1313

@@ -23,10 +23,9 @@ test('connect fail should signal properly', async () => {
2323
return Date.now();
2424
});
2525

26-
const [{ directLineStreamingURL }, { token }] = await Promise.all([
27-
setupBotProxy({ onUpgrade, streamingBotURL: MOCKBOT3_URL }),
28-
fetch(TOKEN_URL, { method: 'POST' }).then(res => res.json())
29-
]);
26+
const { domain, token } = await fetch(TOKEN_URL, { method: 'POST' }).then(res => res.json());
27+
28+
const { directLineStreamingURL } = await setupBotProxy({ onUpgrade, streamingBotURL: new URL('/', domain).href });
3029

3130
// GIVEN: A Direct Line Streaming chat adapter.
3231
const activityObserver = mockObserver();

__tests__/directLineStreaming/connect.success.story.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,21 @@ import fetch from 'node-fetch';
22

33
import { ConnectionStatus } from '../../src/directLine';
44
import { DirectLineStreaming } from '../../src/directLineStreaming';
5+
import waitFor from './__setup__/external/testing-library/waitFor';
56
import mockObserver from './__setup__/mockObserver';
67
import setupBotProxy from './__setup__/setupBotProxy';
7-
import waitFor from './__setup__/external/testing-library/waitFor';
88

9-
const MOCKBOT3_URL = 'https://webchat-mockbot3.azurewebsites.net/';
10-
const TOKEN_URL = 'https://webchat-mockbot3.azurewebsites.net/api/token/directlinease';
9+
const TOKEN_URL =
10+
'https://hawo-mockbot4-token-app.blueriver-ce85e8f0.westus.azurecontainerapps.io/api/token/directlinease?bot=echo%20bot';
1111

1212
afterEach(() => jest.useRealTimers());
1313

1414
test('should connect', async () => {
1515
jest.useFakeTimers({ now: 0 });
1616

17-
const [{ directLineStreamingURL }, { token }] = await Promise.all([
18-
setupBotProxy({ streamingBotURL: MOCKBOT3_URL }),
19-
fetch(TOKEN_URL, { method: 'POST' }).then(res => res.json())
20-
]);
17+
const { domain, token } = await fetch(TOKEN_URL, { method: 'POST' }).then(res => res.json());
18+
19+
const { directLineStreamingURL } = await setupBotProxy({ streamingBotURL: new URL('/', domain).href });
2120

2221
// GIVEN: A Direct Line Streaming chat adapter.
2322
const activityObserver = mockObserver();

__tests__/directLineStreaming/end.story.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,21 @@ import fetch from 'node-fetch';
22

33
import { ConnectionStatus } from '../../src/directLine';
44
import { DirectLineStreaming } from '../../src/directLineStreaming';
5+
import waitFor from './__setup__/external/testing-library/waitFor';
56
import mockObserver from './__setup__/mockObserver';
67
import setupBotProxy from './__setup__/setupBotProxy';
7-
import waitFor from './__setup__/external/testing-library/waitFor';
88

9-
const MOCKBOT3_URL = 'https://webchat-mockbot3.azurewebsites.net/';
10-
const TOKEN_URL = 'https://webchat-mockbot3.azurewebsites.net/api/token/directlinease';
9+
const TOKEN_URL =
10+
'https://hawo-mockbot4-token-app.blueriver-ce85e8f0.westus.azurecontainerapps.io/api/token/directlinease?bot=echo%20bot';
1111

1212
afterEach(() => jest.useRealTimers());
1313

1414
test('should connect', async () => {
1515
jest.useFakeTimers({ now: 0 });
1616

17-
const [{ directLineStreamingURL }, { token }] = await Promise.all([
18-
setupBotProxy({ streamingBotURL: MOCKBOT3_URL }),
19-
fetch(TOKEN_URL, { method: 'POST' }).then(res => res.json())
20-
]);
17+
const { domain, token } = await fetch(TOKEN_URL, { method: 'POST' }).then(res => res.json());
18+
19+
const { directLineStreamingURL } = await setupBotProxy({ streamingBotURL: new URL('/', domain).href });
2120

2221
// GIVEN: A Direct Line Streaming chat adapter.
2322
const activityObserver = mockObserver();

__tests__/directLineStreaming/options.networkInformation.story.ts

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ import fetch from 'node-fetch';
44

55
import { ConnectionStatus } from '../../src/directLine';
66
import { DirectLineStreaming } from '../../src/directLineStreaming';
7+
import waitFor from './__setup__/external/testing-library/waitFor';
78
import mockObserver from './__setup__/mockObserver';
89
import setupBotProxy from './__setup__/setupBotProxy';
9-
import waitFor from './__setup__/external/testing-library/waitFor';
1010

1111
type MockObserver<T> = ReturnType<typeof mockObserver>;
1212
type ResultOfPromise<T> = T extends PromiseLike<infer P> ? P : never;
1313

14-
const MOCKBOT3_URL = 'https://webchat-mockbot3.azurewebsites.net/';
15-
const TOKEN_URL = 'https://webchat-mockbot3.azurewebsites.net/api/token/directlinease';
14+
const TOKEN_URL =
15+
'https://hawo-mockbot4-token-app.blueriver-ce85e8f0.westus.azurecontainerapps.io/api/token/directlinease?bot=echo%20bot';
1616

1717
jest.setTimeout(10_000);
1818

@@ -41,24 +41,22 @@ describe('Direct Line Streaming chat adapter with Network Information API', () =
4141
}
4242
});
4343

44-
(global as any).navigator = {
45-
get connection() {
46-
return networkInformation;
47-
}
48-
};
44+
// Node.js 22.x has global.navigator, but Node.js 18.x and 20.x don't.
45+
if (!global.navigator) {
46+
(global as any).navigator = {};
47+
}
48+
49+
(global as any).navigator.connection = networkInformation;
4950

50-
let token: string;
51+
const { domain, token } = await fetch(TOKEN_URL, { method: 'POST' }).then(res => res.json());
5152

52-
[botProxy, { token }] = await Promise.all([
53-
setupBotProxy({ streamingBotURL: MOCKBOT3_URL }),
54-
fetch(TOKEN_URL, { method: 'POST' }).then(res => res.json())
55-
]);
53+
const botProxy = await setupBotProxy({ streamingBotURL: new URL('/', domain).href });
5654

5755
activityObserver = mockObserver();
5856
connectionStatusObserver = mockObserver();
5957
directLine = new DirectLineStreaming({
6058
domain: botProxy.directLineStreamingURL,
61-
networkInformation: navigator.connection,
59+
networkInformation: (navigator as any).connection,
6260
token
6361
});
6462

@@ -114,7 +112,7 @@ describe('Direct Line Streaming chat adapter with Network Information API', () =
114112
// WHEN: "change" event is received.
115113
describe('when "change" event is received', () => {
116114
beforeEach(() => {
117-
(navigator.connection as any).type = 'bluetooth';
115+
(navigator as any).connection.type = 'bluetooth';
118116
});
119117

120118
// THEN: Should observe "Connecting" -> "Online" again.

__tests__/directLineStreaming/postActivity.fail.story.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ import mockObserver from './__setup__/mockObserver';
66
import setupBotProxy from './__setup__/setupBotProxy';
77
import waitFor from './__setup__/external/testing-library/waitFor';
88

9-
const MOCKBOT3_URL = 'https://webchat-mockbot3.azurewebsites.net/';
10-
const TOKEN_URL = 'https://webchat-mockbot3.azurewebsites.net/api/token/directlinease';
9+
const TOKEN_URL = 'https://hawo-mockbot4-token-app.blueriver-ce85e8f0.westus.azurecontainerapps.io/api/token/directlinease?bot=echo%20bot';
1110

1211
afterEach(() => jest.useRealTimers());
1312

@@ -18,10 +17,9 @@ test('should send activity', async () => {
1817

1918
onWebSocketSendMessage.mockImplementation((data, socket, req, next) => next(data, socket, req));
2019

21-
const [{ directLineStreamingURL }, { token }] = await Promise.all([
22-
setupBotProxy({ onWebSocketSendMessage, streamingBotURL: MOCKBOT3_URL }),
23-
fetch(TOKEN_URL, { method: 'POST' }).then(res => res.json())
24-
]);
20+
const { domain, token } = await fetch(TOKEN_URL, { method: 'POST' }).then(res => res.json());
21+
22+
const { directLineStreamingURL } = await setupBotProxy({ onWebSocketSendMessage, streamingBotURL: new URL('/', domain).href });
2523

2624
// GIVEN: A Direct Line Streaming chat adapter.
2725
const activityObserver = mockObserver();

__tests__/directLineStreaming/postActivity.success.story.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,16 @@ import mockObserver from './__setup__/mockObserver';
77
import setupBotProxy from './__setup__/setupBotProxy';
88
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 = 'https://hawo-mockbot4-token-app.blueriver-ce85e8f0.westus.azurecontainerapps.io/api/token/directlinease?bot=echo%20bot';
1211

1312
afterEach(() => jest.useRealTimers());
1413

1514
test('should send activity', async () => {
1615
jest.useFakeTimers({ now: 0 });
1716

18-
const [{ directLineStreamingURL }, { token }] = await Promise.all([
19-
setupBotProxy({ streamingBotURL: MOCKBOT3_URL }),
20-
fetch(TOKEN_URL, { method: 'POST' }).then(res => res.json())
21-
]);
17+
const { domain, token } = await fetch(TOKEN_URL, { method: 'POST' }).then(res => res.json());
18+
19+
const { directLineStreamingURL } = await setupBotProxy({ streamingBotURL: new URL('/', domain).href });
2220

2321
// GIVEN: A Direct Line Streaming chat adapter.
2422
const activityObserver = mockObserver();

__tests__/directLineStreaming/retryConnect.fail.story.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ import fetch from 'node-fetch';
22

33
import { ConnectionStatus } from '../../src/directLine';
44
import { DirectLineStreaming } from '../../src/directLineStreaming';
5+
import waitFor from './__setup__/external/testing-library/waitFor';
56
import mockObserver from './__setup__/mockObserver';
67
import setupBotProxy from './__setup__/setupBotProxy';
7-
import waitFor from './__setup__/external/testing-library/waitFor';
88

9-
const MOCKBOT3_URL = 'https://webchat-mockbot3.azurewebsites.net/';
10-
const TOKEN_URL = 'https://webchat-mockbot3.azurewebsites.net/api/token/directlinease';
9+
const TOKEN_URL =
10+
'https://hawo-mockbot4-token-app.blueriver-ce85e8f0.westus.azurecontainerapps.io/api/token/directlinease?bot=echo%20bot';
1111

1212
jest.setTimeout(15000);
1313

@@ -20,10 +20,12 @@ test('reconnect fail should stop', async () => {
2020

2121
onUpgrade.mockImplementation((req, socket, head, next) => next(req, socket, head));
2222

23-
const [{ closeAllWebSocketConnections, directLineStreamingURL }, { token }] = await Promise.all([
24-
setupBotProxy({ onUpgrade, streamingBotURL: MOCKBOT3_URL }),
25-
fetch(TOKEN_URL, { method: 'POST' }).then(res => res.json())
26-
]);
23+
const { domain, token } = await fetch(TOKEN_URL, { method: 'POST' }).then(res => res.json());
24+
25+
const { closeAllWebSocketConnections, directLineStreamingURL } = await setupBotProxy({
26+
onUpgrade,
27+
streamingBotURL: new URL('/', domain).href
28+
});
2729

2830
// GIVEN: A Direct Line Streaming chat adapter.
2931
const activityObserver = mockObserver();

__tests__/directLineStreaming/retryConnect.success.story.js

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ import fetch from 'node-fetch';
33
import { ConnectionStatus } from '../../src/directLine';
44
import { DirectLineStreaming } from '../../src/directLineStreaming';
55
import activityTimestampComparer from './__setup__/activityTimestampComparer';
6+
import waitFor from './__setup__/external/testing-library/waitFor';
67
import mockObserver from './__setup__/mockObserver';
78
import 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

1313
afterEach(() => 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

Comments
 (0)