|
8 | 8 | CreateSubNotificationRequest,
|
9 | 9 | DeleteSubNotificationRequest,
|
10 | 10 | InAppNotificationPatchRequest,
|
| 11 | + queryLogsPostBody, |
11 | 12 | PushProviders,
|
12 | 13 | SendRequest,
|
13 | 14 | SetUserPreferencesRequest,
|
@@ -317,6 +318,46 @@ describe('send', () => {
|
317 | 318 | );
|
318 | 319 | });
|
319 | 320 | });
|
| 321 | +describe('queryLogs', () => { |
| 322 | + const queryLogsEndPointRegex = /.*\/logs\/query/; |
| 323 | + const clientId = 'testClientId'; |
| 324 | + const clientSecret = 'testClientSecret'; |
| 325 | + |
| 326 | + test('makes API calls to the correct end-point, non custom', async () => { |
| 327 | + const nonCostumeQuery: queryLogsPostBody = { |
| 328 | + dateRangeFilter: { startTime: 1715904000000, endTime: 1718668799999 }, |
| 329 | + notificationFilter: ['test'], |
| 330 | + channelFilter: [Channels.CALL], |
| 331 | + userFilter: ['[email protected]'], |
| 332 | + statusFilter: ['FAILURE'], |
| 333 | + trackingIds: ['e2d6987f-52c'], |
| 334 | + envIdFilter: [clientId] |
| 335 | + }; |
| 336 | + axiosMock.onPost(queryLogsEndPointRegex).reply(200); |
| 337 | + notificationapi.init(clientId, clientSecret); |
| 338 | + await notificationapi.queryLogs(nonCostumeQuery); |
| 339 | + expect(axiosMock.history.post).toHaveLength(1); |
| 340 | + expect(axiosMock.history.post[0].url).toEqual( |
| 341 | + `https://api.notificationapi.com/${clientId}/logs/query` |
| 342 | + ); |
| 343 | + expect(JSON.parse(axiosMock.history.post[0].data)).toEqual(nonCostumeQuery); |
| 344 | + }); |
| 345 | + test('makes API calls to the correct end-point, custom', async () => { |
| 346 | + const nonCostumeQuery: queryLogsPostBody = { |
| 347 | + dateRangeFilter: { startTime: 1715904000000, endTime: 1718668799999 }, |
| 348 | + customFilter: |
| 349 | + 'fields @message| filter @logStream like /NotificationsSummary/| sort @timestamp desc' |
| 350 | + }; |
| 351 | + axiosMock.onPost(queryLogsEndPointRegex).reply(200); |
| 352 | + notificationapi.init(clientId, clientSecret); |
| 353 | + await notificationapi.queryLogs(nonCostumeQuery); |
| 354 | + expect(axiosMock.history.post).toHaveLength(1); |
| 355 | + expect(axiosMock.history.post[0].url).toEqual( |
| 356 | + `https://api.notificationapi.com/${clientId}/logs/query` |
| 357 | + ); |
| 358 | + expect(JSON.parse(axiosMock.history.post[0].data)).toEqual(nonCostumeQuery); |
| 359 | + }); |
| 360 | +}); |
320 | 361 |
|
321 | 362 | describe('retract by secondaryId', () => {
|
322 | 363 | const retractEndPointRegex = /.*\/sender\/retract/;
|
|
0 commit comments