Merge branch 'develop' into party-chat-translations

This commit is contained in:
Mateus Etto
2018-03-17 00:08:20 +09:00
310 changed files with 10732 additions and 10045 deletions
@@ -2,9 +2,9 @@ import {
generateUser,
} from '../../../../helpers/api-v3-integration.helper';
import xml2js from 'xml2js';
import Bluebird from 'bluebird';
import util from 'util';
let parseStringAsync = Bluebird.promisify(xml2js.parseString, {context: xml2js});
let parseStringAsync = util.promisify(xml2js.parseString).bind(xml2js);
describe('GET /export/userdata.xml', () => {
// TODO disabled because it randomly causes the build to fail
@@ -2,8 +2,8 @@ import {
createAndPopulateGroup,
translate as t,
generateUser,
sleep,
} from '../../../../helpers/api-v3-integration.helper';
import Bluebird from 'bluebird';
describe('POST /groups/:groupId/quests/accept', () => {
const PET_QUEST = 'whale';
@@ -140,7 +140,7 @@ describe('POST /groups/:groupId/quests/accept', () => {
// quest will start after everyone has accepted
await partyMembers[1].post(`/groups/${questingGroup._id}/quests/accept`);
await Bluebird.delay(500);
await sleep(0.5);
await rejectingMember.sync();
@@ -2,8 +2,8 @@ import {
createAndPopulateGroup,
translate as t,
generateUser,
sleep,
} from '../../../../helpers/api-v3-integration.helper';
import Bluebird from 'bluebird';
describe('POST /groups/:groupId/quests/force-start', () => {
const PET_QUEST = 'whale';
@@ -135,7 +135,7 @@ describe('POST /groups/:groupId/quests/force-start', () => {
await leader.post(`/groups/${questingGroup._id}/quests/force-start`);
await Bluebird.delay(500);
await sleep(0.5);
await Promise.all([
partyMemberThatRejects.sync(),
@@ -161,7 +161,7 @@ describe('POST /groups/:groupId/quests/force-start', () => {
await leader.post(`/groups/${questingGroup._id}/quests/force-start`);
await Bluebird.delay(500);
await sleep(0.5);
await questingGroup.sync();
@@ -184,7 +184,7 @@ describe('POST /groups/:groupId/quests/force-start', () => {
await leader.post(`/groups/${questingGroup._id}/quests/force-start`);
await Bluebird.delay(500);
await sleep(0.5);
await questingGroup.sync();
@@ -201,7 +201,7 @@ describe('POST /groups/:groupId/quests/force-start', () => {
await leader.post(`/groups/${questingGroup._id}/quests/force-start`);
await Bluebird.delay(500);
await sleep(0.5);
await questingGroup.sync();
@@ -222,7 +222,7 @@ describe('POST /groups/:groupId/quests/force-start', () => {
await leader.post(`/groups/${questingGroup._id}/quests/force-start`);
await Bluebird.delay(500);
await sleep(0.5);
await questingGroup.sync();
@@ -2,9 +2,9 @@ import {
createAndPopulateGroup,
translate as t,
generateUser,
sleep,
} from '../../../../helpers/api-v3-integration.helper';
import { v4 as generateUUID } from 'uuid';
import Bluebird from 'bluebird';
describe('POST /groups/:groupId/quests/reject', () => {
let questingGroup;
@@ -168,7 +168,7 @@ describe('POST /groups/:groupId/quests/reject', () => {
// quest will start after everyone has accepted or rejected
await rejectingMember.post(`/groups/${questingGroup._id}/quests/reject`);
await Bluebird.delay(500);
await sleep(0.5);
await questingGroup.sync();
@@ -2,7 +2,6 @@ import {
generateUser,
translate as t,
} from '../../../../helpers/api-integration/v3';
import Bluebird from 'bluebird';
describe('GET /shops/market', () => {
let user;
@@ -42,13 +41,13 @@ describe('GET /shops/market', () => {
return array;
}, []);
let results = await Bluebird.each(items, (item) => {
let results = await Promise.all(items.map((item) => {
let { purchaseType, key } = item;
return user.post(`/user/purchase/${purchaseType}/${key}`);
});
}));
expect(results.length).to.be.greaterThan(0);
results.forEach((item) => {
items.forEach((item) => {
expect(item).to.include.keys('key', 'text', 'notes', 'class', 'value', 'currency');
});
});
@@ -2,8 +2,8 @@ import {
generateUser,
generateGroup,
generateChallenge,
sleep,
} from '../../../../../helpers/api-integration/v3';
import Bluebird from 'bluebird';
import { find } from 'lodash';
describe('POST /tasks/:id/score/:direction', () => {
@@ -27,7 +27,7 @@ describe('POST /tasks/:id/score/:direction', () => {
text: 'test habit',
type: 'habit',
});
await Bluebird.delay(1000);
await sleep(1);
let updatedUser = await user.get('/user');
usersChallengeTaskId = updatedUser.tasksOrder.habits[0];
});
@@ -65,7 +65,7 @@ describe('POST /tasks/:id/score/:direction', () => {
text: 'test daily',
type: 'daily',
});
await Bluebird.delay(1000);
await sleep(1);
let updatedUser = await user.get('/user');
usersChallengeTaskId = updatedUser.tasksOrder.dailys[0];
});
@@ -109,7 +109,7 @@ describe('POST /tasks/:id/score/:direction', () => {
text: 'test todo',
type: 'todo',
});
await Bluebird.delay(1000);
await sleep(1);
let updatedUser = await user.get('/user');
usersChallengeTaskId = updatedUser.tasksOrder.todos[0];
});
@@ -134,7 +134,7 @@ describe('POST /tasks/:id/score/:direction', () => {
text: 'test reward',
type: 'reward',
});
await Bluebird.delay(1000);
await sleep(1);
let updatedUser = await user.get('/user');
usersChallengeTaskId = updatedUser.tasksOrder.todos[0];
});
@@ -11,7 +11,6 @@ import {
each,
map,
} from 'lodash';
import Bluebird from 'bluebird';
import {
sha1MakeSalt,
sha1Encrypt as sha1EncryptPassword,
@@ -104,7 +103,7 @@ describe('DELETE /user', () => {
password,
});
await Bluebird.all(map(ids, id => {
await Promise.all(map(ids, id => {
return expect(checkExistence('tasks', id)).to.eventually.eql(false);
}));
});
+4 -5
View File
@@ -1,7 +1,6 @@
/* eslint-disable global-require */
import moment from 'moment';
import nconf from 'nconf';
import Bluebird from 'bluebird';
import requireAgain from 'require-again';
import { recoverCron, cron } from '../../../../../website/server/libs/cron';
import { model as User } from '../../../../../website/server/models/user';
@@ -1363,7 +1362,7 @@ describe('recoverCron', () => {
});
it('throws an error if user cannot be found', async () => {
execStub.returns(Bluebird.resolve(null));
execStub.returns(Promise.resolve(null));
try {
await recoverCron(status, locals);
@@ -1374,8 +1373,8 @@ describe('recoverCron', () => {
});
it('increases status.times count and reruns up to 4 times', async () => {
execStub.returns(Bluebird.resolve({_cronSignature: 'RUNNING_CRON'}));
execStub.onCall(4).returns(Bluebird.resolve({_cronSignature: 'NOT_RUNNING'}));
execStub.returns(Promise.resolve({_cronSignature: 'RUNNING_CRON'}));
execStub.onCall(4).returns(Promise.resolve({_cronSignature: 'NOT_RUNNING'}));
await recoverCron(status, locals);
@@ -1384,7 +1383,7 @@ describe('recoverCron', () => {
});
it('throws an error if recoverCron runs 5 times', async () => {
execStub.returns(Bluebird.resolve({_cronSignature: 'RUNNING_CRON'}));
execStub.returns(Promise.resolve({_cronSignature: 'RUNNING_CRON'}));
try {
await recoverCron(status, locals);
+1 -1
View File
@@ -47,7 +47,7 @@ describe('slack', () => {
expect(IncomingWebhook.prototype.send).to.be.calledOnce;
expect(IncomingWebhook.prototype.send).to.be.calledWith({
text: 'flagger (flagger-id) flagged a message (language: flagger-lang)',
text: 'flagger (flagger-id; language: flagger-lang) flagged a message',
attachments: [{
fallback: 'Flag Message',
color: 'danger',
@@ -8,7 +8,6 @@ import {
attachTranslateFunction,
} from '../../../../../website/server/middlewares/language';
import common from '../../../../../website/common';
import Bluebird from 'bluebird';
import { model as User } from '../../../../../website/server/models/user';
const i18n = common.i18n;
@@ -162,7 +161,7 @@ describe('language middleware', () => {
return this;
},
exec () {
return Bluebird.resolve({
return Promise.resolve({
preferences: {
language: 'it',
},
+2 -3
View File
@@ -1,4 +1,3 @@
import Bluebird from 'bluebird';
import moment from 'moment';
import { model as User } from '../../../../../website/server/models/user';
import { model as Group } from '../../../../../website/server/models/group';
@@ -123,7 +122,7 @@ describe('User Model', () => {
it('adds notifications without data for all given users via static method', async () => {
let user = new User();
let otherUser = new User();
await Bluebird.all([user.save(), otherUser.save()]);
await Promise.all([user.save(), otherUser.save()]);
await User.pushNotification({_id: {$in: [user._id, otherUser._id]}}, 'CRON');
@@ -149,7 +148,7 @@ describe('User Model', () => {
it('adds notifications with data and seen status for all given users via static method', async () => {
let user = new User();
let otherUser = new User();
await Bluebird.all([user.save(), otherUser.save()]);
await Promise.all([user.save(), otherUser.save()]);
await User.pushNotification({_id: {$in: [user._id, otherUser._id]}}, 'CRON', {field: 1}, true);