@webex/webex-core 3.12.0-next.8 → 3.12.0-task-refactor.1

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.
@@ -510,19 +510,13 @@ describe('webex-core', () => {
510
510
  );
511
511
 
512
512
  it('resolves to an authed u2c hostmap when no params specified', () => {
513
- assert.typeOf(fullRemoteHM, 'object');
514
- assert.property(fullRemoteHM, 'serviceLinks');
515
- assert.property(fullRemoteHM, 'hostCatalog');
516
- assert.equal(fullRemoteHM.format, 'hostmap');
517
- assert.isAbove(Object.keys(fullRemoteHM.serviceLinks).length, 0);
513
+ assert.typeOf(fullRemoteHM, 'array');
514
+ assert.isAbove(fullRemoteHM.length, 0);
518
515
  });
519
516
 
520
517
  it('resolves to a limited u2c hostmap when params specified', () => {
521
- assert.typeOf(limitedRemoteHM, 'object');
522
- assert.property(limitedRemoteHM, 'serviceLinks');
523
- assert.property(limitedRemoteHM, 'hostCatalog');
524
- assert.equal(limitedRemoteHM.format, 'hostmap');
525
- assert.isAbove(Object.keys(limitedRemoteHM.serviceLinks).length, 0);
518
+ assert.typeOf(limitedRemoteHM, 'array');
519
+ assert.isAbove(limitedRemoteHM.length, 0);
526
520
  });
527
521
 
528
522
  it('rejects if the params provided are invalid', () =>
@@ -404,13 +404,10 @@ describe('webex-core', () => {
404
404
  assert.isTrue(catalog.isReady);
405
405
  });
406
406
 
407
- it('should call services#initServiceCatalogs() on webex ready', async () => {
408
- services._loadCatalogFromCache = sinon.stub().resolves(false);
407
+ it('should call services#initServiceCatalogs() on webex ready', () => {
409
408
  services.initServiceCatalogs = sinon.stub().resolves();
410
409
  services.initialize();
411
410
  webex.trigger('ready');
412
- // Wait for the async 'ready' handler to complete
413
- await new Promise((resolve) => setTimeout(resolve, 50));
414
411
  assert.called(services.initServiceCatalogs);
415
412
  assert.isTrue(catalog.isReady);
416
413
  });
@@ -700,11 +697,7 @@ describe('webex-core', () => {
700
697
 
701
698
  it('updates query.email to be emailhash-ed using SHA256', (done) => {
702
699
  catalog.updateServiceUrls = sinon.stub().returns({}); // returns `this`
703
- services._fetchNewServiceHostmap = sinon.stub().resolves({
704
- serviceLinks: {},
705
- hostCatalog: {},
706
- format: 'hostmap',
707
- });
700
+ services._fetchNewServiceHostmap = sinon.stub().resolves();
708
701
 
709
702
  services
710
703
  .updateServices({
@@ -834,12 +827,9 @@ describe('webex-core', () => {
834
827
 
835
828
  const getActivationRequest = (requestStub, useUserOnboarding = false) => {
836
829
  const expectedService = useUserOnboarding ? 'user-onboarding' : 'license';
837
- const expectedResource = useUserOnboarding
838
- ? 'api/v1/users/activations'
839
- : 'users/activations';
830
+ const expectedResource = useUserOnboarding ? 'api/v1/users/activations' : 'users/activations';
840
831
  const requests = requestStub.args.filter(
841
- ([request]) =>
842
- request.service === expectedService && request.resource === expectedResource
832
+ ([request]) => request.service === expectedService && request.resource === expectedResource
843
833
  );
844
834
 
845
835
  assert.strictEqual(requests.length, 1);
@@ -918,7 +908,7 @@ describe('webex-core', () => {
918
908
  assert.equal(Object.keys(unauthServices.list(false, 'postauth')).length, 0);
919
909
  }));
920
910
 
921
- it('validates new user with activationOptions suppressEmail true', () =>
911
+ it.skip('validates new user with activationOptions suppressEmail true', () =>
922
912
  unauthServices
923
913
  .validateUser({
924
914
  email: `Collabctg+webex-js-sdk-${uuid.v4()}@gmail.com`,
@@ -1264,19 +1254,13 @@ describe('webex-core', () => {
1264
1254
  );
1265
1255
 
1266
1256
  it('resolves to an authed u2c hostmap when no params specified', () => {
1267
- assert.typeOf(fullRemoteHM, 'object');
1268
- assert.property(fullRemoteHM, 'serviceLinks');
1269
- assert.property(fullRemoteHM, 'hostCatalog');
1270
- assert.equal(fullRemoteHM.format, 'hostmap');
1271
- assert.isAbove(Object.keys(fullRemoteHM.serviceLinks).length, 0);
1257
+ assert.typeOf(fullRemoteHM, 'array');
1258
+ assert.isAbove(fullRemoteHM.length, 0);
1272
1259
  });
1273
1260
 
1274
1261
  it('resolves to a limited u2c hostmap when params specified', () => {
1275
- assert.typeOf(limitedRemoteHM, 'object');
1276
- assert.property(limitedRemoteHM, 'serviceLinks');
1277
- assert.property(limitedRemoteHM, 'hostCatalog');
1278
- assert.equal(limitedRemoteHM.format, 'hostmap');
1279
- assert.isAbove(Object.keys(limitedRemoteHM.serviceLinks).length, 0);
1262
+ assert.typeOf(limitedRemoteHM, 'array');
1263
+ assert.isAbove(limitedRemoteHM.length, 0);
1280
1264
  });
1281
1265
 
1282
1266
  it('rejects if the params provided are invalid', () =>
@@ -23,7 +23,7 @@ import {
23
23
  formattedServiceHostmapEntryConv,
24
24
  formattedServiceHostmapEntryMercury,
25
25
  formattedServiceHostmapEntryTest,
26
- serviceHostmapV2,
26
+ serviceHostmapV2
27
27
  } from '../../../fixtures/host-catalog-v2';
28
28
 
29
29
  // /* eslint-disable no-underscore-dangle */
@@ -316,13 +316,10 @@ describe('webex-core', () => {
316
316
  assert.isTrue(catalog.isReady);
317
317
  });
318
318
 
319
- it('should call services#initServiceCatalogs() on webex ready', async () => {
320
- services._loadCatalogFromCache = sinon.stub().resolves(false);
319
+ it('should call services#initServiceCatalogs() on webex ready', () => {
321
320
  services.initServiceCatalogs = sinon.stub().resolves();
322
321
  services.initialize();
323
322
  webex.trigger('ready');
324
- // Wait for the async 'ready' handler to complete
325
- await new Promise((resolve) => setTimeout(resolve, 50));
326
323
  assert.called(services.initServiceCatalogs);
327
324
  assert.isTrue(catalog.isReady);
328
325
  });
@@ -416,11 +413,7 @@ describe('webex-core', () => {
416
413
  .initServiceCatalogs(true)
417
414
  // services#updateServices() gets called once by the limited catalog
418
415
  // retrieval and should get called again when authorized.
419
- .then(
420
- () =>
421
- assert.calledTwice(services.updateServices) &&
422
- assert.calledWith(services.updateServices, sinon.match({forceRefresh: true}))
423
- )
416
+ .then(() => assert.calledTwice(services.updateServices) && assert.calledWith(services.updateServices, sinon.match({forceRefresh: true})))
424
417
  );
425
418
  });
426
419
  });
@@ -757,12 +750,9 @@ describe('webex-core', () => {
757
750
 
758
751
  const getActivationRequest = (requestStub, useUserOnboarding = false) => {
759
752
  const expectedService = useUserOnboarding ? 'user-onboarding' : 'license';
760
- const expectedResource = useUserOnboarding
761
- ? 'api/v1/users/activations'
762
- : 'users/activations';
753
+ const expectedResource = useUserOnboarding ? 'api/v1/users/activations' : 'users/activations';
763
754
  const requests = requestStub.args.filter(
764
- ([request]) =>
765
- request.service === expectedService && request.resource === expectedResource
755
+ ([request]) => request.service === expectedService && request.resource === expectedResource
766
756
  );
767
757
 
768
758
  assert.strictEqual(requests.length, 1);
@@ -835,7 +825,7 @@ describe('webex-core', () => {
835
825
  assert.equal(r.user.verificationEmailTriggered, true);
836
826
  }));
837
827
 
838
- it('validates new user with activationOptions suppressEmail true', () =>
828
+ it.skip('validates new user with activationOptions suppressEmail true', () =>
839
829
  unauthServices
840
830
  .validateUser({
841
831
  email: `Collabctg+webex-js-sdk-${uuid.v4()}@gmail.com`,
@@ -151,116 +151,6 @@ describe('webex-core', () => {
151
151
 
152
152
  assert.isTrue(homeClusterUrls.every((host) => !host.failed));
153
153
  });
154
-
155
- describe('when hosts have negative priorities', () => {
156
- it('should return defaultUrl when all hosts have negative priorities', () => {
157
- const negativeServiceUrl = new ServiceUrl({
158
- defaultUrl: 'https://default.example.com/api/v1',
159
- hosts: [
160
- {
161
- host: 'example-host-neg1.com',
162
- priority: -1,
163
- ttl: -1,
164
- id: '1',
165
- homeCluster: true,
166
- },
167
- {
168
- host: 'example-host-neg2.com',
169
- priority: -1,
170
- ttl: -1,
171
- id: '2',
172
- homeCluster: true,
173
- },
174
- ],
175
- name: 'negative-priority-test',
176
- });
177
-
178
- assert.equal(
179
- negativeServiceUrl._getPriorityHostUrl(),
180
- 'https://default.example.com/api/v1'
181
- );
182
- });
183
-
184
- it('should return defaultUrl when all hosts have zero priority', () => {
185
- const zeroServiceUrl = new ServiceUrl({
186
- defaultUrl: 'https://default.example.com/api/v1',
187
- hosts: [
188
- {
189
- host: 'example-host-zero.com',
190
- priority: 0,
191
- ttl: -1,
192
- id: '1',
193
- homeCluster: true,
194
- },
195
- ],
196
- name: 'zero-priority-test',
197
- });
198
-
199
- assert.equal(zeroServiceUrl._getPriorityHostUrl(), 'https://default.example.com/api/v1');
200
- });
201
-
202
- it('should ignore hosts with negative priorities and return valid host', () => {
203
- const mixedServiceUrl = new ServiceUrl({
204
- defaultUrl: 'https://default.example.com/api/v1',
205
- hosts: [
206
- {
207
- host: 'example-host-neg.com',
208
- priority: -1,
209
- ttl: -1,
210
- id: '1',
211
- homeCluster: true,
212
- },
213
- {
214
- host: 'example-host-valid.com',
215
- priority: 5,
216
- ttl: -1,
217
- id: '2',
218
- homeCluster: true,
219
- },
220
- ],
221
- name: 'mixed-priority-test',
222
- });
223
-
224
- const result = mixedServiceUrl._getPriorityHostUrl();
225
-
226
- assert.include(result, 'example-host-valid.com');
227
- assert.notInclude(result, 'example-host-neg.com');
228
- });
229
-
230
- it('should select lowest positive priority host when mixed with negative priorities', () => {
231
- const mixedServiceUrl = new ServiceUrl({
232
- defaultUrl: 'https://default.example.com/api/v1',
233
- hosts: [
234
- {
235
- host: 'example-host-neg.com',
236
- priority: -1,
237
- ttl: -1,
238
- id: '1',
239
- homeCluster: true,
240
- },
241
- {
242
- host: 'example-host-p5.com',
243
- priority: 5,
244
- ttl: -1,
245
- id: '2',
246
- homeCluster: true,
247
- },
248
- {
249
- host: 'example-host-p2.com',
250
- priority: 2,
251
- ttl: -1,
252
- id: '3',
253
- homeCluster: true,
254
- },
255
- ],
256
- name: 'mixed-priority-test',
257
- });
258
-
259
- const result = mixedServiceUrl._getPriorityHostUrl();
260
-
261
- assert.include(result, 'example-host-p2.com');
262
- });
263
- });
264
154
  });
265
155
 
266
156
  describe('#failHost()', () => {