@webex/contact-center 3.9.0-next.9 → 3.10.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/dist/cc.js +182 -47
- package/dist/cc.js.map +1 -1
- package/dist/constants.js +1 -0
- package/dist/constants.js.map +1 -1
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -1
- package/dist/logger-proxy.js +24 -1
- package/dist/logger-proxy.js.map +1 -1
- package/dist/metrics/behavioral-events.js +89 -0
- package/dist/metrics/behavioral-events.js.map +1 -1
- package/dist/metrics/constants.js +30 -2
- package/dist/metrics/constants.js.map +1 -1
- package/dist/services/AddressBook.js +271 -0
- package/dist/services/AddressBook.js.map +1 -0
- package/dist/services/EntryPoint.js +227 -0
- package/dist/services/EntryPoint.js.map +1 -0
- package/dist/services/Queue.js +261 -0
- package/dist/services/Queue.js.map +1 -0
- package/dist/services/config/constants.js +36 -2
- package/dist/services/config/constants.js.map +1 -1
- package/dist/services/config/index.js +29 -21
- package/dist/services/config/index.js.map +1 -1
- package/dist/services/config/types.js +33 -1
- package/dist/services/config/types.js.map +1 -1
- package/dist/services/core/Utils.js +42 -1
- package/dist/services/core/Utils.js.map +1 -1
- package/dist/services/task/TaskManager.js +113 -3
- package/dist/services/task/TaskManager.js.map +1 -1
- package/dist/services/task/TaskUtils.js +76 -0
- package/dist/services/task/TaskUtils.js.map +1 -0
- package/dist/services/task/constants.js +26 -1
- package/dist/services/task/constants.js.map +1 -1
- package/dist/services/task/contact.js +86 -0
- package/dist/services/task/contact.js.map +1 -1
- package/dist/services/task/index.js +241 -5
- package/dist/services/task/index.js.map +1 -1
- package/dist/services/task/types.js +14 -0
- package/dist/services/task/types.js.map +1 -1
- package/dist/types/cc.d.ts +115 -35
- package/dist/types/constants.d.ts +1 -0
- package/dist/types/index.d.ts +3 -2
- package/dist/types/metrics/constants.d.ts +24 -1
- package/dist/types/services/AddressBook.d.ts +74 -0
- package/dist/types/services/EntryPoint.d.ts +67 -0
- package/dist/types/services/Queue.d.ts +76 -0
- package/dist/types/services/config/constants.d.ts +35 -1
- package/dist/types/services/config/index.d.ts +6 -9
- package/dist/types/services/config/types.d.ts +79 -58
- package/dist/types/services/core/Utils.d.ts +14 -1
- package/dist/types/services/task/TaskUtils.d.ts +28 -0
- package/dist/types/services/task/constants.d.ts +23 -0
- package/dist/types/services/task/contact.d.ts +10 -0
- package/dist/types/services/task/index.d.ts +64 -1
- package/dist/types/services/task/types.d.ts +221 -19
- package/dist/types/types.d.ts +162 -0
- package/dist/types/utils/PageCache.d.ts +173 -0
- package/dist/types.js +17 -0
- package/dist/types.js.map +1 -1
- package/dist/utils/PageCache.js +192 -0
- package/dist/utils/PageCache.js.map +1 -0
- package/dist/webex.js +1 -1
- package/package.json +10 -9
- package/src/cc.ts +206 -52
- package/src/constants.ts +1 -0
- package/src/index.ts +16 -2
- package/src/logger-proxy.ts +24 -1
- package/src/metrics/behavioral-events.ts +94 -0
- package/src/metrics/constants.ts +34 -1
- package/src/services/AddressBook.ts +291 -0
- package/src/services/EntryPoint.ts +241 -0
- package/src/services/Queue.ts +277 -0
- package/src/services/config/constants.ts +42 -2
- package/src/services/config/index.ts +30 -30
- package/src/services/config/types.ts +59 -58
- package/src/services/core/Utils.ts +44 -0
- package/src/services/task/TaskManager.ts +122 -5
- package/src/services/task/TaskUtils.ts +81 -0
- package/src/services/task/constants.ts +25 -0
- package/src/services/task/contact.ts +80 -0
- package/src/services/task/index.ts +300 -4
- package/src/services/task/types.ts +239 -18
- package/src/types.ts +180 -0
- package/src/utils/PageCache.ts +252 -0
- package/test/unit/spec/cc.ts +282 -85
- package/test/unit/spec/metrics/behavioral-events.ts +42 -0
- package/test/unit/spec/services/AddressBook.ts +332 -0
- package/test/unit/spec/services/EntryPoint.ts +259 -0
- package/test/unit/spec/services/Queue.ts +323 -0
- package/test/unit/spec/services/config/index.ts +279 -65
- package/test/unit/spec/services/task/TaskManager.ts +382 -0
- package/test/unit/spec/services/task/TaskUtils.ts +131 -0
- package/test/unit/spec/services/task/contact.ts +31 -1
- package/test/unit/spec/services/task/index.ts +242 -8
- package/umd/contact-center.min.js +2 -2
- package/umd/contact-center.min.js.map +1 -1
package/test/unit/spec/cc.ts
CHANGED
|
@@ -7,6 +7,11 @@ import {
|
|
|
7
7
|
WebexSDK,
|
|
8
8
|
} from '../../../src/types';
|
|
9
9
|
import ContactCenter from '../../../src/cc';
|
|
10
|
+
import EntryPoint from '../../../src/services/EntryPoint';
|
|
11
|
+
import type {EntryPointListResponse} from '../../../src/types';
|
|
12
|
+
import AddressBook from '../../../src/services/AddressBook';
|
|
13
|
+
import Queue from '../../../src/services/Queue';
|
|
14
|
+
import type {ContactServiceQueuesResponse} from '../../../src/types';
|
|
10
15
|
import MockWebex from '@webex/test-helper-mock-webex';
|
|
11
16
|
import {StationLoginSuccess, AGENT_EVENTS} from '../../../src/services/agent/types';
|
|
12
17
|
import {SetStateResponse} from '../../../src/types';
|
|
@@ -113,6 +118,7 @@ describe('webex.cc', () => {
|
|
|
113
118
|
},
|
|
114
119
|
config: {
|
|
115
120
|
getAgentConfig: jest.fn(),
|
|
121
|
+
getOutdialAniEntries: jest.fn(),
|
|
116
122
|
},
|
|
117
123
|
webSocketManager: mockWebSocketManager,
|
|
118
124
|
connectionService: {
|
|
@@ -134,6 +140,7 @@ describe('webex.cc', () => {
|
|
|
134
140
|
webSocketManager: mockWebSocketManager,
|
|
135
141
|
task: undefined,
|
|
136
142
|
setWrapupData: jest.fn(),
|
|
143
|
+
setAgentId: jest.fn(),
|
|
137
144
|
registerIncomingCallEvent: jest.fn(),
|
|
138
145
|
registerTaskListeners: jest.fn(),
|
|
139
146
|
getTask: jest.fn(),
|
|
@@ -155,7 +162,7 @@ describe('webex.cc', () => {
|
|
|
155
162
|
};
|
|
156
163
|
|
|
157
164
|
jest.spyOn(MetricsManager, 'getInstance').mockReturnValue(mockMetricsManager);
|
|
158
|
-
jest.spyOn(Services, 'getInstance').mockReturnValue(mockServicesInstance);
|
|
165
|
+
jest.spyOn(Services, 'getInstance').mockReturnValue(mockServicesInstance as any);
|
|
159
166
|
jest.spyOn(TaskManager, 'getTaskManager').mockReturnValue(mockTaskManager);
|
|
160
167
|
jest.spyOn(WebexRequest, 'getInstance').mockReturnValue(mockWebexRequest);
|
|
161
168
|
// Instantiate ContactCenter to ensure it's fully initialized
|
|
@@ -1310,7 +1317,7 @@ describe('webex.cc', () => {
|
|
|
1310
1317
|
});
|
|
1311
1318
|
|
|
1312
1319
|
describe('startOutdial', () => {
|
|
1313
|
-
it('should make outdial call successfully.', async () => {
|
|
1320
|
+
it('should make outdial call successfully without origin.', async () => {
|
|
1314
1321
|
// Setup outDialEp.
|
|
1315
1322
|
webex.cc.agentConfig = {
|
|
1316
1323
|
outDialEp: 'test-entry-point',
|
|
@@ -1319,9 +1326,10 @@ describe('webex.cc', () => {
|
|
|
1319
1326
|
// destination number required for making outdial call.
|
|
1320
1327
|
const destination = '1234567890';
|
|
1321
1328
|
|
|
1322
|
-
// Construct Payload for startOutdial.
|
|
1329
|
+
// Construct Payload for startOutdial without origin.
|
|
1323
1330
|
const newPayload = {
|
|
1324
1331
|
destination,
|
|
1332
|
+
origin: undefined,
|
|
1325
1333
|
entryPointId: 'test-entry-point',
|
|
1326
1334
|
direction: OUTDIAL_DIRECTION,
|
|
1327
1335
|
attributes: ATTRIBUTES,
|
|
@@ -1351,6 +1359,49 @@ describe('webex.cc', () => {
|
|
|
1351
1359
|
expect(result).toEqual(mockResponse);
|
|
1352
1360
|
});
|
|
1353
1361
|
|
|
1362
|
+
it('should make outdial call successfully with origin.', async () => {
|
|
1363
|
+
// Setup outDialEp.
|
|
1364
|
+
webex.cc.agentConfig = {
|
|
1365
|
+
outDialEp: 'test-entry-point',
|
|
1366
|
+
};
|
|
1367
|
+
|
|
1368
|
+
// destination number and origin for making outdial call.
|
|
1369
|
+
const destination = '1234567890';
|
|
1370
|
+
const origin = '+19403016307';
|
|
1371
|
+
|
|
1372
|
+
// Construct Payload for startOutdial with origin.
|
|
1373
|
+
const newPayload = {
|
|
1374
|
+
destination,
|
|
1375
|
+
origin,
|
|
1376
|
+
entryPointId: 'test-entry-point',
|
|
1377
|
+
direction: OUTDIAL_DIRECTION,
|
|
1378
|
+
attributes: ATTRIBUTES,
|
|
1379
|
+
mediaType: OUTDIAL_MEDIA_TYPE,
|
|
1380
|
+
outboundType: OUTBOUND_TYPE,
|
|
1381
|
+
} as const;
|
|
1382
|
+
|
|
1383
|
+
const mockResponse = {} as AgentContact;
|
|
1384
|
+
|
|
1385
|
+
const startOutdialMock = jest
|
|
1386
|
+
.spyOn(webex.cc.services.dialer, 'startOutdial')
|
|
1387
|
+
.mockResolvedValue(mockResponse);
|
|
1388
|
+
|
|
1389
|
+
const result = await webex.cc.startOutdial(destination, origin);
|
|
1390
|
+
|
|
1391
|
+
// Verify logging calls
|
|
1392
|
+
expect(LoggerProxy.info).toHaveBeenCalledWith('Starting outbound dial', {
|
|
1393
|
+
module: CC_FILE,
|
|
1394
|
+
method: 'startOutdial',
|
|
1395
|
+
});
|
|
1396
|
+
expect(LoggerProxy.log).toHaveBeenCalledWith('Outbound dial completed successfully', {
|
|
1397
|
+
module: CC_FILE,
|
|
1398
|
+
method: 'startOutdial',
|
|
1399
|
+
});
|
|
1400
|
+
|
|
1401
|
+
expect(startOutdialMock).toHaveBeenCalledWith({data: newPayload});
|
|
1402
|
+
expect(result).toEqual(mockResponse);
|
|
1403
|
+
});
|
|
1404
|
+
|
|
1354
1405
|
it('should handle error during startOutdial', async () => {
|
|
1355
1406
|
// Setup outDialEp.
|
|
1356
1407
|
webex.cc.agentConfig = {
|
|
@@ -1387,88 +1438,6 @@ describe('webex.cc', () => {
|
|
|
1387
1438
|
});
|
|
1388
1439
|
});
|
|
1389
1440
|
|
|
1390
|
-
describe('getQueues', () => {
|
|
1391
|
-
it('should return queues response when successful', async () => {
|
|
1392
|
-
const mockQueuesResponse = [
|
|
1393
|
-
{
|
|
1394
|
-
queueId: 'queue1',
|
|
1395
|
-
queueName: 'Queue 1',
|
|
1396
|
-
},
|
|
1397
|
-
{
|
|
1398
|
-
queueId: 'queue2',
|
|
1399
|
-
queueName: 'Queue 2',
|
|
1400
|
-
},
|
|
1401
|
-
];
|
|
1402
|
-
|
|
1403
|
-
webex.cc.services.config.getQueues = jest.fn().mockResolvedValue(mockQueuesResponse);
|
|
1404
|
-
|
|
1405
|
-
const result = await webex.cc.getQueues();
|
|
1406
|
-
|
|
1407
|
-
// Verify logging calls
|
|
1408
|
-
expect(LoggerProxy.info).toHaveBeenCalledWith('Fetching queues', {
|
|
1409
|
-
module: CC_FILE,
|
|
1410
|
-
method: 'getQueues',
|
|
1411
|
-
});
|
|
1412
|
-
expect(LoggerProxy.log).toHaveBeenCalledWith(
|
|
1413
|
-
`Successfully retrieved ${result.length} queues`,
|
|
1414
|
-
{
|
|
1415
|
-
module: CC_FILE,
|
|
1416
|
-
method: 'getQueues',
|
|
1417
|
-
}
|
|
1418
|
-
);
|
|
1419
|
-
|
|
1420
|
-
expect(webex.cc.services.config.getQueues).toHaveBeenCalledWith(
|
|
1421
|
-
'mockOrgId',
|
|
1422
|
-
0,
|
|
1423
|
-
100,
|
|
1424
|
-
undefined,
|
|
1425
|
-
undefined
|
|
1426
|
-
);
|
|
1427
|
-
expect(result).toEqual(mockQueuesResponse);
|
|
1428
|
-
});
|
|
1429
|
-
|
|
1430
|
-
it('should throw an error if orgId is not present', async () => {
|
|
1431
|
-
jest.spyOn(webex.credentials, 'getOrgId').mockResolvedValue(undefined);
|
|
1432
|
-
webex.cc.services.config.getQueues = jest.fn();
|
|
1433
|
-
|
|
1434
|
-
try {
|
|
1435
|
-
await webex.cc.getQueues();
|
|
1436
|
-
} catch (error) {
|
|
1437
|
-
expect(error).toEqual(new Error('Org ID not found.'));
|
|
1438
|
-
expect(LoggerProxy.info).toHaveBeenCalledWith('Fetching queues', {
|
|
1439
|
-
module: CC_FILE,
|
|
1440
|
-
method: 'getQueues',
|
|
1441
|
-
});
|
|
1442
|
-
expect(LoggerProxy.error).toHaveBeenCalledWith('Org ID not found.', {
|
|
1443
|
-
module: CC_FILE,
|
|
1444
|
-
method: 'getQueues',
|
|
1445
|
-
});
|
|
1446
|
-
expect(webex.cc.services.config.getQueues).not.toHaveBeenCalled();
|
|
1447
|
-
}
|
|
1448
|
-
});
|
|
1449
|
-
|
|
1450
|
-
it('should throw an error if config getQueues throws an error', async () => {
|
|
1451
|
-
webex.cc.services.config.getQueues = jest.fn().mockRejectedValue(new Error('Test error.'));
|
|
1452
|
-
|
|
1453
|
-
try {
|
|
1454
|
-
await webex.cc.getQueues();
|
|
1455
|
-
} catch (error) {
|
|
1456
|
-
expect(error).toEqual(new Error('Test error.'));
|
|
1457
|
-
expect(LoggerProxy.info).toHaveBeenCalledWith('Fetching queues', {
|
|
1458
|
-
module: CC_FILE,
|
|
1459
|
-
method: 'getQueues',
|
|
1460
|
-
});
|
|
1461
|
-
expect(webex.cc.services.config.getQueues).toHaveBeenCalledWith(
|
|
1462
|
-
'mockOrgId',
|
|
1463
|
-
0,
|
|
1464
|
-
100,
|
|
1465
|
-
undefined,
|
|
1466
|
-
undefined
|
|
1467
|
-
);
|
|
1468
|
-
}
|
|
1469
|
-
});
|
|
1470
|
-
});
|
|
1471
|
-
|
|
1472
1441
|
describe('uploadLogs', () => {
|
|
1473
1442
|
it('should upload logs successfully', async () => {
|
|
1474
1443
|
const uploadLogsMock = jest.spyOn(webex.cc.webexRequest, 'uploadLogs').mockResolvedValue({
|
|
@@ -1796,6 +1765,31 @@ describe('webex.cc', () => {
|
|
|
1796
1765
|
});
|
|
1797
1766
|
});
|
|
1798
1767
|
|
|
1768
|
+
describe('API property exposure', () => {
|
|
1769
|
+
it('should provide getEntryPoints wrapper that delegates to EntryPoint', async () => {
|
|
1770
|
+
const spy = jest
|
|
1771
|
+
.spyOn(EntryPoint.prototype, 'getEntryPoints')
|
|
1772
|
+
.mockResolvedValue({} as EntryPointListResponse);
|
|
1773
|
+
await webex.cc.getEntryPoints();
|
|
1774
|
+
expect(spy).toHaveBeenCalled();
|
|
1775
|
+
spy.mockRestore();
|
|
1776
|
+
});
|
|
1777
|
+
|
|
1778
|
+
it('should expose addressBook API', () => {
|
|
1779
|
+
expect(webex.cc.addressBook).toBeDefined();
|
|
1780
|
+
expect(webex.cc.addressBook).toBeInstanceOf(AddressBook);
|
|
1781
|
+
});
|
|
1782
|
+
|
|
1783
|
+
it('should provide getQueues wrapper that delegates to Queue', async () => {
|
|
1784
|
+
const spy = jest
|
|
1785
|
+
.spyOn(Queue.prototype, 'getQueues')
|
|
1786
|
+
.mockResolvedValue({} as ContactServiceQueuesResponse);
|
|
1787
|
+
await webex.cc.getQueues();
|
|
1788
|
+
expect(spy).toHaveBeenCalled();
|
|
1789
|
+
spy.mockRestore();
|
|
1790
|
+
});
|
|
1791
|
+
});
|
|
1792
|
+
|
|
1799
1793
|
describe('updateAgentProfile', () => {
|
|
1800
1794
|
beforeEach(() => {
|
|
1801
1795
|
webex.cc.agentConfig = {
|
|
@@ -1982,4 +1976,207 @@ describe('webex.cc', () => {
|
|
|
1982
1976
|
});
|
|
1983
1977
|
});
|
|
1984
1978
|
});
|
|
1979
|
+
|
|
1980
|
+
describe('getOutdialAniEntries', () => {
|
|
1981
|
+
const mockOutdialANI = 'ani-123-456';
|
|
1982
|
+
const mockParams = {
|
|
1983
|
+
outdialANI: mockOutdialANI,
|
|
1984
|
+
page: 0,
|
|
1985
|
+
pageSize: 10,
|
|
1986
|
+
search: 'test',
|
|
1987
|
+
filter: 'active=true',
|
|
1988
|
+
attributes: 'id,name,number',
|
|
1989
|
+
};
|
|
1990
|
+
|
|
1991
|
+
beforeEach(() => {
|
|
1992
|
+
jest.clearAllMocks();
|
|
1993
|
+
// Reset orgId mock to return valid value
|
|
1994
|
+
webex.credentials.getOrgId.mockReturnValue('mockOrgId');
|
|
1995
|
+
});
|
|
1996
|
+
|
|
1997
|
+
it('should successfully fetch outdial ANI entries and track success metrics', async () => {
|
|
1998
|
+
const mockResult = [
|
|
1999
|
+
{
|
|
2000
|
+
id: '142fba3c-8502-4446-bf6e-584fd657553a',
|
|
2001
|
+
name: 'Test Entry',
|
|
2002
|
+
number: '+19403016307',
|
|
2003
|
+
},
|
|
2004
|
+
{
|
|
2005
|
+
id: '6f53000b-e04a-4418-9de9-ba511d2367cb',
|
|
2006
|
+
name: 'Another Entry',
|
|
2007
|
+
number: '+19403016308',
|
|
2008
|
+
},
|
|
2009
|
+
];
|
|
2010
|
+
|
|
2011
|
+
// Mock the service call to return successful result
|
|
2012
|
+
webex.cc.services.config.getOutdialAniEntries.mockResolvedValue(mockResult);
|
|
2013
|
+
|
|
2014
|
+
const result = await webex.cc.getOutdialAniEntries(mockParams);
|
|
2015
|
+
|
|
2016
|
+
// Verify the service was called with correct parameters
|
|
2017
|
+
expect(webex.cc.services.config.getOutdialAniEntries).toHaveBeenCalledWith('mockOrgId', {
|
|
2018
|
+
outdialANI: mockOutdialANI,
|
|
2019
|
+
page: 0,
|
|
2020
|
+
pageSize: 10,
|
|
2021
|
+
search: 'test',
|
|
2022
|
+
filter: 'active=true',
|
|
2023
|
+
attributes: 'id,name,number',
|
|
2024
|
+
});
|
|
2025
|
+
|
|
2026
|
+
// Verify the result is returned correctly
|
|
2027
|
+
expect(result).toEqual(mockResult);
|
|
2028
|
+
|
|
2029
|
+
// Verify success metrics are tracked
|
|
2030
|
+
expect(mockMetricsManager.trackEvent).toHaveBeenCalledWith(
|
|
2031
|
+
METRIC_EVENT_NAMES.OUTDIAL_ANI_EP_FETCH_SUCCESS,
|
|
2032
|
+
{
|
|
2033
|
+
outdialANI: mockOutdialANI,
|
|
2034
|
+
resultCount: 2,
|
|
2035
|
+
},
|
|
2036
|
+
['behavioral', 'business', 'operational']
|
|
2037
|
+
);
|
|
2038
|
+
|
|
2039
|
+
// Verify success logging
|
|
2040
|
+
expect(LoggerProxy.log).toHaveBeenCalledWith(
|
|
2041
|
+
`Successfully retrieved outdial ANI entries for ANI ID ${mockOutdialANI}`,
|
|
2042
|
+
{
|
|
2043
|
+
module: CC_FILE,
|
|
2044
|
+
method: 'getOutdialAniEntries',
|
|
2045
|
+
}
|
|
2046
|
+
);
|
|
2047
|
+
});
|
|
2048
|
+
|
|
2049
|
+
it('should handle empty results and track success metrics with zero count', async () => {
|
|
2050
|
+
const mockResult = [];
|
|
2051
|
+
|
|
2052
|
+
// Mock the service call to return empty result
|
|
2053
|
+
webex.cc.services.config.getOutdialAniEntries.mockResolvedValue(mockResult);
|
|
2054
|
+
|
|
2055
|
+
const result = await webex.cc.getOutdialAniEntries({outdialANI: mockOutdialANI});
|
|
2056
|
+
|
|
2057
|
+
// Verify the result is returned correctly
|
|
2058
|
+
expect(result).toEqual(mockResult);
|
|
2059
|
+
|
|
2060
|
+
// Verify success metrics are tracked with zero count
|
|
2061
|
+
expect(mockMetricsManager.trackEvent).toHaveBeenCalledWith(
|
|
2062
|
+
METRIC_EVENT_NAMES.OUTDIAL_ANI_EP_FETCH_SUCCESS,
|
|
2063
|
+
{
|
|
2064
|
+
outdialANI: mockOutdialANI,
|
|
2065
|
+
resultCount: 0,
|
|
2066
|
+
},
|
|
2067
|
+
['behavioral', 'business', 'operational']
|
|
2068
|
+
);
|
|
2069
|
+
});
|
|
2070
|
+
|
|
2071
|
+
it('should handle undefined results and track success metrics with zero count', async () => {
|
|
2072
|
+
// Mock the service call to return undefined
|
|
2073
|
+
webex.cc.services.config.getOutdialAniEntries.mockResolvedValue(undefined);
|
|
2074
|
+
|
|
2075
|
+
const result = await webex.cc.getOutdialAniEntries({outdialANI: mockOutdialANI});
|
|
2076
|
+
|
|
2077
|
+
// Verify the result is returned correctly
|
|
2078
|
+
expect(result).toBeUndefined();
|
|
2079
|
+
|
|
2080
|
+
// Verify success metrics are tracked with zero count
|
|
2081
|
+
expect(mockMetricsManager.trackEvent).toHaveBeenCalledWith(
|
|
2082
|
+
METRIC_EVENT_NAMES.OUTDIAL_ANI_EP_FETCH_SUCCESS,
|
|
2083
|
+
{
|
|
2084
|
+
outdialANI: mockOutdialANI,
|
|
2085
|
+
resultCount: 0,
|
|
2086
|
+
},
|
|
2087
|
+
['behavioral', 'business', 'operational']
|
|
2088
|
+
);
|
|
2089
|
+
});
|
|
2090
|
+
|
|
2091
|
+
it('should handle service failure and track failure metrics', async () => {
|
|
2092
|
+
const mockError = new Error('Service unavailable') as any;
|
|
2093
|
+
mockError.details = {
|
|
2094
|
+
trackingId: 'test-tracking-id',
|
|
2095
|
+
orgId: 'mockOrgId',
|
|
2096
|
+
error: 'Service error',
|
|
2097
|
+
};
|
|
2098
|
+
|
|
2099
|
+
// Mock the service call to throw an error
|
|
2100
|
+
webex.cc.services.config.getOutdialAniEntries.mockRejectedValue(mockError);
|
|
2101
|
+
|
|
2102
|
+
// Mock getErrorDetails to return a detailed error
|
|
2103
|
+
const detailedError = new Error('Detailed service error');
|
|
2104
|
+
getErrorDetailsSpy.mockReturnValue({error: detailedError});
|
|
2105
|
+
|
|
2106
|
+
await expect(webex.cc.getOutdialAniEntries(mockParams)).rejects.toThrow('Detailed service error');
|
|
2107
|
+
|
|
2108
|
+
// Verify failure metrics are tracked
|
|
2109
|
+
expect(mockMetricsManager.trackEvent).toHaveBeenCalledWith(
|
|
2110
|
+
METRIC_EVENT_NAMES.OUTDIAL_ANI_EP_FETCH_FAILED,
|
|
2111
|
+
{
|
|
2112
|
+
...MetricsManager.getCommonTrackingFieldForAQMResponseFailed(mockError.details),
|
|
2113
|
+
outdialANI: mockOutdialANI,
|
|
2114
|
+
error: mockError,
|
|
2115
|
+
},
|
|
2116
|
+
['behavioral', 'business', 'operational']
|
|
2117
|
+
);
|
|
2118
|
+
|
|
2119
|
+
// Verify error logging
|
|
2120
|
+
expect(LoggerProxy.error).toHaveBeenCalledWith(
|
|
2121
|
+
`Failed to fetch outdial ANI entries for ANI ID ${mockOutdialANI} due to: ${mockError}`,
|
|
2122
|
+
{
|
|
2123
|
+
module: CC_FILE,
|
|
2124
|
+
method: 'getOutdialAniEntries',
|
|
2125
|
+
trackingId: 'test-tracking-id',
|
|
2126
|
+
}
|
|
2127
|
+
);
|
|
2128
|
+
|
|
2129
|
+
// Verify getErrorDetails was called
|
|
2130
|
+
expect(getErrorDetailsSpy).toHaveBeenCalledWith(
|
|
2131
|
+
mockError,
|
|
2132
|
+
'getOutdialAniEntries',
|
|
2133
|
+
CC_FILE
|
|
2134
|
+
);
|
|
2135
|
+
});
|
|
2136
|
+
|
|
2137
|
+
it('should throw error when orgId is not found', async () => {
|
|
2138
|
+
// Mock getOrgId to return null
|
|
2139
|
+
webex.credentials.getOrgId.mockReturnValue(null);
|
|
2140
|
+
|
|
2141
|
+
await expect(webex.cc.getOutdialAniEntries(mockParams)).rejects.toThrow('Org ID not found.');
|
|
2142
|
+
|
|
2143
|
+
// Verify error logging
|
|
2144
|
+
expect(LoggerProxy.error).toHaveBeenCalledWith('Org ID not found.', {
|
|
2145
|
+
module: CC_FILE,
|
|
2146
|
+
method: 'getOutdialAniEntries',
|
|
2147
|
+
});
|
|
2148
|
+
|
|
2149
|
+
// Verify service was not called
|
|
2150
|
+
expect(webex.cc.services.config.getOutdialAniEntries).not.toHaveBeenCalled();
|
|
2151
|
+
|
|
2152
|
+
// Verify no metrics were tracked
|
|
2153
|
+
expect(mockMetricsManager.trackEvent).not.toHaveBeenCalled();
|
|
2154
|
+
});
|
|
2155
|
+
|
|
2156
|
+
it('should handle minimal parameters correctly', async () => {
|
|
2157
|
+
const minimalParams = {outdialANI: mockOutdialANI};
|
|
2158
|
+
const mockResult = [{id: 'test', name: 'Test', number: '+1234567890'}];
|
|
2159
|
+
|
|
2160
|
+
webex.cc.services.config.getOutdialAniEntries.mockResolvedValue(mockResult);
|
|
2161
|
+
|
|
2162
|
+
const result = await webex.cc.getOutdialAniEntries(minimalParams);
|
|
2163
|
+
|
|
2164
|
+
// Verify the service was called with minimal parameters
|
|
2165
|
+
expect(webex.cc.services.config.getOutdialAniEntries).toHaveBeenCalledWith('mockOrgId', {
|
|
2166
|
+
outdialANI: mockOutdialANI,
|
|
2167
|
+
});
|
|
2168
|
+
|
|
2169
|
+
expect(result).toEqual(mockResult);
|
|
2170
|
+
|
|
2171
|
+
// Verify success metrics are tracked
|
|
2172
|
+
expect(mockMetricsManager.trackEvent).toHaveBeenCalledWith(
|
|
2173
|
+
METRIC_EVENT_NAMES.OUTDIAL_ANI_EP_FETCH_SUCCESS,
|
|
2174
|
+
{
|
|
2175
|
+
outdialANI: mockOutdialANI,
|
|
2176
|
+
resultCount: 1,
|
|
2177
|
+
},
|
|
2178
|
+
['behavioral', 'business', 'operational']
|
|
2179
|
+
);
|
|
2180
|
+
});
|
|
2181
|
+
});
|
|
1985
2182
|
});
|
|
@@ -110,6 +110,48 @@ describe('metrics/behavioral-events', () => {
|
|
|
110
110
|
verb: 'fail',
|
|
111
111
|
});
|
|
112
112
|
|
|
113
|
+
expect(getEventTaxonomy(METRIC_EVENT_NAMES.TASK_CONFERENCE_START_SUCCESS)).toEqual({
|
|
114
|
+
product,
|
|
115
|
+
agent: 'user',
|
|
116
|
+
target: 'task_conference_start',
|
|
117
|
+
verb: 'complete',
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
expect(getEventTaxonomy(METRIC_EVENT_NAMES.TASK_CONFERENCE_START_FAILED)).toEqual({
|
|
121
|
+
product,
|
|
122
|
+
agent: 'user',
|
|
123
|
+
target: 'task_conference_start',
|
|
124
|
+
verb: 'fail',
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
expect(getEventTaxonomy(METRIC_EVENT_NAMES.TASK_CONFERENCE_END_SUCCESS)).toEqual({
|
|
128
|
+
product,
|
|
129
|
+
agent: 'user',
|
|
130
|
+
target: 'task_conference_end',
|
|
131
|
+
verb: 'complete',
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
expect(getEventTaxonomy(METRIC_EVENT_NAMES.TASK_CONFERENCE_END_FAILED)).toEqual({
|
|
135
|
+
product,
|
|
136
|
+
agent: 'user',
|
|
137
|
+
target: 'task_conference_end',
|
|
138
|
+
verb: 'fail',
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
expect(getEventTaxonomy(METRIC_EVENT_NAMES.TASK_CONFERENCE_TRANSFER_SUCCESS)).toEqual({
|
|
142
|
+
product,
|
|
143
|
+
agent: 'user',
|
|
144
|
+
target: 'task_conference_transfer',
|
|
145
|
+
verb: 'complete',
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
expect(getEventTaxonomy(METRIC_EVENT_NAMES.TASK_CONFERENCE_TRANSFER_FAILED)).toEqual({
|
|
149
|
+
product,
|
|
150
|
+
agent: 'user',
|
|
151
|
+
target: 'task_conference_transfer',
|
|
152
|
+
verb: 'fail',
|
|
153
|
+
});
|
|
154
|
+
|
|
113
155
|
expect(getEventTaxonomy('' as METRIC_EVENT_NAMES)).toEqual(undefined);
|
|
114
156
|
});
|
|
115
157
|
});
|