From 42cafbeaabc3ffdf2ecd1759a366f13d21d85a8b Mon Sep 17 00:00:00 2001 From: Phillip Thelen Date: Tue, 21 May 2024 15:39:59 +0200 Subject: [PATCH] make market return unlocked quest potions --- test/common/libs/shops.test.js | 31 ++++++++++++++++++++++++++++- test/content/schedule.test.js | 4 ---- website/common/script/libs/shops.js | 2 +- 3 files changed, 31 insertions(+), 6 deletions(-) diff --git a/test/common/libs/shops.test.js b/test/common/libs/shops.test.js index 0bc24fdf6f..3b7b7f4761 100644 --- a/test/common/libs/shops.test.js +++ b/test/common/libs/shops.test.js @@ -4,7 +4,6 @@ import { } from '../../helpers/common.helper'; import seasonalConfig from '../../../website/common/script/libs/shops-seasonal.config'; -import { userActivityWebhook } from '../../../website/server/libs/webhook'; describe('shops', () => { const user = generateUser(); @@ -14,6 +13,7 @@ describe('shops', () => { if (clock) { clock.restore(); } + user.achievements.quests = {}; }); describe('market', () => { @@ -45,6 +45,35 @@ describe('shops', () => { }); }); + describe('premium hatching potions', () => { + it('contains current scheduled premium hatching potions', async () => { + clock = sinon.useFakeTimers(new Date('2024-04-01')); + const potions = shared.shops.getMarketCategories(user).find(x => x.identifier === 'premiumHatchingPotions'); + expect(potions.items.length).to.eql(2); + }); + + it('does not contain past scheduled premium hatching potions', async () => { + const potions = shared.shops.getMarketCategories(user).find(x => x.identifier === 'premiumHatchingPotions'); + expect(potions.items.filter(x => x.key === 'Aquatic' || x.key === 'Celestial').length).to.eql(0); + }); + + it('contains unlocked quest premium hatching potions', async () => { + user.achievements.quests = { + bronze: 1, + blackPearl: 1, + }; + const potions = shared.shops.getMarketCategories(user).find(x => x.identifier === 'premiumHatchingPotions'); + expect(potions.items.filter(x => x.key === 'Bronze' || x.key === 'BlackPearl').length).to.eql(2); + }); + + it('does not contain locked quest premium hatching potions', async () => { + clock = sinon.useFakeTimers(new Date('2024-04-01')); + const potions = shared.shops.getMarketCategories(user).find(x => x.identifier === 'premiumHatchingPotions'); + expect(potions.items.length).to.eql(2); + expect(potions.items.filter(x => x.key === 'Bronze' || x.key === 'BlackPearl').length).to.eql(0); + }); + }); + it('does not return items with event data', async () => { shopCategories.forEach(category => { category.items.forEach(item => { diff --git a/test/content/schedule.test.js b/test/content/schedule.test.js index 3b804dbbb5..1393a1c425 100644 --- a/test/content/schedule.test.js +++ b/test/content/schedule.test.js @@ -1,7 +1,3 @@ -/* import { each } from 'lodash'; -import { - expectValidTranslationString, -} from '../helpers/content.helper'; */ // eslint-disable-next-line max-len import moment from 'moment'; import { diff --git a/website/common/script/libs/shops.js b/website/common/script/libs/shops.js index 3061768235..be59d70e4c 100644 --- a/website/common/script/libs/shops.js +++ b/website/common/script/libs/shops.js @@ -74,7 +74,7 @@ shops.getMarketCategories = function getMarket (user, language) { const matchers = getScheduleMatchingGroup('premiumHatchingPotions'); premiumHatchingPotionsCategory.items = sortBy(values(content.hatchingPotions) .filter(hp => hp.limited - && matchers.match(hp.key)) + && (matchers.match(hp.key) || (hp.questPotion === true && hp.canBuy(user)))) .map(premiumHatchingPotion => getItemInfo(user, 'premiumHatchingPotion', premiumHatchingPotion, officialPinnedItems, language, matchers)), 'key'); if (premiumHatchingPotionsCategory.items.length > 0) { categories.push(premiumHatchingPotionsCategory);