diff --git a/test/api/v3/unit/models/group.test.js b/test/api/v3/unit/models/group.test.js index ff3785ef5a..577d8108a6 100644 --- a/test/api/v3/unit/models/group.test.js +++ b/test/api/v3/unit/models/group.test.js @@ -350,7 +350,25 @@ describe('Group Model', () => { party = await Group.findOne({_id: party._id}); expect(Group.prototype.sendChat).to.be.calledOnce; - expect(Group.prototype.sendChat).to.be.calledWith('`Participating Member found nothing.`'); + expect(Group.prototype.sendChat).to.be.calledWith('`Participating Member found 0 Bars of Soap.`'); + }); + + it('sends a chat message if no progress is made on quest with multiple items', async () => { + progress.collectedItems = 0; + party.quest.key = 'dilatoryDistress1'; + party.quest.active = false; + + await party.startQuest(questLeader); + await party.save(); + + await Group.processQuestProgress(participatingMember, progress); + + party = await Group.findOne({_id: party._id}); + + expect(Group.prototype.sendChat).to.be.calledOnce; + expect(Group.prototype.sendChat).to.be.calledWithMatch(/`Participating Member found/); + expect(Group.prototype.sendChat).to.be.calledWithMatch(/0 Blue Fins/); + expect(Group.prototype.sendChat).to.be.calledWithMatch(/0 Fire Coral/); }); it('handles collection quests with multiple items', async () => { diff --git a/website/server/models/group.js b/website/server/models/group.js index c9a275679b..501d7d4857 100644 --- a/website/server/models/group.js +++ b/website/server/models/group.js @@ -607,12 +607,20 @@ schema.methods._processCollectionQuest = async function processCollectionQuest ( group.quest.progress.collect[item]++; }); + // Add 0 for all items not found + let questItems = Object.keys(this.quest.progress.collect); + for (let i = 0; i < questItems.length; i++) { + if (!itemsFound[questItems[i]]) { + itemsFound[questItems[i]] = 0; + } + } + let foundText = _.reduce(itemsFound, (m, v, k) => { m.push(`${v} ${quest.collect[k].text('en')}`); return m; }, []); - foundText = foundText.length > 0 ? foundText.join(', ') : 'nothing'; + foundText = foundText.join(', '); group.sendChat(`\`${user.profile.name} found ${foundText}.\``); group.markModified('quest.progress.collect');