Merge pull request #16479 from strapi/feat/back-limit-number-of-created-stages

This commit is contained in:
Marc 2023-04-25 16:43:01 +02:00 committed by GitHub
commit 94e2624b61
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 2 deletions

View File

@ -344,6 +344,19 @@ describeOnCondition(edition === 'EE')('Review workflows', () => {
expect(workflowRes.body.data).toBeUndefined();
}
});
test('It should throw an error if trying to create more than 200 stages', async () => {
const stagesRes = await requests.admin.put(
`/admin/review-workflows/workflows/${testWorkflow.id}/stages`,
{ body: { data: Array(201).fill({ name: 'new stage' }) } }
);
if (hasRW) {
expect(stagesRes.status).toBe(400);
expect(stagesRes.body.error).toBeDefined();
expect(stagesRes.body.error.name).toEqual('ValidationError');
expect(stagesRes.body.error.message).toBeDefined();
}
});
});
describe('Enabling/Disabling review workflows on a content type', () => {
@ -407,7 +420,7 @@ describeOnCondition(edition === 'EE')('Review workflows', () => {
});
});
describe('update a stage on an entity', () => {
describe('Update a stage on an entity', () => {
describe('Review Workflow is enabled', () => {
beforeAll(async () => {
await updateContentType(productUID, {

View File

@ -7,7 +7,12 @@ const stageObject = yup.object().shape({
name: yup.string().max(255).required(),
});
const validateUpdateStagesSchema = yup.array().of(stageObject).required();
const validateUpdateStagesSchema = yup
.array()
.of(stageObject)
.required()
.max(200, 'You can not create more than 200 stages');
const validateUpdateStageOnEntity = yup
.object()
.shape({