Files
habitica/test/api/v4/POST-bug-report.test.js
negue a1cddcaf17 Feature: new "report a bug" modal (#13530)
* WIP: report a bug api/ui

* fix lint

* add USER_USERNAME

* extend sendTxn tests / checks + fix bug report email

* fix lint

* add more checks to sendTxn - fix bug-report variables

* fix lint / ci

* fix test: reset email config url

* fix test stub

* fix tests

* refactor the variables checks

* lint.

* move bug-report page as a modal

* send user_email to the email

* show true/false instead 1/0

* fix issues

* fix footer report bug email if not logged in

* fix styles/margins

* prefill user's email

* show facebook email if local email not existing

* bugReportSuccessModal.vue

* add BROWSER_UA to mail properties

* extract bugReportLogic to its own lib file for unit test

* test api validators

* fix lint
2021-12-14 19:16:50 -06:00

50 lines
1.3 KiB
JavaScript

import {
generateUser,
} from '../../helpers/api-integration/v4';
describe('POST /bug-report', () => {
let user;
beforeEach(async () => {
user = await generateUser();
});
it('returns an error when message is not added', async () => {
await expect(user.post('/bug-report', {
message: '',
}))
.to.eventually.be.rejected.and.to.eql({
code: 400,
error: 'BadRequest',
// seems it is not possible to get the real error message
message: 'Invalid request parameters.',
});
});
it('returns an error when email is not added', async () => {
await expect(user.post('/bug-report', {
message: 'message',
email: '',
}))
.to.eventually.be.rejected.and.to.eql({
code: 400,
error: 'BadRequest',
// seems it is not possible to get the real error message
message: 'Invalid request parameters.',
});
});
it('returns an error when email is not valid', async () => {
await expect(user.post('/bug-report', {
message: 'message',
email: 'notamail',
}))
.to.eventually.be.rejected.and.to.eql({
code: 400,
error: 'BadRequest',
// seems it is not possible to get the real error message
message: 'Invalid request parameters.',
});
});
});