@webex/plugin-meetings 3.0.0-beta.34 → 3.0.0-beta.35

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.
@@ -1,114 +1,217 @@
1
- import {assert} from '@webex/test-helper-chai';
2
1
  import sinon from 'sinon';
2
+ import {assert} from '@webex/test-helper-chai';
3
3
  import MockWebex from '@webex/test-helper-mock-webex';
4
- import Metrics from '@webex/plugin-meetings/src/metrics';
5
-
4
+ import Meetings from '@webex/plugin-meetings';
6
5
  import RoapRequest from '@webex/plugin-meetings/src/roap/request';
7
-
8
-
9
- describe('RoapRequest', () => {
10
- describe('attachRechabilityData', () => {
11
- let webex;
12
-
13
- beforeEach(() => {
14
- webex = new MockWebex();
6
+ import Metrics from '@webex/plugin-meetings/src/metrics';
7
+ import {REACHABILITY} from '@webex/plugin-meetings/src/constants';
8
+
9
+ describe('plugin-meetings/roap', () => {
10
+ let roapRequest;
11
+ let webex;
12
+ const locusUrl = 'locusUrl';
13
+
14
+ beforeEach(async () => {
15
+ webex = new MockWebex({
16
+ children: {
17
+ meetings: Meetings,
18
+ },
15
19
  });
16
-
17
- it('attaches the reachability data when it exists', async () => {
18
- // @ts-ignore
19
- const roapRequest = new RoapRequest({}, {parent: webex});
20
20
 
21
- const sdp = {some: 'attribute'};
21
+ webex.meetings.clientRegion = {
22
+ countryCode: 'US',
23
+ regionCode: 'WEST-COAST',
24
+ };
25
+
26
+ webex.internal = {
27
+ services: {
28
+ get: sinon.mock().returns(locusUrl),
29
+ waitForCatalog: sinon.mock().returns(Promise.resolve({})),
30
+ },
31
+ device: {
32
+ url: 'url',
33
+ },
34
+ };
35
+
36
+ // @ts-ignore
37
+ roapRequest = new RoapRequest({webex});
38
+
39
+ roapRequest.request = sinon.mock().returns(
40
+ Promise.resolve({
41
+ body: {
42
+ locus: {
43
+ roapSeq: '',
44
+ id: '',
45
+ url: 'url/path',
46
+ fullState: {
47
+ lastActive: 'lastActive',
48
+ },
49
+ },
50
+ },
51
+ })
52
+ );
22
53
 
23
- const reachabilitData = {reachability: 'data'};
54
+ Metrics.postEvent = sinon.stub().returns();
24
55
 
25
- await webex.boundedStorage.put(
26
- 'Reachability',
27
- 'reachability.result',
28
- JSON.stringify(reachabilitData)
29
- );
56
+ await webex.boundedStorage.put(
57
+ REACHABILITY.namespace,
58
+ REACHABILITY.localStorageJoinCookie,
59
+ JSON.stringify({
60
+ anycastEntryPoint: 'aws-eu-west-1',
61
+ })
62
+ );
63
+ await webex.boundedStorage.put(
64
+ REACHABILITY.namespace,
65
+ REACHABILITY.localStorageResult,
66
+ JSON.stringify({
67
+ clusterId: {
68
+ udp: 'test',
69
+ },
70
+ })
71
+ );
72
+ });
30
73
 
31
- const newSdp = await roapRequest.attachRechabilityData(sdp);
74
+ describe('#attachReachabilityData', () => {
75
+ it('returns the correct reachability data', async () => {
76
+ const res = await roapRequest.attachReachabilityData({});
32
77
 
33
- assert.deepEqual(newSdp, {
34
- some: 'attribute',
35
- reachability: reachabilitData
36
- })
78
+ assert.deepEqual(res.localSdp, {
79
+ reachability: {
80
+ clusterId: {
81
+ udp: 'test',
82
+ },
83
+ },
84
+ });
85
+ assert.deepEqual(res.joinCookie, {
86
+ anycastEntryPoint: 'aws-eu-west-1',
87
+ });
37
88
  });
38
-
39
- it('handles the case when realiability data does not exist', async () => {
40
- // @ts-ignore
41
- const roapRequest = new RoapRequest({}, {parent: webex});
42
89
 
43
- const sdp = {some: 'attribute'};
90
+ it('handles the case when reachability data does not exist', async () => {
91
+ await webex.boundedStorage.del(REACHABILITY.namespace, REACHABILITY.localStorageJoinCookie);
44
92
 
45
- const newSdp = await roapRequest.attachRechabilityData(sdp);
93
+ await webex.boundedStorage.del(REACHABILITY.namespace, REACHABILITY.localStorageResult);
94
+ const sdp = {
95
+ some: 'attribute',
96
+ };
97
+
98
+ const result = await roapRequest.attachReachabilityData(sdp);
46
99
 
47
- assert.deepEqual(newSdp, sdp);
100
+ assert.deepEqual(result, {
101
+ joinCookie: undefined,
102
+ localSdp: {
103
+ some: 'attribute',
104
+ },
105
+ });
48
106
  });
49
107
  });
50
108
 
51
109
  describe('sendRoap', () => {
52
- let webex;
110
+ it('includes joinCookie in the request correctly', async () => {
111
+ await roapRequest.sendRoap({
112
+ locusSelfUrl: locusUrl,
113
+ mediaId: 'mediaId',
114
+ roapMessage: {
115
+ seq: 'seq',
116
+ },
117
+ });
53
118
 
54
- beforeEach(() => {
55
- webex = new MockWebex();
119
+ const requestParams = roapRequest.request.getCall(0).args[0];
120
+ assert.equal(requestParams.method, 'PUT');
121
+ assert.equal(requestParams.uri, `${locusUrl}/media`);
122
+ assert.deepEqual(requestParams.body.localMedias, [
123
+ {
124
+ localSdp:
125
+ '{"roapMessage":{"seq":"seq"},"audioMuted":false,"videoMuted":false,"reachability":{"clusterId":{"udp":"test"}}}',
126
+ mediaId: 'mediaId',
127
+ },
128
+ ]);
129
+ assert.deepEqual(requestParams.body.clientMediaPreferences, {
130
+ joinCookie: {
131
+ anycastEntryPoint: 'aws-eu-west-1',
132
+ },
133
+ preferTranscoding: true,
134
+ });
56
135
  });
136
+ });
57
137
 
58
- it('calls attachReliabilityData', async () => {
59
- Metrics.postEvent = sinon.stub();
60
-
61
- // @ts-ignore
62
- const roapRequest = new RoapRequest({}, {parent: webex});
63
-
64
- const newSdp = {new: 'sdp'}
138
+ it('calls attachReachabilityData when sendRoap', async () => {
139
+ const newSdp = {
140
+ new: 'sdp',
141
+ };
65
142
 
66
- roapRequest.attachRechabilityData = sinon.stub().returns(Promise.resolve(newSdp));
67
- webex.request.returns(Promise.resolve({
143
+ roapRequest.attachReachabilityData = sinon.stub().returns(
144
+ Promise.resolve({
145
+ localSdp: newSdp,
146
+ joinCookie: {
147
+ anycastEntryPoint: 'aws-eu-west-1',
148
+ },
149
+ })
150
+ );
151
+ webex.request.returns(
152
+ Promise.resolve({
68
153
  body: {
69
- locus: {}
70
- }
71
- }))
154
+ locus: {},
155
+ },
156
+ })
157
+ );
158
+
159
+ const result = await roapRequest.sendRoap({
160
+ roapMessage: {
161
+ seq: 1,
162
+ },
163
+ locusSelfUrl: 'locusSelfUrl',
164
+ mediaId: 'mediaId',
165
+ correlationId: 'correlationId',
166
+ audioMuted: true,
167
+ videoMuted: true,
168
+ meetingId: 'meetingId',
169
+ preferTranscoding: true,
170
+ });
72
171
 
73
- const result = await roapRequest.sendRoap({
74
- roapMessage: {seq: 1},
75
- locusSelfUrl: 'locusSelfUrl',
76
- mediaId: 'mediaId',
77
- correlationId: 'correlationId',
78
- audioMuted: true,
79
- videoMuted: true,
80
- meetingId: 'meetingId',
81
- preferTranscoding: true
82
- });
172
+ const requestParams = roapRequest.request.getCall(0).args[0];
83
173
 
84
- assert.calledOnceWithExactly(webex.request, {
85
- uri: 'locusSelfUrl/media',
86
- method: 'PUT',
87
- body: {
88
- device: {
89
- url: undefined,
90
- deviceType: undefined,
91
- },
92
- correlationId: 'correlationId',
93
- localMedias: [{
174
+ assert.deepEqual(requestParams, {
175
+ uri: 'locusSelfUrl/media',
176
+ method: 'PUT',
177
+ body: {
178
+ device: {
179
+ url: 'url',
180
+ deviceType: undefined,
181
+ },
182
+ correlationId: 'correlationId',
183
+ localMedias: [
184
+ {
94
185
  localSdp: JSON.stringify(newSdp),
95
- mediaId: 'mediaId'
96
- }],
97
- clientMediaPreferences: {preferTranscoding: true}
186
+ mediaId: 'mediaId',
187
+ },
188
+ ],
189
+ clientMediaPreferences: {
190
+ joinCookie: {
191
+ anycastEntryPoint: 'aws-eu-west-1',
192
+ },
193
+ preferTranscoding: true,
98
194
  },
99
- });
195
+ },
196
+ });
100
197
 
101
- assert.calledOnceWithExactly(roapRequest.attachRechabilityData, {
102
- roapMessage: {seq: 1},
103
- audioMuted: true,
104
- videoMuted: true
105
- })
198
+ assert.calledOnceWithExactly(roapRequest.attachReachabilityData, {
199
+ roapMessage: {
200
+ seq: 1,
201
+ },
202
+ audioMuted: true,
203
+ videoMuted: true,
204
+ });
106
205
 
107
- assert.deepEqual(result, {
108
- locus: {
109
- roapSeq: 1
110
- }
111
- });
206
+ assert.deepEqual(result, {
207
+ locus: {
208
+ fullState: {
209
+ lastActive: 'lastActive',
210
+ },
211
+ id: '',
212
+ roapSeq: 1,
213
+ url: 'url/path',
214
+ }
112
215
  });
113
- })
216
+ });
114
217
  });