make market return unlocked quest potions

This commit is contained in:
Phillip Thelen
2024-05-21 15:39:59 +02:00
parent 5b5d5a39a4
commit 42cafbeaab
3 changed files with 31 additions and 6 deletions

View File

@@ -4,7 +4,6 @@ import {
} from '../../helpers/common.helper'; } from '../../helpers/common.helper';
import seasonalConfig from '../../../website/common/script/libs/shops-seasonal.config'; import seasonalConfig from '../../../website/common/script/libs/shops-seasonal.config';
import { userActivityWebhook } from '../../../website/server/libs/webhook';
describe('shops', () => { describe('shops', () => {
const user = generateUser(); const user = generateUser();
@@ -14,6 +13,7 @@ describe('shops', () => {
if (clock) { if (clock) {
clock.restore(); clock.restore();
} }
user.achievements.quests = {};
}); });
describe('market', () => { 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 () => { it('does not return items with event data', async () => {
shopCategories.forEach(category => { shopCategories.forEach(category => {
category.items.forEach(item => { category.items.forEach(item => {

View File

@@ -1,7 +1,3 @@
/* import { each } from 'lodash';
import {
expectValidTranslationString,
} from '../helpers/content.helper'; */
// eslint-disable-next-line max-len // eslint-disable-next-line max-len
import moment from 'moment'; import moment from 'moment';
import { import {

View File

@@ -74,7 +74,7 @@ shops.getMarketCategories = function getMarket (user, language) {
const matchers = getScheduleMatchingGroup('premiumHatchingPotions'); const matchers = getScheduleMatchingGroup('premiumHatchingPotions');
premiumHatchingPotionsCategory.items = sortBy(values(content.hatchingPotions) premiumHatchingPotionsCategory.items = sortBy(values(content.hatchingPotions)
.filter(hp => hp.limited .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'); .map(premiumHatchingPotion => getItemInfo(user, 'premiumHatchingPotion', premiumHatchingPotion, officialPinnedItems, language, matchers)), 'key');
if (premiumHatchingPotionsCategory.items.length > 0) { if (premiumHatchingPotionsCategory.items.length > 0) {
categories.push(premiumHatchingPotionsCategory); categories.push(premiumHatchingPotionsCategory);