diff --git a/test/api/v3/integration/debug/GET-debug-timeTravelTime.test.js b/test/api/v3/integration/debug/GET-debug-timeTravelTime.test.js index 49f7464a58..e99b9a3839 100644 --- a/test/api/v3/integration/debug/GET-debug-timeTravelTime.test.js +++ b/test/api/v3/integration/debug/GET-debug-timeTravelTime.test.js @@ -20,15 +20,11 @@ describe('GET /debug/time-travel-time', () => { await user.post('/debug/jump-time', { disable: true }); }); - it('returns error when the user is not an admin', async () => { + it('returns shifted when the user is not an admin', async () => { nconf.set('ENABLE_TIME_TRAVEL', true); const regularUser = await generateUser(); - await expect(regularUser.get('/debug/time-travel-time')) - .eventually.be.rejected.and.to.deep.equal({ - code: 400, - error: 'BadRequest', - message: 'You do not have permission to time travel.', - }); + const result = await regularUser.get('/debug/time-travel-time'); + expect(result.time).to.exist; }); it('returns error when not in time travel mode', async () => { diff --git a/test/api/v3/integration/shops/GET-shops_backgrounds.test.js b/test/api/v3/integration/shops/GET-shops_backgrounds.test.js index 387a3bf40f..ec38a83460 100644 --- a/test/api/v3/integration/shops/GET-shops_backgrounds.test.js +++ b/test/api/v3/integration/shops/GET-shops_backgrounds.test.js @@ -17,9 +17,5 @@ describe('GET /shops/backgrounds', () => { expect(shop.notes).to.eql(t('backgroundShop')); expect(shop.imageName).to.equal('background_shop'); expect(shop.sets).to.be.an('array'); - - const sets = shop.sets.map(set => set.identifier); - expect(sets).to.include('incentiveBackgrounds'); - expect(sets).to.include('backgrounds062014'); }); }); diff --git a/test/api/v3/integration/shops/GET-shops_time_travelers.test.js b/test/api/v3/integration/shops/GET-shops_time_travelers.test.js index 3e81459eac..cfe384bf1c 100644 --- a/test/api/v3/integration/shops/GET-shops_time_travelers.test.js +++ b/test/api/v3/integration/shops/GET-shops_time_travelers.test.js @@ -5,9 +5,15 @@ import { describe('GET /shops/time-travelers', () => { let user; + let clock; beforeEach(async () => { user = await generateUser(); + clock = sinon.useFakeTimers(new Date('2024-06-08')); + }); + + afterEach(() => { + clock.restore(); }); it('returns a valid shop object', async () => { diff --git a/test/common/ops/buy/purchase.js b/test/common/ops/buy/purchase.js index b2f13553f5..592aa59374 100644 --- a/test/common/ops/buy/purchase.js +++ b/test/common/ops/buy/purchase.js @@ -92,6 +92,24 @@ describe('shared.ops.purchase', () => { } }); + it('returns error when gear is not available', async () => { + try { + await purchase(user, { params: { type: 'gear', key: 'shield_special_spring2019Healer' } }); + } catch (err) { + expect(err).to.be.an.instanceof(NotAuthorized); + expect(err.message).to.equal(i18n.t('messageNotAvailable')); + } + }); + + it('returns error when gear is not gem purchasable', async () => { + try { + await purchase(user, { params: { type: 'gear', key: 'shield_healer_3' } }); + } catch (err) { + expect(err).to.be.an.instanceof(NotAuthorized); + expect(err.message).to.equal(i18n.t('messageNotAvailable')); + } + }); + it('returns error when item is not found', async () => { const params = { key: 'notExisting', type: 'food' }; diff --git a/website/common/script/index.js b/website/common/script/index.js index 07eebbe845..0c27e5469f 100644 --- a/website/common/script/index.js +++ b/website/common/script/index.js @@ -96,6 +96,7 @@ import updateTask from './ops/updateTask'; import * as statHelpers from './statHelpers'; import { unEquipByType } from './ops/unequip'; import getOfficialPinnedItems from './libs/getOfficialPinnedItems'; +import cleanupPinnedItems from './libs/cleanupPinnedItems'; import { sleepAsync } from './libs/sleepAsync'; const api = { @@ -164,6 +165,7 @@ api.onboarding = onboarding; api.setDebuffPotionItems = setDebuffPotionItems; api.getDebuffPotionItems = getDebuffPotionItems; api.getOfficialPinnedItems = getOfficialPinnedItems; +api.cleanupPinnedItems = cleanupPinnedItems; api.sleepAsync = sleepAsync; api.fns = { diff --git a/website/common/script/ops/buy/purchase.js b/website/common/script/ops/buy/purchase.js index 1938939fe9..110a000478 100644 --- a/website/common/script/ops/buy/purchase.js +++ b/website/common/script/ops/buy/purchase.js @@ -102,7 +102,7 @@ export default async function purchase (user, req = {}, analytics) { if (!matchers.match(item.key)) { throw new NotAuthorized(i18n.t('messageNotAvailable', req.language)); } - } else if (item.end && item.event.gear) { + } else if (item.klass === 'special') { const matchers = getScheduleMatchingGroup('seasonalGear'); if (!matchers.match(item.set)) { throw new NotAuthorized(i18n.t('messageNotAvailable', req.language)); @@ -112,7 +112,7 @@ export default async function purchase (user, req = {}, analytics) { if (!matchers.match(item.key)) { throw new NotAuthorized(i18n.t('notAvailable', { key: item.key })); } - } else if (!item.canBuy(user)) { + } else if (!item.canBuy || !item.canBuy(user)) { throw new NotAuthorized(i18n.t('messageNotAvailable', req.language)); } diff --git a/website/server/libs/cron.js b/website/server/libs/cron.js index 74587dfd95..39d548de2f 100644 --- a/website/server/libs/cron.js +++ b/website/server/libs/cron.js @@ -7,7 +7,6 @@ import common from '../../common'; import { preenUserHistory } from './preening'; import { sleep } from './sleep'; import { revealMysteryItems } from './payments/subscriptions'; -import cleanupPinnedItems from '../../common/script/libs/cleanupPinnedItems'; const CRON_SAFE_MODE = nconf.get('CRON_SAFE_MODE') === 'true'; const CRON_SEMI_SAFE_MODE = nconf.get('CRON_SEMI_SAFE_MODE') === 'true'; @@ -501,7 +500,7 @@ export async function cron (options = {}) { } if (user.pinnedItems && user.pinnedItems.length > 0) { - user.pinnedItems = cleanupPinnedItems(user); + user.pinnedItems = common.cleanupPinnedItems(user); } // Send notification for changes in HP and MP.