moving developer-only strings to api messages (#10188)

* move translatable string to apiMessages

* use apiMessages instead of res.t for groupIdRequired / keepOrRemove

* move pageMustBeNumber to apiMessages

* change apimessages

* move missingKeyParam to apiMessages

* move more strings to apiMessages

* fix lint

* revert lodash imports to fix tests

* fix webhook test

* fix test

* rollback key change of `keepOrRemove`

* remove unneeded `req.language` param

*  extract more messages from i18n

* add missing `missingTypeParam` message
This commit is contained in:
negue
2018-04-14 16:13:13 +02:00
committed by Matteo Pagliazzi
parent d05d2fb9d7
commit a42cb0e3ab
55 changed files with 179 additions and 136 deletions
@@ -1,8 +1,8 @@
import {
generateUser,
translate as t,
} from '../../../../../helpers/api-integration/v3';
import paypalPayments from '../../../../../../website/server/libs/payments/paypal';
import apiMessages from '../../../../../../website/server/libs/apiMessages';
describe('payments : paypal #checkoutSuccess', () => {
let endpoint = '/paypal/checkout/success';
@@ -17,7 +17,7 @@ describe('payments : paypal #checkoutSuccess', () => {
.to.eventually.be.rejected.and.eql({
code: 400,
error: 'BadRequest',
message: t('missingPaymentId'),
message: apiMessages('missingPaymentId'),
});
});
@@ -26,7 +26,7 @@ describe('payments : paypal #checkoutSuccess', () => {
.to.eventually.be.rejected.and.eql({
code: 400,
error: 'BadRequest',
message: t('missingCustomerId'),
message: apiMessages('missingCustomerId'),
});
});
@@ -1,9 +1,9 @@
import {
generateUser,
translate as t,
} from '../../../../../helpers/api-integration/v3';
import paypalPayments from '../../../../../../website/server/libs/payments/paypal';
import shared from '../../../../../../website/common';
import apiMessages from '../../../../../../website/server/libs/apiMessages';
describe('payments : paypal #subscribe', () => {
let endpoint = '/paypal/subscribe';
@@ -17,7 +17,7 @@ describe('payments : paypal #subscribe', () => {
await expect(user.get(endpoint)).to.eventually.be.rejected.and.eql({
code: 400,
error: 'BadRequest',
message: t('missingSubKey'),
message: apiMessages('missingSubKey'),
});
});
@@ -1,7 +1,7 @@
import {
generateUser,
translate as t,
} from '../../../../../helpers/api-integration/v3';
import apiMessages from '../../../../../../website/server/libs/apiMessages';
import paypalPayments from '../../../../../../website/server/libs/payments/paypal';
describe('payments : paypal #subscribeSuccess', () => {
@@ -16,7 +16,7 @@ describe('payments : paypal #subscribeSuccess', () => {
await expect(user.get(endpoint)).to.eventually.be.rejected.and.eql({
code: 400,
error: 'BadRequest',
message: t('missingPaypalBlock'),
message: apiMessages('missingPaypalBlock'),
});
});
@@ -5,6 +5,7 @@ import {
} from '../../../../helpers/api-v3-integration.helper';
import { v4 as generateUUID } from 'uuid';
import { quests as questScrolls } from '../../../../../website/common/script/content';
import apiMessages from '../../../../../website/server/libs/apiMessages';
describe('POST /groups/:groupId/quests/invite/:questKey', () => {
let questingGroup;
@@ -68,7 +69,7 @@ describe('POST /groups/:groupId/quests/invite/:questKey', () => {
await expect(leader.post(`/groups/${questingGroup._id}/quests/invite/${FAKE_QUEST}`)).to.eventually.be.rejected.and.eql({
code: 404,
error: 'NotFound',
message: t('questNotFound', {key: FAKE_QUEST}),
message: apiMessages('questNotFound', {key: FAKE_QUEST}),
});
});
@@ -9,6 +9,7 @@ import {
import { v4 as generateUUID } from 'uuid';
import { find } from 'lodash';
import apiMessages from '../../../../../website/server/libs/apiMessages';
describe('POST /user/class/cast/:spellId', () => {
let user;
@@ -24,7 +25,7 @@ describe('POST /user/class/cast/:spellId', () => {
.to.eventually.be.rejected.and.eql({
code: 404,
error: 'NotFound',
message: t('spellNotFound', {spellId}),
message: apiMessages('spellNotFound', {spellId}),
});
});
@@ -34,7 +35,7 @@ describe('POST /user/class/cast/:spellId', () => {
.to.eventually.be.rejected.and.eql({
code: 404,
error: 'NotFound',
message: t('spellNotFound', {spellId}),
message: apiMessages('spellNotFound', {spellId}),
});
});
@@ -5,6 +5,7 @@ import {
translate as t,
} from '../../../../../helpers/api-integration/v3';
import shared from '../../../../../../website/common/script';
import apiMessages from '../../../../../../website/server/libs/apiMessages';
let content = shared.content;
@@ -24,7 +25,7 @@ describe('POST /user/buy/:key', () => {
.to.eventually.be.rejected.and.eql({
code: 404,
error: 'NotFound',
message: t('itemNotFound', {key: 'notExisting'}),
message: apiMessages('itemNotFound', {key: 'notExisting'}),
});
});
@@ -2,8 +2,8 @@
import {
generateUser,
translate as t,
} from '../../../../../helpers/api-integration/v3';
import apiMessages from '../../../../../../website/server/libs/apiMessages';
describe('POST /user/buy-gear/:key', () => {
let user;
@@ -21,7 +21,7 @@ describe('POST /user/buy-gear/:key', () => {
.to.eventually.be.rejected.and.eql({
code: 404,
error: 'NotFound',
message: t('itemNotFound', {key: 'notExisting'}),
message: apiMessages('itemNotFound', {key: 'notExisting'}),
});
});
@@ -3,6 +3,7 @@ import {
translate as t,
} from '../../../../../helpers/api-integration/v3';
import shared from '../../../../../../website/common/script';
import apiMessages from '../../../../../../website/server/libs/apiMessages';
let content = shared.content;
@@ -20,7 +21,7 @@ describe('POST /user/buy-quest/:key', () => {
.to.eventually.be.rejected.and.eql({
code: 404,
error: 'NotFound',
message: t('questNotFound', {key: 'notExisting'}),
message: apiMessages('questNotFound', {key: 'notExisting'}),
});
});
@@ -3,6 +3,7 @@ import {
translate as t,
} from '../../../../../helpers/api-integration/v3';
import shared from '../../../../../../website/common/script';
import apiMessages from '../../../../../../website/server/libs/apiMessages';
let content = shared.content;
@@ -20,7 +21,7 @@ describe('POST /user/buy-special-spell/:key', () => {
.to.eventually.be.rejected.and.eql({
code: 404,
error: 'NotFound',
message: t('spellNotFound', {spellId: 'notExisting'}),
message: apiMessages('spellNotFound', {spellId: 'notExisting'}),
});
});
@@ -2,6 +2,7 @@ import {
generateUser,
translate as t,
} from '../../../../../helpers/api-integration/v3';
import apiMessages from '../../../../../../website/server/libs/apiMessages';
describe('POST /user/allocate', () => {
let user;
@@ -17,7 +18,7 @@ describe('POST /user/allocate', () => {
.to.eventually.be.rejected.and.eql({
code: 400,
error: 'BadRequest',
message: t('invalidAttribute', {attr: 'invalid'}),
message: apiMessages('invalidAttribute', {attr: 'invalid'}),
});
});
@@ -3,6 +3,7 @@ import {
translate as t,
} from '../../../../helpers/api-integration/v3';
import { v4 as generateUUID } from 'uuid';
import apiMessages from '../../../../../website/server/libs/apiMessages';
describe('POST /user/webhook', () => {
let user, body;
@@ -200,7 +201,7 @@ describe('POST /user/webhook', () => {
await expect(user.post('/user/webhook', body)).to.eventually.be.rejected.and.eql({
code: 400,
error: 'BadRequest',
message: t('groupIdRequired'),
message: apiMessages('groupIdRequired'),
});
});
@@ -3,6 +3,7 @@ import {
translate as t,
} from '../../../../helpers/api-integration/v3';
import { v4 as generateUUID} from 'uuid';
import apiMessages from '../../../../../website/server/libs/apiMessages';
describe('PUT /user/webhook/:id', () => {
let user, webhookToUpdate;
@@ -126,7 +127,7 @@ describe('PUT /user/webhook/:id', () => {
await expect(user.put(`/user/webhook/${webhookToUpdate.id}`, {type, options})).to.eventually.be.rejected.and.eql({
code: 400,
error: 'BadRequest',
message: t('groupIdRequired'),
message: apiMessages('groupIdRequired'),
});
});
});
+3 -2
View File
@@ -1,6 +1,7 @@
import { model as Webhook } from '../../../../../website/server/models/webhook';
import { BadRequest } from '../../../../../website/server/libs/errors';
import { v4 as generateUUID } from 'uuid';
import apiMessages from '../../../../../website/server/libs/apiMessages';
describe('Webhook Model', () => {
context('Instance Methods', () => {
@@ -135,8 +136,8 @@ describe('Webhook Model', () => {
wh.formatOptions(res);
} catch (err) {
expect(err).to.be.an.instanceOf(BadRequest);
expect(res.t).to.be.calledOnce;
expect(res.t).to.be.calledWith('groupIdRequired');
expect(err.message).to.eql(apiMessages('groupIdRequired'));
done();
}
});