mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-15 05:37:22 +01:00
Add integration tests for questActivity webhook
This commit is contained in:
@@ -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 = {
|
||||
|
||||
Reference in New Issue
Block a user