mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-18 15:17:25 +01:00
fix for #10496: Newly subscribed accounts receive erroneous notification that they have Mystery Items (#10759)
* fix Newly subscribed accounts receive erroneous notification that they have Mystery Items * Added unit test for #10496 * Restored a previous unit test
This commit is contained in:
committed by
Matteo Pagliazzi
parent
00717eda76
commit
4ed1082558
@@ -446,6 +446,19 @@ describe('payments/index', () => {
|
|||||||
fakeClock.restore();
|
fakeClock.restore();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('does not add a notification for mystery items if none was awarded', async () => {
|
||||||
|
const noMysteryItemTimeframe = 1462183920000; // May 2nd 2016
|
||||||
|
let fakeClock = sinon.useFakeTimers(noMysteryItemTimeframe);
|
||||||
|
data = { paymentMethod: 'PaymentMethod', user, sub: { key: 'basic_3mo' } };
|
||||||
|
|
||||||
|
await api.createSubscription(data);
|
||||||
|
|
||||||
|
expect(user.purchased.plan.mysteryItems).to.have.a.lengthOf(0);
|
||||||
|
expect(user.notifications.find(n => n.type === 'NEW_MYSTERY_ITEMS')).to.be.undefined;
|
||||||
|
|
||||||
|
fakeClock.restore();
|
||||||
|
});
|
||||||
|
|
||||||
it('does not award mystery item when user already owns the item', async () => {
|
it('does not award mystery item when user already owns the item', async () => {
|
||||||
let mayMysteryItemTimeframe = 1464725113000; // May 31st 2016
|
let mayMysteryItemTimeframe = 1464725113000; // May 31st 2016
|
||||||
let fakeClock = sinon.useFakeTimers(mayMysteryItemTimeframe);
|
let fakeClock = sinon.useFakeTimers(mayMysteryItemTimeframe);
|
||||||
|
|||||||
@@ -36,8 +36,9 @@ function revealMysteryItems (user) {
|
|||||||
pushedItems.push(item.key);
|
pushedItems.push(item.key);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
if (pushedItems.length > 0) {
|
||||||
user.addNotification('NEW_MYSTERY_ITEMS', { items: pushedItems });
|
user.addNotification('NEW_MYSTERY_ITEMS', { items: pushedItems });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// @TODO: Abstract to payment helper
|
// @TODO: Abstract to payment helper
|
||||||
|
|||||||
Reference in New Issue
Block a user