Files
habitica/test/api/v3/integration/debug/POST-debug_quest-progress.test.js
Phillip Thelen f8d315ff6e 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>
2024-01-16 15:18:47 -06:00

61 lines
1.4 KiB
JavaScript

import nconf from 'nconf';
import {
generateUser,
} from '../../../../helpers/api-integration/v3';
describe('POST /debug/quest-progress', () => {
let user;
beforeEach(async () => {
user = await generateUser();
});
afterEach(() => {
nconf.set('IS_PROD', false);
});
it('errors if user is not on a quest', async () => {
await expect(user.post('/debug/quest-progress'))
.to.eventually.be.rejected.and.to.deep.equal({
code: 400,
error: 'BadRequest',
message: 'User is not on a valid quest.',
});
});
it('increases boss quest progress by 1000', async () => {
await user.updateOne({
'party.quest.key': 'whale',
});
await user.post('/debug/quest-progress');
await user.sync();
expect(user.party.quest.progress.up).to.eql(1000);
});
it('increases collection quest progress by 300 items', async () => {
await user.updateOne({
'party.quest.key': 'evilsanta2',
});
await user.post('/debug/quest-progress');
await user.sync();
expect(user.party.quest.progress.collectedItems).to.eql(300);
});
it('returns error when not in production mode', async () => {
nconf.set('IS_PROD', true);
await expect(user.post('/debug/quest-progress'))
.eventually.be.rejected.and.to.deep.equal({
code: 404,
error: 'NotFound',
message: 'Not found.',
});
});
});