From ad9b551de3b85d7e60c93c011ef82720c79a4787 Mon Sep 17 00:00:00 2001 From: hamboomger Date: Thu, 8 Oct 2020 13:34:19 +0300 Subject: [PATCH] fix(quests): Quests that are level-locked for purchase can now be used at any level --- .../POST-groups_groupId_quests_invite.test.js | 28 ++++++++----------- website/server/controllers/api-v3/quests.js | 1 - 2 files changed, 12 insertions(+), 17 deletions(-) diff --git a/test/api/v3/integration/quests/POST-groups_groupId_quests_invite.test.js b/test/api/v3/integration/quests/POST-groups_groupId_quests_invite.test.js index 81a0d1327c..170f9a4c21 100644 --- a/test/api/v3/integration/quests/POST-groups_groupId_quests_invite.test.js +++ b/test/api/v3/integration/quests/POST-groups_groupId_quests_invite.test.js @@ -83,22 +83,6 @@ describe('POST /groups/:groupId/quests/invite/:questKey', () => { }); }); - it('does not issue invites if the user is of insufficient Level', async () => { - const LEVELED_QUEST = 'atom1'; - const LEVELED_QUEST_REQ = questScrolls[LEVELED_QUEST].lvl; - const leaderUpdate = {}; - leaderUpdate[`items.quests.${LEVELED_QUEST}`] = 1; - leaderUpdate['stats.lvl'] = LEVELED_QUEST_REQ - 1; - - await leader.update(leaderUpdate); - - await expect(leader.post(`/groups/${questingGroup._id}/quests/invite/${LEVELED_QUEST}`)).to.eventually.be.rejected.and.eql({ - code: 401, - error: 'NotAuthorized', - message: t('questLevelTooHigh', { level: LEVELED_QUEST_REQ }), - }); - }); - it('does not issue invites if a quest is already underway', async () => { const QUEST_IN_PROGRESS = 'atom1'; const leaderUpdate = {}; @@ -212,6 +196,18 @@ describe('POST /groups/:groupId/quests/invite/:questKey', () => { expect(returnedGroup.chat[0]._meta).to.be.undefined; }); + it('successfully issues a quest invitation when quest level is higher than user level', async () => { + const LEVELED_QUEST = 'atom1'; + const LEVELED_QUEST_REQ = questScrolls[LEVELED_QUEST].lvl; + const leaderUpdate = {}; + leaderUpdate[`items.quests.${LEVELED_QUEST}`] = 1; + leaderUpdate['stats.lvl'] = LEVELED_QUEST_REQ - 1; + + await leader.update(leaderUpdate); + + await leader.post(`/groups/${questingGroup._id}/quests/invite/${LEVELED_QUEST}`); + }); + context('sending quest activity webhooks', () => { before(async () => { await server.start(); diff --git a/website/server/controllers/api-v3/quests.js b/website/server/controllers/api-v3/quests.js index 264069bab5..dd1105e58d 100644 --- a/website/server/controllers/api-v3/quests.js +++ b/website/server/controllers/api-v3/quests.js @@ -73,7 +73,6 @@ api.inviteToQuest = { if (group.type !== 'party') throw new NotAuthorized(res.t('guildQuestsNotSupported')); if (!quest) throw new NotFound(apiError('questNotFound', { key: questKey })); if (!user.items.quests[questKey]) throw new NotAuthorized(res.t('questNotOwned')); - if (user.stats.lvl < quest.lvl) throw new NotAuthorized(res.t('questLevelTooHigh', { level: quest.lvl })); if (group.quest.key) throw new NotAuthorized(res.t('questAlreadyUnderway')); const members = await User.find({