mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 06:37:23 +01:00
add max length validations for summary in challenge create and update… (#14053)
* add max length validations for summary in challenge create and update controllers * Add validation to group APIs * fix lint errors * add validation to group plan * fix imports * add tests * add max length validations for summary in challenge create and update controllers * Add validation to group APIs * fix lint errors * add validation to group plan * fix imports * add tests * lint checks
This commit is contained in:
@@ -4,6 +4,7 @@ import {
|
||||
createAndPopulateGroup,
|
||||
translate as t,
|
||||
} from '../../../../helpers/api-integration/v3';
|
||||
import { MAX_SUMMARY_SIZE_FOR_CHALLENGES } from '../../../../../website/common/script/constants';
|
||||
|
||||
describe('POST /challenges', () => {
|
||||
it('returns error when group is empty', async () => {
|
||||
@@ -60,6 +61,22 @@ describe('POST /challenges', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('return error when creating a challenge with summary with greater than MAX_SUMMARY_SIZE_FOR_CHALLENGES characters', async () => {
|
||||
const user = await generateUser();
|
||||
const summary = 'A'.repeat(MAX_SUMMARY_SIZE_FOR_CHALLENGES + 1);
|
||||
const group = createAndPopulateGroup({
|
||||
members: 1,
|
||||
});
|
||||
await expect(user.post('/challenges', {
|
||||
group: group._id,
|
||||
summary,
|
||||
})).to.eventually.be.rejected.and.eql({
|
||||
code: 400,
|
||||
error: 'BadRequest',
|
||||
message: t('invalidReqParams'),
|
||||
});
|
||||
});
|
||||
|
||||
context('Creating a challenge for a valid group', () => {
|
||||
let groupLeader;
|
||||
let group;
|
||||
|
||||
Reference in New Issue
Block a user