feature items according to content schedule

This commit is contained in:
Phillip Thelen 2024-04-08 19:19:28 +02:00
parent 5c448188cf
commit 6079dd4af6
3 changed files with 84 additions and 69 deletions

View file

@ -3,7 +3,7 @@ import {
} from '../../helpers/common.helper';
import cleanupPinnedItems from '../../../website/common/script/libs/cleanupPinnedItems';
describe.only('cleanupPinnedItems', () => {
describe('cleanupPinnedItems', () => {
let user;
let testPinnedItems;
let clock;

View file

@ -0,0 +1,52 @@
import Sinon from 'sinon';
import featuredItems from '../../website/common/script/content/shop-featuredItems';
describe('Shop Featured Items', () => {
let clock;
afterEach(() => {
if (clock !== undefined) {
clock.restore();
clock = undefined;
}
});
describe('Market', () => {
it('contains armoire', () => {
const items = featuredItems.market();
expect(_.find(items, item => item.path === 'armoire')).to.exist;
});
it('contains the current premium hatching potions', () => {
clock = Sinon.useFakeTimers(new Date('2024-04-08'));
const items = featuredItems.market();
expect(_.find(items, item => item.path === 'premiumHatchingPotions.Porcelain')).to.exist;
});
it('is featuring 4 items', () => {
clock = Sinon.useFakeTimers(new Date('2024-02-08'));
const items = featuredItems.market();
expect(items.length).to.eql(4);
});
});
describe('Quest Shop', () => {
it('contains bundle', () => {
clock = Sinon.useFakeTimers(new Date('2024-04-08'));
const items = featuredItems.quests();
expect(_.find(items, item => item.path === 'bundles.birdBuddies')).to.exist;
});
it('contains pet quests', () => {
clock = Sinon.useFakeTimers(new Date('2024-04-08'));
const items = featuredItems.quests();
expect(_.find(items, item => item.path === 'quests.frog')).to.exist;
});
it('is featuring 4 items', () => {
clock = Sinon.useFakeTimers(new Date('2024-02-08'));
const items = featuredItems.quests();
expect(items.length).to.eql(4);
});
});
});

View file

@ -1,5 +1,5 @@
import moment from 'moment';
import { EVENTS } from './constants';
import { EVENTS, getScheduleMatchingGroup } from './constants';
// Magic Hatching Potions are configured like this:
// type: 'premiumHatchingPotion', // note no "s" at the end
// path: 'premiumHatchingPotions.Rainbow',
@ -7,77 +7,40 @@ import { EVENTS } from './constants';
// hatching potions and food names should be capitalized lest you break the market
const featuredItems = {
market () {
if (moment().isBetween(EVENTS.spring2024.start, EVENTS.spring2024.end)) {
return [
{
type: 'armoire',
path: 'armoire',
},
{
const featured = [{
type: 'armoire',
path: 'armoire',
}];
const itemKeys = getScheduleMatchingGroup('premiumHatchingPotions').items;
itemKeys.forEach(itemKey => {
if (featured.length < 4) {
featured.push({
type: 'premiumHatchingPotion',
path: 'premiumHatchingPotions.Celestial',
},
{
type: 'premiumHatchingPotion',
path: 'premiumHatchingPotions.Shimmer',
},
{
type: 'premiumHatchingPotion',
path: 'premiumHatchingPotions.Rainbow',
},
];
}
return [
{
type: 'armoire',
path: 'armoire',
},
{
type: 'food',
path: 'food.Fish',
},
{
type: 'hatchingPotions',
path: 'hatchingPotions.Skeleton',
},
{
type: 'eggs',
path: 'eggs.Fox',
},
];
path: `premiumHatchingPotions.${itemKey}`,
});
}
});
return featured;
},
quests () {
if (moment().isBetween(EVENTS.bundle202403.start, EVENTS.bundle202403.end)) {
return [
{
type: 'bundles',
path: 'bundles.cuddleBuddies',
},
{
const featured = [];
const bundleKeys = getScheduleMatchingGroup('bundles').items;
bundleKeys.forEach(itemKey => {
featured.push({
type: 'bundles',
path: `bundles.${itemKey}`,
});
});
const petQuestKeys = getScheduleMatchingGroup('petQuests').items;
petQuestKeys.forEach(itemKey => {
if (featured.length < 4) {
featured.push({
type: 'quests',
path: 'quests.hedgehog',
},
{
type: 'quests',
path: 'quests.sheep',
},
];
}
return [
{
type: 'quests',
path: 'quests.rat',
},
{
type: 'quests',
path: 'quests.kraken',
},
{
type: 'quests',
path: 'quests.slime',
},
];
path: `quests.${itemKey}`,
});
}
});
return featured;
},
seasonal: 'spring2019CloudRogueSet',
timeTravelers: [