Add end dates to categories in customizationshop

This commit is contained in:
Phillip Thelen
2024-06-05 10:34:17 +02:00
parent 6889b65123
commit ea66e4e4a1
2 changed files with 37 additions and 1 deletions

View File

@@ -344,6 +344,36 @@ describe('shops', () => {
});
});
describe('customizationShop', () => {
const shopCategories = shared.shops.getCustomizationsShopCategories(user, null);
it('does not return items with event data', async () => {
shopCategories.forEach(category => {
category.items.forEach(item => {
expect(item.event, item.key).to.not.exist;
});
});
});
it('backgrounds category contains end date', () => {
const backgroundCategory = shopCategories.find(cat => cat.identifier === 'backgrounds');
expect(backgroundCategory.end).to.exist;
expect(backgroundCategory.end).to.be.greaterThan(new Date());
});
it('hair color category contains end date', () => {
const colorCategory = shopCategories.find(cat => cat.identifier === 'color');
expect(colorCategory.end).to.exist;
expect(colorCategory.end).to.be.greaterThan(new Date());
});
it('skin category contains end date', () => {
const colorCategory = shopCategories.find(cat => cat.identifier === 'color');
expect(colorCategory.end).to.exist;
expect(colorCategory.end).to.be.greaterThan(new Date());
});
});
describe('seasonalShop', () => {
const shopCategories = shared.shops.getSeasonalShopCategories(user, null, seasonalConfig());
const today = new Date();

View File

@@ -586,13 +586,14 @@ shops.getCustomizationsShopCategories = function getCustomizationsShopCategories
const categories = [];
const officialPinnedItems = getOfficialPinnedItems(user);
const matchers = getScheduleMatchingGroup('backgrounds');
const backgroundCategory = {
identifier: 'backgrounds',
text: i18n.t('backgrounds', language),
items: [],
end: matchers.end
};
const matchers = getScheduleMatchingGroup('backgrounds');
eachRight(content.backgrounds, (group, key) => {
if (matchers.match(key)) {
each(group, bg => {
@@ -628,6 +629,10 @@ shops.getCustomizationsShopCategories = function getCustomizationsShopCategories
text: i18n.t(`titleHair${hairType}`, language),
items: [],
};
if (hairType === 'color') {
category.end = customizationMatcher.end;
}
}
eachRight(content.appearances.hair[hairType], (hairStyle, key) => {
if (hairStyle.price > 0 && (!user.purchased.hair || !user.purchased.hair[hairType]
@@ -672,6 +677,7 @@ shops.getCustomizationsShopCategories = function getCustomizationsShopCategories
}
});
if (type === 'skin') {
category.end = customizationMatcher.end;
categories.push(category);
} else {
shirtsCategory = category;