@webex/internal-plugin-mercury 3.0.0-beta.9 → 3.0.0-bnr.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -3
- package/dist/config.js +0 -7
- package/dist/config.js.map +1 -1
- package/dist/errors.js +0 -44
- package/dist/errors.js.map +1 -1
- package/dist/index.js +1 -20
- package/dist/index.js.map +1 -1
- package/dist/mercury.js +29 -148
- package/dist/mercury.js.map +1 -1
- package/dist/socket/index.js +0 -4
- package/dist/socket/index.js.map +1 -1
- package/dist/socket/socket-base.js +25 -116
- package/dist/socket/socket-base.js.map +1 -1
- package/dist/socket/socket.js +1 -7
- package/dist/socket/socket.js.map +1 -1
- package/dist/socket/socket.shim.js +2 -7
- package/dist/socket/socket.shim.js.map +1 -1
- package/dist/types/config.d.ts +10 -0
- package/dist/types/errors.d.ts +31 -0
- package/dist/types/index.d.ts +4 -0
- package/dist/types/mercury.d.ts +2 -0
- package/dist/types/socket/index.d.ts +1 -0
- package/dist/types/socket/socket-base.d.ts +120 -0
- package/dist/types/socket/socket.d.ts +2 -0
- package/dist/types/socket/socket.shim.d.ts +2 -0
- package/package.json +14 -14
- package/src/config.js +2 -2
- package/src/errors.js +7 -5
- package/src/index.js +2 -2
- package/src/mercury.js +74 -59
- package/src/socket/socket-base.js +45 -46
- package/src/socket/socket.shim.js +6 -8
- package/test/integration/spec/mercury.js +49 -39
- package/test/integration/spec/sharable-mercury.js +19 -15
- package/test/integration/spec/webex.js +8 -7
- package/test/unit/spec/mercury-events.js +51 -60
- package/test/unit/spec/mercury.js +179 -150
- package/test/unit/spec/socket.js +246 -202
|
@@ -14,17 +14,19 @@ describe('plugin-mercury', function () {
|
|
|
14
14
|
describe('Sharable Mercury', () => {
|
|
15
15
|
let webex;
|
|
16
16
|
|
|
17
|
-
beforeEach(() =>
|
|
18
|
-
.then((users) => {
|
|
17
|
+
beforeEach(() =>
|
|
18
|
+
testUsers.create({count: 1}).then((users) => {
|
|
19
19
|
webex = new WebexCore({
|
|
20
20
|
credentials: {
|
|
21
|
-
supertoken: users[0].token
|
|
22
|
-
}
|
|
21
|
+
supertoken: users[0].token,
|
|
22
|
+
},
|
|
23
23
|
});
|
|
24
24
|
|
|
25
|
-
return webex.internal.device
|
|
25
|
+
return webex.internal.device
|
|
26
|
+
.register()
|
|
26
27
|
.then(() => webex.internal.feature.setFeature('developer', 'web-shared-mercury', true));
|
|
27
|
-
})
|
|
28
|
+
})
|
|
29
|
+
);
|
|
28
30
|
|
|
29
31
|
afterEach(() => webex && webex.internal.mercury.disconnect());
|
|
30
32
|
|
|
@@ -39,17 +41,19 @@ describe('plugin-mercury', function () {
|
|
|
39
41
|
webex.internal.mercury.on('event:mercury.buffer_state', spy1);
|
|
40
42
|
webex.internal.mercury.on('event:mercury.registration_status', spy2);
|
|
41
43
|
|
|
42
|
-
return webex.internal.mercury.connect()
|
|
43
|
-
.
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
const {data} = spy2.args[0][0];
|
|
44
|
+
return webex.internal.mercury.connect().then(() => {
|
|
45
|
+
assert.notCalled(spy1);
|
|
46
|
+
assert.calledOnce(spy2);
|
|
47
|
+
const {data} = spy2.args[0][0];
|
|
47
48
|
|
|
48
|
-
|
|
49
|
-
|
|
49
|
+
assert.property(data, 'bufferState');
|
|
50
|
+
assert.property(data, 'localClusterServiceUrls');
|
|
50
51
|
|
|
51
|
-
|
|
52
|
-
|
|
52
|
+
assert.deepEqual(
|
|
53
|
+
webex.internal.mercury.localClusterServiceUrls,
|
|
54
|
+
data.localClusterServiceUrls
|
|
55
|
+
);
|
|
56
|
+
});
|
|
53
57
|
});
|
|
54
58
|
});
|
|
55
59
|
});
|
|
@@ -14,25 +14,26 @@ describe('plugin-mercury', function () {
|
|
|
14
14
|
|
|
15
15
|
let webex;
|
|
16
16
|
|
|
17
|
-
beforeEach('create users', () =>
|
|
18
|
-
.then(async (users) => {
|
|
17
|
+
beforeEach('create users', () =>
|
|
18
|
+
testUsers.create({count: 1}).then(async (users) => {
|
|
19
19
|
// Pause for 5 seconds for CI
|
|
20
20
|
await new Promise((done) => setTimeout(done, 5000));
|
|
21
21
|
|
|
22
22
|
webex = new WebexCore({
|
|
23
23
|
credentials: {
|
|
24
|
-
supertoken: users[0].token
|
|
25
|
-
}
|
|
24
|
+
supertoken: users[0].token,
|
|
25
|
+
},
|
|
26
26
|
});
|
|
27
27
|
sinon.spy(webex.internal.mercury, 'disconnect');
|
|
28
28
|
sinon.spy(webex.internal.device, 'unregister');
|
|
29
29
|
|
|
30
30
|
return webex.internal.mercury.connect();
|
|
31
|
-
})
|
|
31
|
+
})
|
|
32
|
+
);
|
|
32
33
|
|
|
33
34
|
describe('onBeforeLogout()', () => {
|
|
34
|
-
it('disconnects the web socket', () =>
|
|
35
|
-
.then(() => {
|
|
35
|
+
it('disconnects the web socket', () =>
|
|
36
|
+
webex.logout({noRedirect: true}).then(() => {
|
|
36
37
|
assert.called(webex.internal.mercury.disconnect);
|
|
37
38
|
assert.isFalse(webex.internal.mercury.connected);
|
|
38
39
|
assert.called(webex.internal.device.unregister);
|
|
@@ -16,19 +16,15 @@ import promiseTick from '../lib/promise-tick';
|
|
|
16
16
|
describe('plugin-mercury', () => {
|
|
17
17
|
describe('Mercury', () => {
|
|
18
18
|
describe('Events', () => {
|
|
19
|
-
let clock,
|
|
20
|
-
mercury,
|
|
21
|
-
mockWebSocket,
|
|
22
|
-
socketOpenStub,
|
|
23
|
-
webex;
|
|
19
|
+
let clock, mercury, mockWebSocket, socketOpenStub, webex;
|
|
24
20
|
|
|
25
21
|
const fakeTestMessage = {
|
|
26
22
|
id: uuid.v4(),
|
|
27
23
|
data: {
|
|
28
|
-
eventType: 'fake.test'
|
|
24
|
+
eventType: 'fake.test',
|
|
29
25
|
},
|
|
30
26
|
timestamp: Date.now(),
|
|
31
|
-
trackingId: `suffix_${uuid.v4()}_${Date.now()}
|
|
27
|
+
trackingId: `suffix_${uuid.v4()}_${Date.now()}`,
|
|
32
28
|
};
|
|
33
29
|
|
|
34
30
|
const statusStartTypingMessage = {
|
|
@@ -36,12 +32,12 @@ describe('plugin-mercury', () => {
|
|
|
36
32
|
data: {
|
|
37
33
|
eventType: 'status.start_typing',
|
|
38
34
|
actor: {
|
|
39
|
-
id: 'actorId'
|
|
35
|
+
id: 'actorId',
|
|
40
36
|
},
|
|
41
|
-
conversationId: uuid.v4()
|
|
37
|
+
conversationId: uuid.v4(),
|
|
42
38
|
},
|
|
43
39
|
timestamp: Date.now(),
|
|
44
|
-
trackingId: `suffix_${uuid.v4()}_${Date.now()}
|
|
40
|
+
trackingId: `suffix_${uuid.v4()}_${Date.now()}`,
|
|
45
41
|
};
|
|
46
42
|
|
|
47
43
|
beforeEach(() => {
|
|
@@ -55,8 +51,8 @@ describe('plugin-mercury', () => {
|
|
|
55
51
|
beforeEach(() => {
|
|
56
52
|
webex = new MockWebex({
|
|
57
53
|
children: {
|
|
58
|
-
mercury: Mercury
|
|
59
|
-
}
|
|
54
|
+
mercury: Mercury,
|
|
55
|
+
},
|
|
60
56
|
});
|
|
61
57
|
|
|
62
58
|
webex.internal.metrics.submitClientMetrics = sinon.stub();
|
|
@@ -100,8 +96,7 @@ describe('plugin-mercury', () => {
|
|
|
100
96
|
|
|
101
97
|
mockWebSocket.open();
|
|
102
98
|
|
|
103
|
-
return promise
|
|
104
|
-
.then(() => assert.called(spy));
|
|
99
|
+
return promise.then(() => assert.called(spy));
|
|
105
100
|
});
|
|
106
101
|
});
|
|
107
102
|
|
|
@@ -120,7 +115,7 @@ describe('plugin-mercury', () => {
|
|
|
120
115
|
|
|
121
116
|
mockWebSocket.emit('close', {
|
|
122
117
|
code: 1000,
|
|
123
|
-
reason: 'Done'
|
|
118
|
+
reason: 'Done',
|
|
124
119
|
});
|
|
125
120
|
|
|
126
121
|
return promise;
|
|
@@ -173,9 +168,9 @@ describe('plugin-mercury', () => {
|
|
|
173
168
|
data: JSON.stringify({
|
|
174
169
|
id: uuid.v4(),
|
|
175
170
|
data: {
|
|
176
|
-
eventType: 'mercury.buffer_state'
|
|
177
|
-
}
|
|
178
|
-
})
|
|
171
|
+
eventType: 'mercury.buffer_state',
|
|
172
|
+
},
|
|
173
|
+
}),
|
|
179
174
|
});
|
|
180
175
|
// using lengthOf because notCalled doesn't allow the helpful
|
|
181
176
|
// string assertion
|
|
@@ -185,8 +180,7 @@ describe('plugin-mercury', () => {
|
|
|
185
180
|
.then(() => {
|
|
186
181
|
assert.calledOnce(bufferStateSpy);
|
|
187
182
|
|
|
188
|
-
return mercury.connect()
|
|
189
|
-
.then(done);
|
|
183
|
+
return mercury.connect().then(done);
|
|
190
184
|
})
|
|
191
185
|
.catch(done);
|
|
192
186
|
});
|
|
@@ -211,54 +205,54 @@ describe('plugin-mercury', () => {
|
|
|
211
205
|
{
|
|
212
206
|
code: 1000,
|
|
213
207
|
reason: 'idle',
|
|
214
|
-
action: 'reconnect'
|
|
208
|
+
action: 'reconnect',
|
|
215
209
|
},
|
|
216
210
|
{
|
|
217
211
|
code: 1000,
|
|
218
212
|
reason: 'done (forced)',
|
|
219
|
-
action: 'reconnect'
|
|
213
|
+
action: 'reconnect',
|
|
220
214
|
},
|
|
221
215
|
{
|
|
222
216
|
code: 1000,
|
|
223
217
|
reason: 'pong not received',
|
|
224
|
-
action: 'reconnect'
|
|
218
|
+
action: 'reconnect',
|
|
225
219
|
},
|
|
226
220
|
{
|
|
227
221
|
code: 1000,
|
|
228
222
|
reason: 'pong mismatch',
|
|
229
|
-
action: 'reconnect'
|
|
223
|
+
action: 'reconnect',
|
|
230
224
|
},
|
|
231
225
|
{
|
|
232
226
|
code: 1000,
|
|
233
|
-
action: 'close'
|
|
227
|
+
action: 'close',
|
|
234
228
|
},
|
|
235
229
|
{
|
|
236
230
|
code: 1003,
|
|
237
|
-
action: 'close'
|
|
231
|
+
action: 'close',
|
|
238
232
|
},
|
|
239
233
|
{
|
|
240
234
|
code: 1001,
|
|
241
|
-
action: 'reconnect'
|
|
235
|
+
action: 'reconnect',
|
|
242
236
|
},
|
|
243
237
|
{
|
|
244
238
|
code: 1005,
|
|
245
|
-
action: 'reconnect'
|
|
239
|
+
action: 'reconnect',
|
|
246
240
|
},
|
|
247
241
|
{
|
|
248
242
|
code: 1006,
|
|
249
|
-
action: 'reconnect'
|
|
243
|
+
action: 'reconnect',
|
|
250
244
|
},
|
|
251
245
|
{
|
|
252
246
|
code: 1011,
|
|
253
|
-
action: 'reconnect'
|
|
247
|
+
action: 'reconnect',
|
|
254
248
|
},
|
|
255
249
|
{
|
|
256
250
|
code: 4000,
|
|
257
|
-
action: 'replace'
|
|
251
|
+
action: 'replace',
|
|
258
252
|
},
|
|
259
253
|
{
|
|
260
|
-
action: 'close'
|
|
261
|
-
}
|
|
254
|
+
action: 'close',
|
|
255
|
+
},
|
|
262
256
|
];
|
|
263
257
|
|
|
264
258
|
events.forEach((def) => {
|
|
@@ -267,11 +261,9 @@ describe('plugin-mercury', () => {
|
|
|
267
261
|
|
|
268
262
|
if (code && reason) {
|
|
269
263
|
description = `with code \`${code}\` and reason \`${reason}\``;
|
|
270
|
-
}
|
|
271
|
-
else if (code) {
|
|
264
|
+
} else if (code) {
|
|
272
265
|
description = `with code \`${code}\``;
|
|
273
|
-
}
|
|
274
|
-
else if (reason) {
|
|
266
|
+
} else if (reason) {
|
|
275
267
|
description = `with reason \`${reason}\``;
|
|
276
268
|
}
|
|
277
269
|
|
|
@@ -351,7 +343,7 @@ describe('plugin-mercury', () => {
|
|
|
351
343
|
describe('when a MessageEvent is received', () => {
|
|
352
344
|
it('processes the Event via any autowired event handlers', () => {
|
|
353
345
|
webex.fake = {
|
|
354
|
-
processTestEvent: sinon.spy()
|
|
346
|
+
processTestEvent: sinon.spy(),
|
|
355
347
|
};
|
|
356
348
|
|
|
357
349
|
const promise = mercury.connect();
|
|
@@ -393,7 +385,7 @@ describe('plugin-mercury', () => {
|
|
|
393
385
|
});
|
|
394
386
|
});
|
|
395
387
|
|
|
396
|
-
it(
|
|
388
|
+
it("emits the Mercury envelope named by the Mercury event's eventType", () => {
|
|
397
389
|
const startSpy = sinon.spy();
|
|
398
390
|
const stopSpy = sinon.spy();
|
|
399
391
|
|
|
@@ -427,28 +419,27 @@ describe('plugin-mercury', () => {
|
|
|
427
419
|
|
|
428
420
|
mockWebSocket.open();
|
|
429
421
|
|
|
430
|
-
return promise
|
|
431
|
-
.
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
})
|
|
449
|
-
});
|
|
450
|
-
assert.called(spy);
|
|
422
|
+
return promise.then(() => {
|
|
423
|
+
mockWebSocket.emit('message', {
|
|
424
|
+
data: JSON.stringify({
|
|
425
|
+
sequenceNumber: 2,
|
|
426
|
+
id: 'mockid',
|
|
427
|
+
data: {
|
|
428
|
+
eventType: 'mercury.buffer_state',
|
|
429
|
+
},
|
|
430
|
+
}),
|
|
431
|
+
});
|
|
432
|
+
mockWebSocket.emit('message', {
|
|
433
|
+
data: JSON.stringify({
|
|
434
|
+
sequenceNumber: 4,
|
|
435
|
+
id: 'mockid',
|
|
436
|
+
data: {
|
|
437
|
+
eventType: 'mercury.buffer_state',
|
|
438
|
+
},
|
|
439
|
+
}),
|
|
451
440
|
});
|
|
441
|
+
assert.called(spy);
|
|
442
|
+
});
|
|
452
443
|
});
|
|
453
444
|
});
|
|
454
445
|
});
|