-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
0 additions
and
103 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,7 +19,6 @@ import dns from 'dns'; | |
import { merge } from 'lodash'; | ||
import mailer from 'nodemailer/lib/mailer'; | ||
import { BouncesService } from 'src/api/bounces/bounces.service'; | ||
import { NotificationsController } from 'src/api/notifications/notifications.controller'; | ||
import { NotificationsService } from 'src/api/notifications/notifications.service'; | ||
import { SubscriptionsService } from 'src/api/subscriptions/subscriptions.service'; | ||
import { CommonService } from 'src/common/common.service'; | ||
|
@@ -902,108 +901,6 @@ describe('POST /notifications', () => { | |
}); | ||
}); | ||
|
||
// skip b/c bullMQ | ||
it.skip( | ||
'should retry sub-request when sending chunked broadcast ' + | ||
'notifications', | ||
async () => { | ||
await runAsSuperAdmin(async () => { | ||
const appConfig = app.get<AppConfigService>(AppConfigService).get(); | ||
const origNotificationConfig = appConfig.notification; | ||
const newNotificationConfig = merge({}, origNotificationConfig, { | ||
broadcastSubscriberChunkSize: 1, | ||
}); | ||
appConfig.notification = newNotificationConfig; | ||
|
||
const reqStub = jest | ||
.spyOn(axios, 'get') | ||
.mockRejectedValueOnce({ error: 'connection error' }); | ||
const res = await client | ||
.post('/api/notifications') | ||
.send({ | ||
serviceName: 'myChunkedBroadcastService', | ||
message: { | ||
from: '[email protected]', | ||
subject: 'test', | ||
textBody: 'test', | ||
}, | ||
channel: 'email', | ||
isBroadcast: true, | ||
}) | ||
.set('Accept', 'application/json'); | ||
expect(res.status).toEqual(200); | ||
expect( | ||
CommonService.prototype.sendEmail as unknown as jest.SpyInstance, | ||
).toBeCalledTimes(2); | ||
expect(reqStub).toBeCalledTimes(3); | ||
const data = await notificationsService.findAll( | ||
{ | ||
where: { | ||
serviceName: 'myChunkedBroadcastService', | ||
}, | ||
}, | ||
undefined, | ||
); | ||
expect(data.length).toEqual(1); | ||
appConfig.notification = origNotificationConfig; | ||
}); | ||
}, | ||
); | ||
|
||
// skip b/c bullMQ | ||
it.skip('should handle chunk request abortion', async () => { | ||
await runAsSuperAdmin(async () => { | ||
const appConfig = app.get<AppConfigService>(AppConfigService).get(); | ||
const origNotificationConfig = appConfig.notification; | ||
const newNotificationConfig = merge({}, origNotificationConfig, { | ||
broadcastSubscriberChunkSize: 1, | ||
}); | ||
appConfig.notification = newNotificationConfig; | ||
|
||
const sendPushNotificationStub = jest | ||
.spyOn(NotificationsController.prototype, 'sendPushNotification') | ||
.mockImplementation(async function (this: any, ...args) { | ||
await wait(3000); | ||
sendPushNotificationStub.mockRestore(); | ||
await NotificationsController.prototype.sendPushNotification.apply( | ||
this, | ||
args, | ||
); | ||
}); | ||
|
||
const notification = await notificationsService.create( | ||
{ | ||
serviceName: 'myChunkedBroadcastService', | ||
state: 'sending', | ||
message: { | ||
from: '[email protected]', | ||
subject: 'test', | ||
textBody: 'test', | ||
}, | ||
channel: 'email', | ||
isBroadcast: true, | ||
dispatch: { | ||
candidates: [promiseAllRes[2].id, promiseAllRes[3].id], | ||
}, | ||
}, | ||
undefined, | ||
); | ||
const res = client | ||
.get( | ||
`/api/notifications/${notification.id}/broadcastToChunkSubscribers?start=0`, | ||
) | ||
.end(); | ||
await wait(10); | ||
((res as any).req as any).socket.destroy(); | ||
res.abort(); | ||
await wait(4000); | ||
expect( | ||
CommonService.prototype.sendEmail as unknown as jest.SpyInstance, | ||
).not.toBeCalled(); | ||
appConfig.notification = newNotificationConfig; | ||
}); | ||
}); | ||
|
||
it('should perform client-retry', async () => { | ||
await runAsSuperAdmin(async () => { | ||
( | ||
|