-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #32 from notificationapi-com/tqLKwvhB/2053-query-log
add query log
- Loading branch information
Showing
4 changed files
with
62 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ import { | |
CreateSubNotificationRequest, | ||
DeleteSubNotificationRequest, | ||
InAppNotificationPatchRequest, | ||
queryLogsPostBody, | ||
PushProviders, | ||
SendRequest, | ||
SetUserPreferencesRequest, | ||
|
@@ -317,6 +318,46 @@ describe('send', () => { | |
); | ||
}); | ||
}); | ||
describe('queryLogs', () => { | ||
const queryLogsEndPointRegex = /.*\/logs\/query/; | ||
const clientId = 'testClientId'; | ||
const clientSecret = 'testClientSecret'; | ||
|
||
test('makes API calls to the correct end-point, non custom', async () => { | ||
const nonCostumeQuery: queryLogsPostBody = { | ||
dateRangeFilter: { startTime: 1715904000000, endTime: 1718668799999 }, | ||
notificationFilter: ['test'], | ||
channelFilter: [Channels.CALL], | ||
userFilter: ['[email protected]'], | ||
statusFilter: ['FAILURE'], | ||
trackingIds: ['e2d6987f-52c'], | ||
envIdFilter: [clientId] | ||
}; | ||
axiosMock.onPost(queryLogsEndPointRegex).reply(200); | ||
notificationapi.init(clientId, clientSecret); | ||
await notificationapi.queryLogs(nonCostumeQuery); | ||
expect(axiosMock.history.post).toHaveLength(1); | ||
expect(axiosMock.history.post[0].url).toEqual( | ||
`https://api.notificationapi.com/${clientId}/logs/query` | ||
); | ||
expect(JSON.parse(axiosMock.history.post[0].data)).toEqual(nonCostumeQuery); | ||
}); | ||
test('makes API calls to the correct end-point, custom', async () => { | ||
const nonCostumeQuery: queryLogsPostBody = { | ||
dateRangeFilter: { startTime: 1715904000000, endTime: 1718668799999 }, | ||
customFilter: | ||
'fields @message| filter @logStream like /NotificationsSummary/| sort @timestamp desc' | ||
}; | ||
axiosMock.onPost(queryLogsEndPointRegex).reply(200); | ||
notificationapi.init(clientId, clientSecret); | ||
await notificationapi.queryLogs(nonCostumeQuery); | ||
expect(axiosMock.history.post).toHaveLength(1); | ||
expect(axiosMock.history.post[0].url).toEqual( | ||
`https://api.notificationapi.com/${clientId}/logs/query` | ||
); | ||
expect(JSON.parse(axiosMock.history.post[0].data)).toEqual(nonCostumeQuery); | ||
}); | ||
}); | ||
|
||
describe('retract by secondaryId', () => { | ||
const retractEndPointRegex = /.*\/sender\/retract/; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters