@webex/contact-center 3.9.0-next.14 → 3.9.0-next.16

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.
@@ -66,7 +66,7 @@ describe('AgentConfigService', () => {
66
66
  method: 'GET',
67
67
  });
68
68
  expect(result).toEqual(mockResponse.body);
69
-
69
+
70
70
  expect(LoggerProxy.info).toHaveBeenCalledWith('Fetching user data using CI', {
71
71
  module: CONFIG_FILE_NAME,
72
72
  method: 'getUserUsingCI',
@@ -124,7 +124,7 @@ describe('AgentConfigService', () => {
124
124
  method: 'GET',
125
125
  });
126
126
  expect(result).toEqual(mockResponse.body);
127
-
127
+
128
128
  expect(LoggerProxy.info).toHaveBeenCalledWith('Fetching desktop profile', {
129
129
  module: CONFIG_FILE_NAME,
130
130
  method: 'getDesktopProfileById',
@@ -175,12 +175,7 @@ describe('AgentConfigService', () => {
175
175
  };
176
176
  (mockWebexRequest.request as jest.Mock).mockResolvedValue(mockResponse);
177
177
 
178
- const result = await agentConfigService.getListOfTeams(
179
- mockOrgId,
180
- page,
181
- pageSize,
182
- filter
183
- );
178
+ const result = await agentConfigService.getListOfTeams(mockOrgId, page, pageSize, filter);
184
179
 
185
180
  expect(mockWebexRequest.request).toHaveBeenCalledWith({
186
181
  service: mockWccAPIURL,
@@ -188,7 +183,7 @@ describe('AgentConfigService', () => {
188
183
  method: 'GET',
189
184
  });
190
185
  expect(result).toEqual(mockResponse.body);
191
-
186
+
192
187
  expect(LoggerProxy.info).toHaveBeenCalledWith('Fetching list of teams', {
193
188
  module: CONFIG_FILE_NAME,
194
189
  method: 'getListOfTeams',
@@ -272,7 +267,7 @@ describe('AgentConfigService', () => {
272
267
  method: 'GET',
273
268
  });
274
269
  expect(result).toEqual(mockResponse.body);
275
-
270
+
276
271
  expect(LoggerProxy.info).toHaveBeenCalledWith('Fetching list of aux codes', {
277
272
  module: CONFIG_FILE_NAME,
278
273
  method: 'getListOfAuxCodes',
@@ -723,7 +718,7 @@ describe('AgentConfigService', () => {
723
718
  const mockOrgInfo = {
724
719
  tenantId: 'tenant123',
725
720
  timezone: 'GMT',
726
- }
721
+ };
727
722
 
728
723
  const mockOrgSettings = {
729
724
  campaignManagerEnabled: true,
@@ -732,10 +727,10 @@ describe('AgentConfigService', () => {
732
727
  };
733
728
 
734
729
  const mockSiteInfo = {
735
- id: "c6a5451f-5ba7-49a1-aee8-fbef70c19ece",
736
- name: "Site-1",
737
- multimediaProfileId: "c5888e6f-5661-4871-9936-cbcec7658d41",
738
- }
730
+ id: 'c6a5451f-5ba7-49a1-aee8-fbef70c19ece',
731
+ name: 'Site-1',
732
+ multimediaProfileId: 'c5888e6f-5661-4871-9936-cbcec7658d41',
733
+ };
739
734
 
740
735
  const mockTenantData = {
741
736
  timeoutDesktopInactivityEnabled: false,
@@ -774,10 +769,13 @@ describe('AgentConfigService', () => {
774
769
 
775
770
  const result = await agentConfigService.getAgentConfig(mockOrgId, mockAgentId);
776
771
 
777
- expect(LoggerProxy.info).toHaveBeenCalledWith(`Fetched user data, userId: ${mockUserConfig.ciUserId}`, {
778
- module: CONFIG_FILE_NAME,
779
- method: 'getAgentConfig',
780
- });
772
+ expect(LoggerProxy.info).toHaveBeenCalledWith(
773
+ `Fetched user data, userId: ${mockUserConfig.ciUserId}`,
774
+ {
775
+ module: CONFIG_FILE_NAME,
776
+ method: 'getAgentConfig',
777
+ }
778
+ );
781
779
  expect(LoggerProxy.info).toHaveBeenCalledWith('Fetched all required data', {
782
780
  module: CONFIG_FILE_NAME,
783
781
  method: 'getAgentConfig',
@@ -802,7 +800,7 @@ describe('AgentConfigService', () => {
802
800
  agentProfileData: mockAgentProfile,
803
801
  dialPlanData: mockDialPlanData,
804
802
  urlMapping: mockURLMapping,
805
- multimediaProfileId: mockSiteInfo.multimediaProfileId
803
+ multimediaProfileId: mockSiteInfo.multimediaProfileId,
806
804
  });
807
805
  });
808
806
 
@@ -868,10 +866,10 @@ describe('AgentConfigService', () => {
868
866
  };
869
867
 
870
868
  const mockSiteInfo = {
871
- id: "c6a5451f-5ba7-49a1-aee8-fbef70c19ece",
872
- name: "Site-1",
873
- multimediaProfileId: "c5888e6f-5661-4871-9936-cbcec7658d41",
874
- }
869
+ id: 'c6a5451f-5ba7-49a1-aee8-fbef70c19ece',
870
+ name: 'Site-1',
871
+ multimediaProfileId: 'c5888e6f-5661-4871-9936-cbcec7658d41',
872
+ };
875
873
 
876
874
  const mockTenantData = {
877
875
  timeoutDesktopInactivityEnabled: true,
@@ -911,10 +909,13 @@ describe('AgentConfigService', () => {
911
909
 
912
910
  const result = await agentConfigService.getAgentConfig(mockOrgId, mockAgentId);
913
911
 
914
- expect(LoggerProxy.info).toHaveBeenCalledWith(`Fetched user data, userId: ${mockUserConfig.ciUserId}`, {
915
- module: CONFIG_FILE_NAME,
916
- method: 'getAgentConfig',
917
- });
912
+ expect(LoggerProxy.info).toHaveBeenCalledWith(
913
+ `Fetched user data, userId: ${mockUserConfig.ciUserId}`,
914
+ {
915
+ module: CONFIG_FILE_NAME,
916
+ method: 'getAgentConfig',
917
+ }
918
+ );
918
919
  expect(LoggerProxy.info).toHaveBeenCalledWith('Fetched all required data', {
919
920
  module: CONFIG_FILE_NAME,
920
921
  method: 'getAgentConfig',
@@ -939,7 +940,7 @@ describe('AgentConfigService', () => {
939
940
  agentProfileData: mockAgentProfile,
940
941
  dialPlanData: mockDialPlanData,
941
942
  urlMapping: mockURLMapping,
942
- multimediaProfileId: mockSiteInfo.multimediaProfileId
943
+ multimediaProfileId: mockSiteInfo.multimediaProfileId,
943
944
  });
944
945
  });
945
946
 
@@ -961,4 +962,288 @@ describe('AgentConfigService', () => {
961
962
  );
962
963
  });
963
964
  });
965
+
966
+ describe('getOutdialAniEntries', () => {
967
+ const mockOutdialANI = 'ani-123-456';
968
+ const mockError = new Error('API call failed');
969
+
970
+ it('should return outdial ANI entries on success with minimal parameters', async () => {
971
+ const mockResponse = {
972
+ statusCode: 200,
973
+ body: {
974
+ data: [
975
+ {
976
+ id: '142fba3c-8502-4446-bf6e-584fd657553a',
977
+ name: 'Second Entry',
978
+ number: '+19403016307',
979
+ links: [],
980
+ createdTime: 1759227334000,
981
+ lastUpdatedTime: 1759227334000,
982
+ },
983
+ {
984
+ id: '6f53000b-e04a-4418-9de9-ba511d2367cb',
985
+ name: 'Sandbox OutDial -entry-iycx',
986
+ number: '+19403016307',
987
+ links: [],
988
+ createdTime: 1755185421000,
989
+ lastUpdatedTime: 1759227334000,
990
+ },
991
+ ],
992
+ },
993
+ };
994
+ (mockWebexRequest.request as jest.Mock).mockResolvedValue(mockResponse);
995
+
996
+ const result = await agentConfigService.getOutdialAniEntries(mockOrgId, {
997
+ outdialANI: mockOutdialANI,
998
+ });
999
+
1000
+ expect(mockWebexRequest.request).toHaveBeenCalledWith({
1001
+ service: mockWccAPIURL,
1002
+ resource: `organization/${mockOrgId}/v2/outdial-ani/${mockOutdialANI}/entry`,
1003
+ method: 'GET',
1004
+ });
1005
+ expect(result).toEqual(mockResponse.body.data);
1006
+
1007
+ expect(LoggerProxy.info).toHaveBeenCalledWith('Fetching outdial ANI entries', {
1008
+ module: CONFIG_FILE_NAME,
1009
+ method: 'getOutdialAniEntries',
1010
+ });
1011
+ expect(LoggerProxy.log).toHaveBeenCalledWith('getOutdialAniEntries API success.', {
1012
+ module: CONFIG_FILE_NAME,
1013
+ method: 'getOutdialAniEntries',
1014
+ });
1015
+ });
1016
+
1017
+ it('should return outdial ANI entries on success with all parameters', async () => {
1018
+ const page = 1;
1019
+ const pageSize = 50;
1020
+ const search = 'test';
1021
+ const filter = 'active=true';
1022
+ const attributes = 'number,name,id';
1023
+
1024
+ const mockResponse = {
1025
+ statusCode: 200,
1026
+ body: {
1027
+ data: [
1028
+ {
1029
+ id: '142fba3c-8502-4446-bf6e-584fd657553a',
1030
+ name: 'Test Entry',
1031
+ number: '+19403016307',
1032
+ },
1033
+ ],
1034
+ },
1035
+ };
1036
+ (mockWebexRequest.request as jest.Mock).mockResolvedValue(mockResponse);
1037
+
1038
+ const result = await agentConfigService.getOutdialAniEntries(mockOrgId, {
1039
+ outdialANI: mockOutdialANI,
1040
+ page,
1041
+ pageSize,
1042
+ search,
1043
+ filter,
1044
+ attributes,
1045
+ });
1046
+
1047
+ expect(mockWebexRequest.request).toHaveBeenCalledWith({
1048
+ service: mockWccAPIURL,
1049
+ resource: `organization/${mockOrgId}/v2/outdial-ani/${mockOutdialANI}/entry?page=${page}&pageSize=${pageSize}&search=${search}&filter=${filter}&attributes=${attributes}`,
1050
+ method: 'GET',
1051
+ });
1052
+ expect(result).toEqual(mockResponse.body.data);
1053
+
1054
+ expect(LoggerProxy.info).toHaveBeenCalledWith('Fetching outdial ANI entries', {
1055
+ module: CONFIG_FILE_NAME,
1056
+ method: 'getOutdialAniEntries',
1057
+ });
1058
+ expect(LoggerProxy.log).toHaveBeenCalledWith('getOutdialAniEntries API success.', {
1059
+ module: CONFIG_FILE_NAME,
1060
+ method: 'getOutdialAniEntries',
1061
+ });
1062
+ });
1063
+
1064
+ it('should return outdial ANI entries with partial parameters', async () => {
1065
+ const page = 0;
1066
+ const pageSize = 25;
1067
+ const attributes = 'number,name';
1068
+
1069
+ const mockResponse = {
1070
+ statusCode: 200,
1071
+ body: {
1072
+ data: [
1073
+ {
1074
+ id: '142fba3c-8502-4446-bf6e-584fd657553a',
1075
+ name: 'Partial Entry',
1076
+ number: '+19403016307',
1077
+ },
1078
+ ],
1079
+ },
1080
+ };
1081
+ (mockWebexRequest.request as jest.Mock).mockResolvedValue(mockResponse);
1082
+
1083
+ const result = await agentConfigService.getOutdialAniEntries(mockOrgId, {
1084
+ outdialANI: mockOutdialANI,
1085
+ page,
1086
+ pageSize,
1087
+ attributes,
1088
+ });
1089
+
1090
+ expect(mockWebexRequest.request).toHaveBeenCalledWith({
1091
+ service: mockWccAPIURL,
1092
+ resource: `organization/${mockOrgId}/v2/outdial-ani/${mockOutdialANI}/entry?page=${page}&pageSize=${pageSize}&attributes=${attributes}`,
1093
+ method: 'GET',
1094
+ });
1095
+ expect(result).toEqual(mockResponse.body.data);
1096
+ });
1097
+
1098
+ it('should return empty array when no ANI entries found', async () => {
1099
+ const mockResponse = {
1100
+ statusCode: 200,
1101
+ body: {
1102
+ data: [],
1103
+ },
1104
+ };
1105
+ (mockWebexRequest.request as jest.Mock).mockResolvedValue(mockResponse);
1106
+
1107
+ const result = await agentConfigService.getOutdialAniEntries(mockOrgId, {
1108
+ outdialANI: mockOutdialANI,
1109
+ });
1110
+
1111
+ expect(mockWebexRequest.request).toHaveBeenCalledWith({
1112
+ service: mockWccAPIURL,
1113
+ resource: `organization/${mockOrgId}/v2/outdial-ani/${mockOutdialANI}/entry`,
1114
+ method: 'GET',
1115
+ });
1116
+ expect(result).toEqual([]);
1117
+
1118
+ expect(LoggerProxy.info).toHaveBeenCalledWith('Fetching outdial ANI entries', {
1119
+ module: CONFIG_FILE_NAME,
1120
+ method: 'getOutdialAniEntries',
1121
+ });
1122
+ expect(LoggerProxy.log).toHaveBeenCalledWith('getOutdialAniEntries API success.', {
1123
+ module: CONFIG_FILE_NAME,
1124
+ method: 'getOutdialAniEntries',
1125
+ });
1126
+ });
1127
+
1128
+ it('should throw an error if the API call fails', async () => {
1129
+ (mockWebexRequest.request as jest.Mock).mockRejectedValue(mockError);
1130
+
1131
+ await expect(
1132
+ agentConfigService.getOutdialAniEntries(mockOrgId, {outdialANI: mockOutdialANI})
1133
+ ).rejects.toThrow('API call failed');
1134
+
1135
+ expect(LoggerProxy.error).toHaveBeenCalledWith(
1136
+ 'getOutdialAniEntries API call failed with Error: API call failed',
1137
+ {module: CONFIG_FILE_NAME, method: 'getOutdialAniEntries'}
1138
+ );
1139
+ expect(mockWebexRequest.request).toHaveBeenCalledWith({
1140
+ service: mockWccAPIURL,
1141
+ resource: `organization/${mockOrgId}/v2/outdial-ani/${mockOutdialANI}/entry`,
1142
+ method: 'GET',
1143
+ });
1144
+ });
1145
+
1146
+ it('should return undefined when API call returns a non-200 status code', async () => {
1147
+ const mockResponse = {statusCode: 404};
1148
+ (mockWebexRequest.request as jest.Mock).mockResolvedValue(mockResponse);
1149
+
1150
+ const result = await agentConfigService.getOutdialAniEntries(mockOrgId, {
1151
+ outdialANI: mockOutdialANI,
1152
+ });
1153
+
1154
+ expect(result).toBeUndefined();
1155
+ expect(LoggerProxy.log).toHaveBeenCalledWith('getOutdialAniEntries API success.', {
1156
+ module: CONFIG_FILE_NAME,
1157
+ method: 'getOutdialAniEntries',
1158
+ });
1159
+ expect(mockWebexRequest.request).toHaveBeenCalledWith({
1160
+ service: mockWccAPIURL,
1161
+ resource: `organization/${mockOrgId}/v2/outdial-ani/${mockOutdialANI}/entry`,
1162
+ method: 'GET',
1163
+ });
1164
+ });
1165
+
1166
+ it('should return undefined when API call returns a 500 status code', async () => {
1167
+ const mockResponse = {statusCode: 500};
1168
+ (mockWebexRequest.request as jest.Mock).mockResolvedValue(mockResponse);
1169
+
1170
+ const result = await agentConfigService.getOutdialAniEntries(mockOrgId, {
1171
+ outdialANI: mockOutdialANI,
1172
+ });
1173
+
1174
+ expect(result).toBeUndefined();
1175
+ expect(LoggerProxy.log).toHaveBeenCalledWith('getOutdialAniEntries API success.', {
1176
+ module: CONFIG_FILE_NAME,
1177
+ method: 'getOutdialAniEntries',
1178
+ });
1179
+ expect(mockWebexRequest.request).toHaveBeenCalledWith({
1180
+ service: mockWccAPIURL,
1181
+ resource: `organization/${mockOrgId}/v2/outdial-ani/${mockOutdialANI}/entry`,
1182
+ method: 'GET',
1183
+ });
1184
+ });
1185
+
1186
+ it('should handle undefined response body gracefully', async () => {
1187
+ const mockResponse = {
1188
+ statusCode: 200,
1189
+ body: undefined,
1190
+ };
1191
+ (mockWebexRequest.request as jest.Mock).mockResolvedValue(mockResponse);
1192
+
1193
+ const result = await agentConfigService.getOutdialAniEntries(mockOrgId, {
1194
+ outdialANI: mockOutdialANI,
1195
+ });
1196
+
1197
+ expect(result).toBeUndefined();
1198
+ expect(LoggerProxy.log).toHaveBeenCalledWith('getOutdialAniEntries API success.', {
1199
+ module: CONFIG_FILE_NAME,
1200
+ method: 'getOutdialAniEntries',
1201
+ });
1202
+ });
1203
+
1204
+ it('should handle response body without data property', async () => {
1205
+ const mockResponse = {
1206
+ statusCode: 200,
1207
+ body: {
1208
+ message: 'No data available',
1209
+ },
1210
+ };
1211
+ (mockWebexRequest.request as jest.Mock).mockResolvedValue(mockResponse);
1212
+
1213
+ const result = await agentConfigService.getOutdialAniEntries(mockOrgId, {
1214
+ outdialANI: mockOutdialANI,
1215
+ });
1216
+
1217
+ expect(result).toBeUndefined();
1218
+ expect(LoggerProxy.log).toHaveBeenCalledWith('getOutdialAniEntries API success.', {
1219
+ module: CONFIG_FILE_NAME,
1220
+ method: 'getOutdialAniEntries',
1221
+ });
1222
+ });
1223
+
1224
+ it('should properly encode special characters in parameters', async () => {
1225
+ const search = 'test search with spaces';
1226
+ const filter = 'name=contains("test & special")';
1227
+
1228
+ const mockResponse = {
1229
+ statusCode: 200,
1230
+ body: {data: []},
1231
+ };
1232
+ (mockWebexRequest.request as jest.Mock).mockResolvedValue(mockResponse);
1233
+
1234
+ await agentConfigService.getOutdialAniEntries(mockOrgId, {
1235
+ outdialANI: mockOutdialANI,
1236
+ page: 0,
1237
+ pageSize: 10,
1238
+ search,
1239
+ filter,
1240
+ });
1241
+
1242
+ expect(mockWebexRequest.request).toHaveBeenCalledWith({
1243
+ service: mockWccAPIURL,
1244
+ resource: `organization/${mockOrgId}/v2/outdial-ani/${mockOutdialANI}/entry?page=0&pageSize=10&search=${search}&filter=${filter}`,
1245
+ method: 'GET',
1246
+ });
1247
+ });
1248
+ });
964
1249
  });