Upgrade to mongoose 7 (#14971)

* remove some unused dependencies

* update mongoose version

* make common tests pass

* Make unit tests pass

* make api v3 integration tests pass

* fix lint issues

* fix issue with package-lock

* fix(lint): we don't need no .js

* fix(lint): update to latest config-habitrpg

* chore(npm): update package locks

* fix(test): replace deprecated fn

* chore(package): update eslint-habitrpg again

* fix(lint): server linting

* fix(lint): client linting

* fix(client): correct mangled common imports

* chore(npm): update package-locks

* fix(lint): punctuation, module

---------

Co-authored-by: SabreCat <sabrecat@gmail.com>
Co-authored-by: SabreCat <sabe@habitica.com>
This commit is contained in:
Phillip Thelen
2024-01-16 22:18:47 +01:00
committed by GitHub
parent d0e4b533e3
commit f8d315ff6e
189 changed files with 2645 additions and 1423 deletions

View File

@@ -18,7 +18,7 @@ describe('POST /user/class/cast/:spellId', () => {
});
it('returns an error if spell does not exist', async () => {
await user.update({ 'stats.class': 'rogue' });
await user.updateOne({ 'stats.class': 'rogue' });
const spellId = 'invalidSpell';
await expect(user.post(`/user/class/cast/${spellId}`))
.to.eventually.be.rejected.and.eql({
@@ -39,7 +39,7 @@ describe('POST /user/class/cast/:spellId', () => {
});
it('returns an error if spell.mana > user.mana', async () => {
await user.update({ 'stats.class': 'rogue' });
await user.updateOne({ 'stats.class': 'rogue' });
await expect(user.post('/user/class/cast/backStab'))
.to.eventually.be.rejected.and.eql({
code: 401,
@@ -58,7 +58,7 @@ describe('POST /user/class/cast/:spellId', () => {
});
it('returns an error if use Healing Light spell with full health', async () => {
await user.update({
await user.updateOne({
'stats.class': 'healer',
'stats.lvl': 11,
'stats.hp': 50,
@@ -73,7 +73,7 @@ describe('POST /user/class/cast/:spellId', () => {
});
it('returns an error if spell.lvl > user.level', async () => {
await user.update({ 'stats.mp': 200, 'stats.class': 'wizard' });
await user.updateOne({ 'stats.mp': 200, 'stats.class': 'wizard' });
await expect(user.post('/user/class/cast/earth'))
.to.eventually.be.rejected.and.eql({
code: 401,
@@ -101,7 +101,7 @@ describe('POST /user/class/cast/:spellId', () => {
});
it('returns an error if targetId is required but missing', async () => {
await user.update({ 'stats.class': 'rogue', 'stats.lvl': 11 });
await user.updateOne({ 'stats.class': 'rogue', 'stats.lvl': 11 });
await expect(user.post('/user/class/cast/pickPocket'))
.to.eventually.be.rejected.and.eql({
code: 400,
@@ -111,7 +111,7 @@ describe('POST /user/class/cast/:spellId', () => {
});
it('returns an error if targeted task doesn\'t exist', async () => {
await user.update({ 'stats.class': 'rogue', 'stats.lvl': 11 });
await user.updateOne({ 'stats.class': 'rogue', 'stats.lvl': 11 });
await expect(user.post(`/user/class/cast/pickPocket?targetId=${generateUUID()}`))
.to.eventually.be.rejected.and.eql({
code: 404,
@@ -127,7 +127,7 @@ describe('POST /user/class/cast/:spellId', () => {
await groupLeader.post(`/tasks/challenge/${challenge._id}`, [
{ type: 'habit', text: 'task text' },
]);
await groupLeader.update({ 'stats.class': 'rogue', 'stats.lvl': 11 });
await groupLeader.updateOne({ 'stats.class': 'rogue', 'stats.lvl': 11 });
await sleep(0.5);
await groupLeader.sync();
await expect(groupLeader.post(`/user/class/cast/pickPocket?targetId=${groupLeader.tasksOrder.habits[0]}`))
@@ -146,7 +146,7 @@ describe('POST /user/class/cast/:spellId', () => {
type: 'todo',
});
await groupLeader.post(`/tasks/${groupTask._id}/assign`, [groupLeader._id]);
await groupLeader.update({ 'stats.class': 'rogue', 'stats.lvl': 11 });
await groupLeader.updateOne({ 'stats.class': 'rogue', 'stats.lvl': 11 });
await sleep(0.5);
await groupLeader.sync();
@@ -159,7 +159,7 @@ describe('POST /user/class/cast/:spellId', () => {
});
it('Issue #12361: returns an error if stealth has already been cast', async () => {
await user.update({
await user.updateOne({
'stats.class': 'rogue',
'stats.lvl': 15,
'stats.mp': 400,
@@ -180,7 +180,7 @@ describe('POST /user/class/cast/:spellId', () => {
groupDetails: { type: 'party', privacy: 'private' },
members: 1,
});
await groupLeader.update({ 'items.special.snowball': 3 });
await groupLeader.updateOne({ 'items.special.snowball': 3 });
const target = generateUUID();
await expect(groupLeader.post(`/user/class/cast/snowball?targetId=${target}`))
@@ -192,7 +192,7 @@ describe('POST /user/class/cast/:spellId', () => {
});
it('returns an error if party does not exists', async () => {
await user.update({ 'items.special.snowball': 3 });
await user.updateOne({ 'items.special.snowball': 3 });
await expect(user.post(`/user/class/cast/snowball?targetId=${generateUUID()}`))
.to.eventually.be.rejected.and.eql({
@@ -207,7 +207,7 @@ describe('POST /user/class/cast/:spellId', () => {
groupDetails: { type: 'party', privacy: 'private' },
members: 1,
});
await groupLeader.update({ 'stats.mp': 200, 'stats.class': 'wizard', 'stats.lvl': 13 });
await groupLeader.updateOne({ 'stats.mp': 200, 'stats.class': 'wizard', 'stats.lvl': 13 });
await groupLeader.post('/user/class/cast/earth');
await sleep(1);
@@ -224,11 +224,11 @@ describe('POST /user/class/cast/:spellId', () => {
});
let promises = [];
promises.push(group.groupLeader.update({ 'stats.mp': 200, 'stats.class': 'wizard', 'stats.lvl': 20 }));
promises.push(group.members[0].update({ 'stats.mp': 0, 'stats.class': 'warrior', 'stats.lvl': 20 }));
promises.push(group.members[1].update({ 'stats.mp': 0, 'stats.class': 'wizard', 'stats.lvl': 20 }));
promises.push(group.members[2].update({ 'stats.mp': 0, 'stats.class': 'rogue', 'stats.lvl': 20 }));
promises.push(group.members[3].update({ 'stats.mp': 0, 'stats.class': 'healer', 'stats.lvl': 20 }));
promises.push(group.groupLeader.updateOne({ 'stats.mp': 200, 'stats.class': 'wizard', 'stats.lvl': 20 }));
promises.push(group.members[0].updateOne({ 'stats.mp': 0, 'stats.class': 'warrior', 'stats.lvl': 20 }));
promises.push(group.members[1].updateOne({ 'stats.mp': 0, 'stats.class': 'wizard', 'stats.lvl': 20 }));
promises.push(group.members[2].updateOne({ 'stats.mp': 0, 'stats.class': 'rogue', 'stats.lvl': 20 }));
promises.push(group.members[3].updateOne({ 'stats.mp': 0, 'stats.class': 'healer', 'stats.lvl': 20 }));
await Promise.all(promises);
await group.groupLeader.post('/user/class/cast/mpheal');
@@ -252,7 +252,7 @@ describe('POST /user/class/cast/:spellId', () => {
members: 1,
});
await groupLeader.update({ 'stats.mp': 200, 'stats.class': 'wizard', 'stats.lvl': 13 });
await groupLeader.updateOne({ 'stats.mp': 200, 'stats.class': 'wizard', 'stats.lvl': 13 });
await groupLeader.post('/user/class/cast/earth', { quantity: 2 });
await sleep(1);
@@ -275,7 +275,7 @@ describe('POST /user/class/cast/:spellId', () => {
text: 'todo group',
type: 'todo',
});
await user.update({ 'stats.class': 'healer', 'stats.mp': 200, 'stats.lvl': 15 });
await user.updateOne({ 'stats.class': 'healer', 'stats.mp': 200, 'stats.lvl': 15 });
await user.post(`/tasks/${groupTask._id}/assign`, [user._id]);
await user.put('/user', {
'preferences.tasks.mirrorGroupTasks': [guild._id],
@@ -305,7 +305,7 @@ describe('POST /user/class/cast/:spellId', () => {
});
const leader = party.groupLeader;
const recipient = party.members[0];
await leader.update({ 'stats.gp': 10 });
await leader.updateOne({ 'stats.gp': 10 });
await leader.post(`/user/class/cast/birthday?targetId=${recipient._id}`);
await leader.sync();
await recipient.sync();
@@ -314,14 +314,14 @@ describe('POST /user/class/cast/:spellId', () => {
});
it('only increases user\'s achievement one if target == caster', async () => {
await user.update({ 'stats.gp': 10 });
await user.updateOne({ 'stats.gp': 10 });
await user.post(`/user/class/cast/birthday?targetId=${user._id}`);
await user.sync();
expect(user.achievements.birthday).to.equal(1);
});
it('passes correct target to spell when targetType === \'task\'', async () => {
await user.update({ 'stats.class': 'wizard', 'stats.lvl': 11 });
await user.updateOne({ 'stats.class': 'wizard', 'stats.lvl': 11 });
const task = await user.post('/tasks/user', {
text: 'test habit',
@@ -334,7 +334,7 @@ describe('POST /user/class/cast/:spellId', () => {
});
it('passes correct target to spell when targetType === \'self\'', async () => {
await user.update({ 'stats.class': 'wizard', 'stats.lvl': 14, 'stats.mp': 50 });
await user.updateOne({ 'stats.class': 'wizard', 'stats.lvl': 14, 'stats.mp': 50 });
const result = await user.post('/user/class/cast/frost');