From 6784d23a7ce38afcbde7b2092c71e74400a48fd8 Mon Sep 17 00:00:00 2001 From: Phillip Thelen Date: Fri, 16 Aug 2019 19:40:49 +0200 Subject: [PATCH] Add translated gear name to open-mystery-item call (#11306) * Add translated gear name to open-mystery-item call * Fix test * fix mystery item text language --- .../v3/integration/user/POST-user_open_mystery_item.test.js | 2 ++ test/common/ops/openMysteryItem.js | 4 +++- website/common/script/ops/openMysteryItem.js | 1 + 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/test/api/v3/integration/user/POST-user_open_mystery_item.test.js b/test/api/v3/integration/user/POST-user_open_mystery_item.test.js index 40ac6eca24..1c81cfe439 100644 --- a/test/api/v3/integration/user/POST-user_open_mystery_item.test.js +++ b/test/api/v3/integration/user/POST-user_open_mystery_item.test.js @@ -9,6 +9,7 @@ describe('POST /user/open-mystery-item', () => { let mysteryItemKey = 'eyewear_special_summerRogue'; let mysteryItemIndex = content.gear.flat[mysteryItemKey].index; let mysteryItemType = content.gear.flat[mysteryItemKey].type; + let mysteryItemText = content.gear.flat[mysteryItemKey].text(); beforeEach(async () => { user = await generateUser({ @@ -32,5 +33,6 @@ describe('POST /user/open-mystery-item', () => { expect(response.data.key).to.eql(mysteryItemKey); expect(response.data.index).to.eql(mysteryItemIndex); expect(response.data.type).to.eql(mysteryItemType); + expect(response.data.text).to.eql(mysteryItemText); }); }); diff --git a/test/common/ops/openMysteryItem.js b/test/common/ops/openMysteryItem.js index f98a3048b5..e828129457 100644 --- a/test/common/ops/openMysteryItem.js +++ b/test/common/ops/openMysteryItem.js @@ -36,7 +36,9 @@ describe('shared.ops.openMysteryItem', () => { expect(user.items.gear.owned[mysteryItemKey]).to.be.true; expect(message).to.equal(i18n.t('mysteryItemOpened')); - expect(data).to.eql(content.gear.flat[mysteryItemKey]); + let item = _.cloneDeep(content.gear.flat[mysteryItemKey]); + item.text = content.gear.flat[mysteryItemKey].text(); + expect(data).to.eql(item); expect(user.notifications.length).to.equal(0); }); }); diff --git a/website/common/script/ops/openMysteryItem.js b/website/common/script/ops/openMysteryItem.js index c45d63e925..b2cf4ea561 100644 --- a/website/common/script/ops/openMysteryItem.js +++ b/website/common/script/ops/openMysteryItem.js @@ -24,6 +24,7 @@ module.exports = function openMysteryItem (user, req = {}, analytics) { if (mysteryItems.length === 0) markNotificationAsRead(user); item = cloneDeep(content.gear.flat[item]); + item.text = content.gear.flat[item.key].text(user.preferences.language); user.items.gear.owned[item.key] = true; if (user.markModified) {