diff --git a/test/api/v3/integration/webhook/POST-user_add_webhook.test.js b/test/api/v3/integration/webhook/POST-user_add_webhook.test.js index 306ba771c0..1bf8399a8d 100644 --- a/test/api/v3/integration/webhook/POST-user_add_webhook.test.js +++ b/test/api/v3/integration/webhook/POST-user_add_webhook.test.js @@ -226,6 +226,69 @@ describe('POST /user/webhook', () => { }); }); + it('defaults questActivity options', async () => { + body.type = 'questActivity'; + + const webhook = await user.post('/user/webhook', body); + + expect(webhook.options).to.eql({ + questStarted: false, + questFinished: false, + questInvited: false, + }); + }); + + it('can set questActivity options', async () => { + body.type = 'questActivity'; + body.options = { + questStarted: true, + questFinished: true, + questInvited: true, + }; + + const webhook = await user.post('/user/webhook', body); + + expect(webhook.options).to.eql({ + questStarted: true, + questFinished: true, + questInvited: true, + }); + }); + + it('discards extra properties in questActivity options', async () => { + body.type = 'questActivity'; + body.options = { + questStarted: false, + questFinished: true, + questInvited: true, + foo: 'bar', + }; + + const webhook = await user.post('/user/webhook', body); + + expect(webhook.options.foo).to.not.exist; + expect(webhook.options).to.eql({ + questStarted: false, + questFinished: true, + questInvited: true, + }); + }); + + ['questStarted', 'questFinished', 'questInvited'].forEach(option => { + it(`requires questActivity option ${option} to be a boolean`, async () => { + body.type = 'questActivity'; + body.options = { + [option]: 'not a boolean', + }; + + await expect(user.post('/user/webhook', body)).to.eventually.be.rejected.and.eql({ + code: 400, + error: 'BadRequest', + message: t('webhookBooleanOption', { option }), + }); + }); + }); + it('discards extra properties in globalActivity options', async () => { body.type = 'globalActivity'; body.options = {