Add more achievements to notifications list (#11332)

* Add more achievements to notifications list

* use addNotification

* Fix logic to not award stable achievements over and over

* Improve achievement display

* Fix setting notifications for party inviter

* Add tests that notifications are added correctly

* Fix tests
This commit is contained in:
Phillip Thelen
2019-10-18 17:04:33 +02:00
committed by Matteo Pagliazzi
parent ec7ded042b
commit 360aaa9f0b
8 changed files with 108 additions and 25 deletions

View File

@@ -384,6 +384,7 @@ describe('User Model', () => {
user = await user.save();
// verify that it's been awarded
expect(user.achievements.beastMaster).to.equal(true);
expect(user.notifications.find(notification => notification.type === 'ACHIEVEMENT_BEAST_MASTER')).to.exist;
// reset the user
user.achievements.beastMasterCount = 0;
@@ -414,6 +415,25 @@ describe('User Model', () => {
expect(user.achievements.beastMaster).to.not.equal(true);
});
it('adds achievements to notification list', async () => {
let user = new User();
user = await user.save(); // necessary for user.isSelected to work correctly
// Create conditions for achievements to be awarded
user.achievements.beastMasterCount = 3;
user.achievements.mountMasterCount = 3;
user.achievements.triadBingoCount = 3;
expect(user.achievements.beastMaster).to.not.equal(true); // verify that it was not awarded initially
expect(user.achievements.mountMaster).to.not.equal(true); // verify that it was not awarded initially
expect(user.achievements.triadBingo).to.not.equal(true); // verify that it was not awarded initially
user = await user.save();
// verify that it's been awarded
expect(user.notifications.find(notification => notification.type === 'ACHIEVEMENT_BEAST_MASTER')).to.exist;
expect(user.notifications.find(notification => notification.type === 'ACHIEVEMENT_MOUNT_MASTER')).to.exist;
expect(user.notifications.find(notification => notification.type === 'ACHIEVEMENT_TRIAD_BINGO')).to.exist;
});
context('manage unallocated stats points notifications', () => {
it('doesn\'t add a notification if there are no points to allocate', async () => {
let user = new User();