@app-connect/core 1.7.5 → 1.7.10

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.
@@ -268,4 +268,149 @@ describe('ConnectorRegistry Interface Registration with Composition', () => {
268
268
  expect(composedConnector.getAuthType).toBeDefined();
269
269
  expect(await composedConnector.getAuthType()).toBe('apiKey');
270
270
  });
271
+
272
+ test('should set and get default manifest', () => {
273
+ const defaultManifest = {
274
+ name: 'Default CRM',
275
+ version: '1.0.0',
276
+ features: ['call_logging', 'contact_sync']
277
+ };
278
+
279
+ connectorRegistry.setDefaultManifest(defaultManifest);
280
+
281
+ // Get manifest with fallback should return default
282
+ const manifest = connectorRegistry.getManifest('nonExistentPlatform', true);
283
+ expect(manifest).toEqual(defaultManifest);
284
+ });
285
+
286
+ test('should throw error when getting manifest without fallback and platform not found', () => {
287
+ expect(() => {
288
+ connectorRegistry.getManifest('nonExistentPlatform', false);
289
+ }).toThrow('Manifest not found for platform: nonExistentPlatform');
290
+ });
291
+
292
+ test('should throw error when getting manifest with fallback but no default set', () => {
293
+ connectorRegistry.manifests.clear();
294
+ expect(() => {
295
+ connectorRegistry.getManifest('nonExistentPlatform', true);
296
+ }).toThrow('Manifest not found for platform: nonExistentPlatform');
297
+ });
298
+
299
+ test('should register connector with manifest', () => {
300
+ const mockConnector = {
301
+ getAuthType: () => 'apiKey',
302
+ createCallLog: jest.fn(),
303
+ updateCallLog: jest.fn()
304
+ };
305
+ const manifest = {
306
+ name: 'Test CRM',
307
+ version: '2.0.0',
308
+ authType: 'oauth'
309
+ };
310
+
311
+ connectorRegistry.registerConnector('testPlatformWithManifest', mockConnector, manifest);
312
+
313
+ const retrievedManifest = connectorRegistry.getManifest('testPlatformWithManifest');
314
+ expect(retrievedManifest).toEqual(manifest);
315
+ });
316
+
317
+ test('should set and get release notes', () => {
318
+ const releaseNotes = {
319
+ version: '1.5.0',
320
+ date: '2024-01-15',
321
+ changes: ['Bug fixes', 'New features']
322
+ };
323
+
324
+ connectorRegistry.setReleaseNotes(releaseNotes);
325
+
326
+ // getReleaseNotes currently returns the same object regardless of platform
327
+ const notes = connectorRegistry.getReleaseNotes('anyPlatform');
328
+ expect(notes).toEqual(releaseNotes);
329
+ });
330
+
331
+ test('should get registered platforms', () => {
332
+ const connector1 = {
333
+ getAuthType: () => 'apiKey',
334
+ createCallLog: jest.fn(),
335
+ updateCallLog: jest.fn()
336
+ };
337
+ const connector2 = {
338
+ getAuthType: () => 'oauth',
339
+ createCallLog: jest.fn(),
340
+ updateCallLog: jest.fn()
341
+ };
342
+
343
+ connectorRegistry.registerConnector('platform1', connector1);
344
+ connectorRegistry.registerConnector('platform2', connector2);
345
+
346
+ const platforms = connectorRegistry.getRegisteredPlatforms();
347
+ expect(platforms).toContain('platform1');
348
+ expect(platforms).toContain('platform2');
349
+ expect(platforms).toHaveLength(2);
350
+ });
351
+
352
+ test('should check if platform is registered', () => {
353
+ const mockConnector = {
354
+ getAuthType: () => 'apiKey',
355
+ createCallLog: jest.fn(),
356
+ updateCallLog: jest.fn()
357
+ };
358
+
359
+ connectorRegistry.registerConnector('registeredPlatform', mockConnector);
360
+
361
+ expect(connectorRegistry.isRegistered('registeredPlatform')).toBe(true);
362
+ expect(connectorRegistry.isRegistered('unregisteredPlatform')).toBe(false);
363
+ });
364
+
365
+ test('should throw error for original connector when not found', () => {
366
+ expect(() => {
367
+ connectorRegistry.getOriginalConnector('nonExistentPlatform');
368
+ }).toThrow('Connector not found for platform: nonExistentPlatform');
369
+ });
370
+
371
+ test('should validate connector interface with missing required methods', () => {
372
+ const incompleteConnector = {
373
+ getAuthType: () => 'apiKey',
374
+ createCallLog: jest.fn()
375
+ // Missing updateCallLog
376
+ };
377
+
378
+ expect(() => {
379
+ connectorRegistry.registerConnector('incompletePlatform', incompleteConnector);
380
+ }).toThrow('Connector incompletePlatform missing required method: updateCallLog');
381
+ });
382
+
383
+ test('should return proxy connector when platform not found but proxy exists', () => {
384
+ const proxyConnector = {
385
+ getAuthType: () => 'proxy',
386
+ createCallLog: jest.fn(),
387
+ updateCallLog: jest.fn(),
388
+ proxy: true
389
+ };
390
+
391
+ connectorRegistry.registerConnector('proxy', proxyConnector);
392
+
393
+ const connector = connectorRegistry.getConnector('unknownPlatformWithProxy');
394
+ expect(connector).toBe(proxyConnector);
395
+ expect(connector.proxy).toBe(true);
396
+ });
397
+
398
+ test('should handle getAuthType error in getConnectorCapabilities', async () => {
399
+ const mockConnector = {
400
+ getAuthType: jest.fn().mockRejectedValue(new Error('Auth type error')),
401
+ createCallLog: jest.fn(),
402
+ updateCallLog: jest.fn()
403
+ };
404
+
405
+ connectorRegistry.registerConnector('errorPlatform', mockConnector);
406
+
407
+ const capabilities = await connectorRegistry.getConnectorCapabilities('errorPlatform');
408
+ expect(capabilities.authType).toBe('unknown');
409
+ });
410
+
411
+ test('should handle unregistering non-existent interface gracefully', () => {
412
+ // This should not throw
413
+ connectorRegistry.unregisterConnectorInterface('nonExistentPlatform', 'nonExistentInterface');
414
+ expect(connectorRegistry.hasPlatformInterface('nonExistentPlatform', 'nonExistentInterface')).toBe(false);
415
+ });
271
416
  });