Upgrade tests tools and lint migrations and scripts (part 2) (#9998)

* upgrade gulp-babel

* upgrade babel-eslint

* upgrade eslint-friendly-formatter

* start upgrading chai

* start to upgrade eslint

* restore skipped tests

* start to upgrqde monk

* fix linting and remove unused file

* fix mocha notifications, and common tests

* fix unit tests

* start to fix initrgration tests

* more integration tests fixes

* upgrade monk to latest version

* lint /scripts

* migrations: start moving to /archive unused migrations and run eslint with --fix

* lint migrations

* fix more integration tests

* fix test
This commit is contained in:
Matteo Pagliazzi
2018-02-17 18:11:24 +01:00
committed by GitHub
parent b0ae0ef4da
commit 74ba55c20b
362 changed files with 8041 additions and 7813 deletions

View File

@@ -347,11 +347,11 @@ api.loginSocial = {
// Clean previous email preferences
if (savedUser.auth[network].emails && savedUser.auth[network].emails[0] && savedUser.auth[network].emails[0].value) {
EmailUnsubscription
.remove({email: savedUser.auth[network].emails[0].value.toLowerCase()})
.exec()
.then(() => {
if (!existingUser) sendTxnEmail(savedUser, 'welcome');
}); // eslint-disable-line max-nested-callbacks
.remove({email: savedUser.auth[network].emails[0].value.toLowerCase()})
.exec()
.then(() => {
if (!existingUser) sendTxnEmail(savedUser, 'welcome');
}); // eslint-disable-line max-nested-callbacks
}
if (!existingUser) {

View File

@@ -434,11 +434,11 @@ api.getUserChallenges = {
let challenges = await Challenge.find({
$or: orOptions,
})
.sort('-official -createdAt')
// see below why we're not using populate
// .populate('group', basicGroupFields)
// .populate('leader', nameFields)
.exec();
.sort('-official -createdAt')
// see below why we're not using populate
// .populate('group', basicGroupFields)
// .populate('leader', nameFields)
.exec();
let resChals = challenges.map(challenge => challenge.toJSON());
// Instead of populate we make a find call manually because of https://github.com/Automattic/mongoose/issues/3833

View File

@@ -1018,9 +1018,9 @@ async function _inviteByEmail (invite, group, inviter, req, res) {
if (!invite.email) throw new BadRequest(res.t('inviteMissingEmail'));
let userToContact = await User.findOne({$or: [
{'auth.local.email': invite.email},
{'auth.facebook.emails.value': invite.email},
{'auth.google.emails.value': invite.email},
{'auth.local.email': invite.email},
{'auth.facebook.emails.value': invite.email},
{'auth.google.emails.value': invite.email},
]})
.select({_id: true, 'preferences.emailNotifications': true})
.exec();

View File

@@ -71,15 +71,15 @@ api.getPatrons = {
const perPage = 50;
let patrons = await User
.find({
'backer.tier': {$gt: 0},
})
.select('contributor backer profile.name')
.sort('-backer.tier')
.skip(page * perPage)
.limit(perPage)
.lean()
.exec();
.find({
'backer.tier': {$gt: 0},
})
.select('contributor backer profile.name')
.sort('-backer.tier')
.skip(page * perPage)
.limit(perPage)
.lean()
.exec();
res.respond(200, patrons);
},
@@ -123,13 +123,13 @@ api.getHeroes = {
middlewares: [authWithHeaders()],
async handler (req, res) {
let heroes = await User
.find({
'contributor.level': {$gt: 0},
})
.select('contributor backer profile.name')
.sort('-contributor.level')
.lean()
.exec();
.find({
'contributor.level': {$gt: 0},
})
.select('contributor backer profile.name')
.sort('-contributor.level')
.lean()
.exec();
res.respond(200, heroes);
},

View File

@@ -13,11 +13,11 @@ function geti18nBrowserScript (language) {
return `(function () {
if (!window) return;
window['habitica-i18n'] = ${JSON.stringify({
availableLanguages,
language,
strings: translations[langCode],
momentLang: momentLangs[language.momentLangCode],
})};
availableLanguages,
language,
strings: translations[langCode],
momentLang: momentLangs[language.momentLangCode],
})};
})()`;
}

View File

@@ -408,8 +408,8 @@ api.getChallengeMemberProgress = {
userId: memberId,
'challenge.id': challengeId,
})
.select('-tags') // We don't want to return the tags publicly TODO same for other data?
.exec();
.select('-tags') // We don't want to return the tags publicly TODO same for other data?
.exec();
// manually call toJSON with minimize: true so empty paths aren't returned
let response = member.toJSON({minimize: true});

View File

@@ -79,8 +79,8 @@ api.inviteToQuest = {
'party._id': group._id,
_id: {$ne: user._id},
})
.select('auth.facebook auth.local preferences.emailNotifications profile.name pushDevices')
.exec();
.select('auth.facebook auth.local preferences.emailNotifications profile.name pushDevices')
.exec();
group.markModified('quest');
group.quest.key = questKey;

View File

@@ -489,8 +489,8 @@ api.getGroupApprovals = {
'group.approval.approved': false,
'group.approval.requested': true,
}, 'userId group text')
.populate('userId', 'profile')
.exec();
.populate('userId', 'profile')
.exec();
res.respond(200, approvals);
},