mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-18 07:07:35 +01:00
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:
@@ -14,7 +14,7 @@ describe('API Messages', () => {
|
||||
let vars = {a: 1};
|
||||
sandbox.stub(_, 'clone').returns({});
|
||||
apiMessages('guildsOnlyPaginate', vars);
|
||||
expect(_.clone).to.have.been.called.once;
|
||||
expect(_.clone).to.have.been.calledOnce;
|
||||
expect(_.clone).to.have.been.calledWith(vars);
|
||||
});
|
||||
|
||||
@@ -23,9 +23,9 @@ describe('API Messages', () => {
|
||||
let stub = sinon.stub().returns('string');
|
||||
sandbox.stub(_, 'template').returns(stub);
|
||||
apiMessages('guildsOnlyPaginate', vars);
|
||||
expect(_.template).to.have.been.called.once;
|
||||
expect(_.template).to.have.been.calledOnce;
|
||||
expect(_.template).to.have.been.calledWith(message);
|
||||
expect(stub).to.have.been.called.once;
|
||||
expect(stub).to.have.been.calledOnce;
|
||||
expect(stub).to.have.been.calledWith(vars);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import mongoose from 'mongoose';
|
||||
import {
|
||||
removeFromArray,
|
||||
removeFromArray,
|
||||
} from '../../../../../website/server/libs/collectionManipulators';
|
||||
|
||||
describe('Collection Manipulators', () => {
|
||||
|
||||
@@ -181,9 +181,9 @@ describe('cron', () => {
|
||||
cron({user, tasksByType, daysMissed, analytics});
|
||||
|
||||
expect(user.purchased.plan.customerId).to.not.exist;
|
||||
expect(user.purchased.plan.consecutive.gemCapExtra).to.be.empty;
|
||||
expect(user.purchased.plan.consecutive.count).to.be.empty;
|
||||
expect(user.purchased.plan.consecutive.offset).to.be.empty;
|
||||
expect(user.purchased.plan.consecutive.gemCapExtra).to.equal(0);
|
||||
expect(user.purchased.plan.consecutive.count).to.equal(0);
|
||||
expect(user.purchased.plan.consecutive.offset).to.equal(0);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1027,7 +1027,7 @@ describe('cron', () => {
|
||||
cron({user, tasksByType, daysMissed, analytics});
|
||||
expect(user.party.quest.progress.up).to.equal(0);
|
||||
expect(user.party.quest.progress.down).to.equal(0);
|
||||
expect(user.party.quest.progress.collectedItems).to.be.empty;
|
||||
expect(user.party.quest.progress.collectedItems).to.equal(0);
|
||||
});
|
||||
|
||||
it('applies the user progress', () => {
|
||||
|
||||
@@ -132,11 +132,11 @@ describe('Amazon Payments - Checkout', () => {
|
||||
};
|
||||
|
||||
await expect(amzLib.checkout({gift, user, orderReferenceId, headers}))
|
||||
.to.eventually.be.rejected.and.to.eql({
|
||||
httpCode: 400,
|
||||
message: 'Amount must be at least 1.',
|
||||
name: 'BadRequest',
|
||||
});
|
||||
.to.eventually.be.rejected.and.to.eql({
|
||||
httpCode: 400,
|
||||
message: 'Amount must be at least 1.',
|
||||
name: 'BadRequest',
|
||||
});
|
||||
});
|
||||
|
||||
it('should error if user cannot get gems gems', async () => {
|
||||
|
||||
@@ -123,11 +123,11 @@ describe('Amazon Payments - Subscribe', () => {
|
||||
groupId,
|
||||
headers,
|
||||
}))
|
||||
.to.eventually.be.rejected.and.to.eql({
|
||||
httpCode: 400,
|
||||
name: 'BadRequest',
|
||||
message: i18n.t('missingSubscriptionCode'),
|
||||
});
|
||||
.to.eventually.be.rejected.and.to.eql({
|
||||
httpCode: 400,
|
||||
name: 'BadRequest',
|
||||
message: i18n.t('missingSubscriptionCode'),
|
||||
});
|
||||
});
|
||||
|
||||
it('should throw an error if we are missing a billingAgreementId', async () => {
|
||||
@@ -138,11 +138,11 @@ describe('Amazon Payments - Subscribe', () => {
|
||||
groupId,
|
||||
headers,
|
||||
}))
|
||||
.to.eventually.be.rejected.and.to.eql({
|
||||
httpCode: 400,
|
||||
name: 'BadRequest',
|
||||
message: 'Missing req.body.billingAgreementId',
|
||||
});
|
||||
.to.eventually.be.rejected.and.to.eql({
|
||||
httpCode: 400,
|
||||
name: 'BadRequest',
|
||||
message: 'Missing req.body.billingAgreementId',
|
||||
});
|
||||
});
|
||||
|
||||
it('should throw an error when coupon code is missing', async () => {
|
||||
@@ -156,11 +156,11 @@ describe('Amazon Payments - Subscribe', () => {
|
||||
groupId,
|
||||
headers,
|
||||
}))
|
||||
.to.eventually.be.rejected.and.to.eql({
|
||||
httpCode: 400,
|
||||
name: 'BadRequest',
|
||||
message: i18n.t('couponCodeRequired'),
|
||||
});
|
||||
.to.eventually.be.rejected.and.to.eql({
|
||||
httpCode: 400,
|
||||
name: 'BadRequest',
|
||||
message: i18n.t('couponCodeRequired'),
|
||||
});
|
||||
});
|
||||
|
||||
it('should throw an error when coupon code is invalid', async () => {
|
||||
@@ -182,11 +182,11 @@ describe('Amazon Payments - Subscribe', () => {
|
||||
groupId,
|
||||
headers,
|
||||
}))
|
||||
.to.eventually.be.rejected.and.to.eql({
|
||||
httpCode: 401,
|
||||
name: 'NotAuthorized',
|
||||
message: i18n.t('invalidCoupon'),
|
||||
});
|
||||
.to.eventually.be.rejected.and.to.eql({
|
||||
httpCode: 401,
|
||||
name: 'NotAuthorized',
|
||||
message: i18n.t('invalidCoupon'),
|
||||
});
|
||||
cc.validate.restore();
|
||||
});
|
||||
|
||||
|
||||
@@ -305,7 +305,7 @@ describe('Purchasing a group plan for group', () => {
|
||||
|
||||
await api.createSubscription(data);
|
||||
|
||||
expect(sender.sendTxn).to.be.calledFourTimes;
|
||||
expect(sender.sendTxn).to.have.callCount(4);
|
||||
expect(sender.sendTxn.args[0][0]._id).to.equal(TECH_ASSISTANCE_EMAIL);
|
||||
expect(sender.sendTxn.args[0][1]).to.equal('admin-user-subscription-details');
|
||||
expect(sender.sendTxn.args[1][0]._id).to.equal(recipient._id);
|
||||
@@ -338,7 +338,7 @@ describe('Purchasing a group plan for group', () => {
|
||||
|
||||
await api.createSubscription(data);
|
||||
|
||||
expect(sender.sendTxn).to.be.calledFourTimes;
|
||||
expect(sender.sendTxn).to.have.callCount(4);
|
||||
expect(sender.sendTxn.args[0][0]._id).to.equal(TECH_ASSISTANCE_EMAIL);
|
||||
expect(sender.sendTxn.args[0][1]).to.equal('admin-user-subscription-details');
|
||||
expect(sender.sendTxn.args[1][0]._id).to.equal(recipient._id);
|
||||
|
||||
@@ -71,11 +71,11 @@ describe('checkout', () => {
|
||||
};
|
||||
|
||||
await expect(paypalPayments.checkout({gift}))
|
||||
.to.eventually.be.rejected.and.to.eql({
|
||||
httpCode: 400,
|
||||
message: 'Amount must be at least 1.',
|
||||
name: 'BadRequest',
|
||||
});
|
||||
.to.eventually.be.rejected.and.to.eql({
|
||||
httpCode: 400,
|
||||
message: 'Amount must be at least 1.',
|
||||
name: 'BadRequest',
|
||||
});
|
||||
});
|
||||
|
||||
it('should error if the user cannot get gems', async () => {
|
||||
|
||||
@@ -42,11 +42,11 @@ describe('cancel subscription', () => {
|
||||
user,
|
||||
groupId: undefined,
|
||||
}))
|
||||
.to.eventually.be.rejected.and.to.eql({
|
||||
httpCode: 401,
|
||||
name: 'NotAuthorized',
|
||||
message: i18n.t('missingSubscription'),
|
||||
});
|
||||
.to.eventually.be.rejected.and.to.eql({
|
||||
httpCode: 401,
|
||||
name: 'NotAuthorized',
|
||||
message: i18n.t('missingSubscription'),
|
||||
});
|
||||
});
|
||||
|
||||
it('throws an error if the group is not found', async () => {
|
||||
@@ -54,11 +54,11 @@ describe('cancel subscription', () => {
|
||||
user,
|
||||
groupId: 'fake-group',
|
||||
}))
|
||||
.to.eventually.be.rejected.and.to.eql({
|
||||
httpCode: 404,
|
||||
name: 'NotFound',
|
||||
message: i18n.t('groupNotFound'),
|
||||
});
|
||||
.to.eventually.be.rejected.and.to.eql({
|
||||
httpCode: 404,
|
||||
name: 'NotFound',
|
||||
message: i18n.t('groupNotFound'),
|
||||
});
|
||||
});
|
||||
|
||||
it('throws an error if user is not the group leader', async () => {
|
||||
@@ -70,11 +70,11 @@ describe('cancel subscription', () => {
|
||||
user: nonLeader,
|
||||
groupId,
|
||||
}))
|
||||
.to.eventually.be.rejected.and.to.eql({
|
||||
httpCode: 401,
|
||||
name: 'NotAuthorized',
|
||||
message: i18n.t('onlyGroupLeaderCanManageSubscription'),
|
||||
});
|
||||
.to.eventually.be.rejected.and.to.eql({
|
||||
httpCode: 401,
|
||||
name: 'NotAuthorized',
|
||||
message: i18n.t('onlyGroupLeaderCanManageSubscription'),
|
||||
});
|
||||
});
|
||||
|
||||
describe('success', () => {
|
||||
|
||||
@@ -88,11 +88,11 @@ describe('checkout with subscription', () => {
|
||||
headers,
|
||||
coupon,
|
||||
}))
|
||||
.to.eventually.be.rejected.and.to.eql({
|
||||
httpCode: 400,
|
||||
name: 'BadRequest',
|
||||
message: 'Missing req.body.id',
|
||||
});
|
||||
.to.eventually.be.rejected.and.to.eql({
|
||||
httpCode: 400,
|
||||
name: 'BadRequest',
|
||||
message: 'Missing req.body.id',
|
||||
});
|
||||
});
|
||||
|
||||
it('should throw an error when coupon code is missing', async () => {
|
||||
@@ -108,11 +108,11 @@ describe('checkout with subscription', () => {
|
||||
headers,
|
||||
coupon,
|
||||
}))
|
||||
.to.eventually.be.rejected.and.to.eql({
|
||||
httpCode: 400,
|
||||
name: 'BadRequest',
|
||||
message: i18n.t('couponCodeRequired'),
|
||||
});
|
||||
.to.eventually.be.rejected.and.to.eql({
|
||||
httpCode: 400,
|
||||
name: 'BadRequest',
|
||||
message: i18n.t('couponCodeRequired'),
|
||||
});
|
||||
});
|
||||
|
||||
it('should throw an error when coupon code is invalid', async () => {
|
||||
@@ -136,11 +136,11 @@ describe('checkout with subscription', () => {
|
||||
headers,
|
||||
coupon,
|
||||
}))
|
||||
.to.eventually.be.rejected.and.to.eql({
|
||||
httpCode: 400,
|
||||
name: 'BadRequest',
|
||||
message: i18n.t('invalidCoupon'),
|
||||
});
|
||||
.to.eventually.be.rejected.and.to.eql({
|
||||
httpCode: 400,
|
||||
name: 'BadRequest',
|
||||
message: i18n.t('invalidCoupon'),
|
||||
});
|
||||
cc.validate.restore();
|
||||
});
|
||||
|
||||
|
||||
@@ -57,11 +57,11 @@ describe('checkout', () => {
|
||||
headers,
|
||||
coupon,
|
||||
}, stripe))
|
||||
.to.eventually.be.rejected.and.to.eql({
|
||||
httpCode: 400,
|
||||
message: 'Amount must be at least 1.',
|
||||
name: 'BadRequest',
|
||||
});
|
||||
.to.eventually.be.rejected.and.to.eql({
|
||||
httpCode: 400,
|
||||
message: 'Amount must be at least 1.',
|
||||
name: 'BadRequest',
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
@@ -43,11 +43,11 @@ describe('edit subscription', () => {
|
||||
user,
|
||||
groupId: undefined,
|
||||
}))
|
||||
.to.eventually.be.rejected.and.to.eql({
|
||||
httpCode: 401,
|
||||
name: 'NotAuthorized',
|
||||
message: i18n.t('missingSubscription'),
|
||||
});
|
||||
.to.eventually.be.rejected.and.to.eql({
|
||||
httpCode: 401,
|
||||
name: 'NotAuthorized',
|
||||
message: i18n.t('missingSubscription'),
|
||||
});
|
||||
});
|
||||
|
||||
it('throws an error if a token is not provided', async () => {
|
||||
@@ -55,11 +55,11 @@ describe('edit subscription', () => {
|
||||
user,
|
||||
groupId: undefined,
|
||||
}))
|
||||
.to.eventually.be.rejected.and.to.eql({
|
||||
httpCode: 400,
|
||||
name: 'BadRequest',
|
||||
message: 'Missing req.body.id',
|
||||
});
|
||||
.to.eventually.be.rejected.and.to.eql({
|
||||
httpCode: 400,
|
||||
name: 'BadRequest',
|
||||
message: 'Missing req.body.id',
|
||||
});
|
||||
});
|
||||
|
||||
it('throws an error if the group is not found', async () => {
|
||||
@@ -68,11 +68,11 @@ describe('edit subscription', () => {
|
||||
user,
|
||||
groupId: 'fake-group',
|
||||
}))
|
||||
.to.eventually.be.rejected.and.to.eql({
|
||||
httpCode: 404,
|
||||
name: 'NotFound',
|
||||
message: i18n.t('groupNotFound'),
|
||||
});
|
||||
.to.eventually.be.rejected.and.to.eql({
|
||||
httpCode: 404,
|
||||
name: 'NotFound',
|
||||
message: i18n.t('groupNotFound'),
|
||||
});
|
||||
});
|
||||
|
||||
it('throws an error if user is not the group leader', async () => {
|
||||
@@ -85,11 +85,11 @@ describe('edit subscription', () => {
|
||||
user: nonLeader,
|
||||
groupId,
|
||||
}))
|
||||
.to.eventually.be.rejected.and.to.eql({
|
||||
httpCode: 401,
|
||||
name: 'NotAuthorized',
|
||||
message: i18n.t('onlyGroupLeaderCanManageSubscription'),
|
||||
});
|
||||
.to.eventually.be.rejected.and.to.eql({
|
||||
httpCode: 401,
|
||||
name: 'NotAuthorized',
|
||||
message: i18n.t('onlyGroupLeaderCanManageSubscription'),
|
||||
});
|
||||
});
|
||||
|
||||
describe('success', () => {
|
||||
|
||||
@@ -34,7 +34,7 @@ describe('Stripe - Webhooks', () => {
|
||||
it('logs an error if an unsupported webhook event is passed', async () => {
|
||||
const error = new Error(`Missing handler for Stripe webhook ${eventType}`);
|
||||
await stripePayments.handleWebhooks({requestBody: event}, stripe);
|
||||
expect(logger.error).to.have.been.called.once;
|
||||
expect(logger.error).to.have.been.calledOnce;
|
||||
|
||||
const calledWith = logger.error.getCall(0).args;
|
||||
expect(calledWith[0].message).to.equal(error.message);
|
||||
@@ -43,7 +43,7 @@ describe('Stripe - Webhooks', () => {
|
||||
|
||||
it('retrieves and validates the event from Stripe', async () => {
|
||||
await stripePayments.handleWebhooks({requestBody: event}, stripe);
|
||||
expect(stripe.events.retrieve).to.have.been.called.once;
|
||||
expect(stripe.events.retrieve).to.have.been.calledOnce;
|
||||
expect(stripe.events.retrieve).to.have.been.calledWith(event.id);
|
||||
});
|
||||
});
|
||||
@@ -70,7 +70,7 @@ describe('Stripe - Webhooks', () => {
|
||||
|
||||
await stripePayments.handleWebhooks({requestBody: {}}, stripe);
|
||||
|
||||
expect(stripe.events.retrieve).to.have.been.called.once;
|
||||
expect(stripe.events.retrieve).to.have.been.calledOnce;
|
||||
expect(stripe.customers.del).to.not.have.been.called;
|
||||
expect(payments.cancelSubscription).to.not.have.been.called;
|
||||
stripe.events.retrieve.restore();
|
||||
|
||||
@@ -54,7 +54,7 @@ describe('taskManager', () => {
|
||||
expect(newTask.type).to.equal(testHabit.type);
|
||||
expect(newTask.up).to.equal(testHabit.up);
|
||||
expect(newTask.down).to.equal(testHabit.down);
|
||||
expect(newTask.createdAt).isNotEmtpy;
|
||||
expect(newTask.createdAt).to.exist;
|
||||
});
|
||||
|
||||
it('gets user tasks', async () => {
|
||||
@@ -75,7 +75,7 @@ describe('taskManager', () => {
|
||||
expect(task.type).to.equal(testHabit.type);
|
||||
expect(task.up).to.equal(testHabit.up);
|
||||
expect(task.down).to.equal(testHabit.down);
|
||||
expect(task.createdAt).isNotEmtpy;
|
||||
expect(task.createdAt).to.exist;
|
||||
});
|
||||
|
||||
it('creates group tasks', async () => {
|
||||
@@ -89,7 +89,7 @@ describe('taskManager', () => {
|
||||
expect(newTask.type).to.equal(testHabit.type);
|
||||
expect(newTask.up).to.equal(testHabit.up);
|
||||
expect(newTask.down).to.equal(testHabit.down);
|
||||
expect(newTask.createdAt).isNotEmtpy;
|
||||
expect(newTask.createdAt).to.exist;
|
||||
expect(newTask.group.id).to.equal(group._id);
|
||||
});
|
||||
|
||||
@@ -111,7 +111,7 @@ describe('taskManager', () => {
|
||||
expect(task.type).to.equal(testHabit.type);
|
||||
expect(task.up).to.equal(testHabit.up);
|
||||
expect(task.down).to.equal(testHabit.down);
|
||||
expect(task.createdAt).isNotEmtpy;
|
||||
expect(task.createdAt).to.exist;
|
||||
expect(task.group.id).to.equal(group._id);
|
||||
});
|
||||
|
||||
@@ -126,7 +126,7 @@ describe('taskManager', () => {
|
||||
expect(newTask.type).to.equal(testHabit.type);
|
||||
expect(newTask.up).to.equal(testHabit.up);
|
||||
expect(newTask.down).to.equal(testHabit.down);
|
||||
expect(newTask.createdAt).isNotEmtpy;
|
||||
expect(newTask.createdAt).to.exist;
|
||||
expect(newTask.challenge.id).to.equal(challenge._id);
|
||||
});
|
||||
|
||||
@@ -148,7 +148,7 @@ describe('taskManager', () => {
|
||||
expect(task.type).to.equal(testHabit.type);
|
||||
expect(task.up).to.equal(testHabit.up);
|
||||
expect(task.down).to.equal(testHabit.down);
|
||||
expect(task.createdAt).isNotEmtpy;
|
||||
expect(task.createdAt).to.exist;
|
||||
expect(task.challenge.id).to.equal(challenge._id);
|
||||
});
|
||||
|
||||
@@ -171,7 +171,7 @@ describe('taskManager', () => {
|
||||
expect(syncableTask.updatedAt).to.not.exist;
|
||||
});
|
||||
|
||||
it('moves tasks to a specified position', async() => {
|
||||
it('moves tasks to a specified position', async () => {
|
||||
let order = ['task-id-1', 'task-id-2'];
|
||||
|
||||
moveTask(order, 'task-id-2', 0);
|
||||
|
||||
Reference in New Issue
Block a user