mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-18 07:07:35 +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();
|
||||
});
|
||||
|
||||
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 () => {
|
||||
let mayMysteryItemTimeframe = 1464725113000; // May 31st 2016
|
||||
let fakeClock = sinon.useFakeTimers(mayMysteryItemTimeframe);
|
||||
|
||||
@@ -36,9 +36,10 @@ function revealMysteryItems (user) {
|
||||
pushedItems.push(item.key);
|
||||
}
|
||||
});
|
||||
|
||||
if (pushedItems.length > 0) {
|
||||
user.addNotification('NEW_MYSTERY_ITEMS', { items: pushedItems });
|
||||
}
|
||||
}
|
||||
|
||||
// @TODO: Abstract to payment helper
|
||||
function _dateDiff (earlyDate, lateDate) {
|
||||
|
||||
Reference in New Issue
Block a user