diff --git a/packages/core/content-manager/server/src/controllers/collection-types.ts b/packages/core/content-manager/server/src/controllers/collection-types.ts index 65cbfae089..de3d65e15c 100644 --- a/packages/core/content-manager/server/src/controllers/collection-types.ts +++ b/packages/core/content-manager/server/src/controllers/collection-types.ts @@ -232,6 +232,7 @@ export default { ]); const sanitizedDocument = await permissionChecker.sanitizeOutput(document); + ctx.status = 201; ctx.body = await documentMetadata.formatDocumentWithMetadata(model, sanitizedDocument, { // Empty metadata as it's not relevant for a new document availableLocales: false, diff --git a/packages/core/content-releases/server/src/controllers/__tests__/release-action.test.ts b/packages/core/content-releases/server/src/controllers/__tests__/release-action.test.ts index 5c3b6883e9..d6851caa67 100644 --- a/packages/core/content-releases/server/src/controllers/__tests__/release-action.test.ts +++ b/packages/core/content-releases/server/src/controllers/__tests__/release-action.test.ts @@ -100,6 +100,7 @@ describe('Release Action controller', () => { params: { releaseId: 1, }, + created: jest.fn(), request: { body: [ { @@ -123,9 +124,18 @@ describe('Release Action controller', () => { await releaseActionController.createMany(ctx); expect(mockCreateAction).toHaveBeenCalledTimes(2); - expect(ctx.body.data).toHaveLength(2); - expect(ctx.body.meta.totalEntries).toBe(2); - expect(ctx.body.meta.entriesAlreadyInRelease).toBe(0); + + expect(ctx.created).toHaveBeenCalledWith( + expect.objectContaining({ + data: expect.any(Array), // Ensure data is an array + meta: expect.objectContaining({ + totalEntries: 2, + entriesAlreadyInRelease: 0, + }), + }) + ); + const firstCallArgument = ctx.created.mock.calls[0][0]; + expect(firstCallArgument.data.length).toBe(2); }); it('should count already added entries and dont throw an error', async () => { @@ -139,6 +149,7 @@ describe('Release Action controller', () => { params: { releaseId: 1, }, + created: jest.fn(), request: { body: [ { @@ -155,9 +166,10 @@ describe('Release Action controller', () => { await releaseActionController.createMany(ctx); expect(mockCreateAction).toHaveBeenCalledTimes(1); - expect(ctx.body.data).toHaveLength(0); - expect(ctx.body.meta.totalEntries).toBe(1); - expect(ctx.body.meta.entriesAlreadyInRelease).toBe(1); + expect(ctx.created).toHaveBeenCalledWith({ + data: [], + meta: { totalEntries: 1, entriesAlreadyInRelease: 1 }, + }); }); }); diff --git a/packages/core/content-releases/server/src/controllers/release-action.ts b/packages/core/content-releases/server/src/controllers/release-action.ts index 8b6503eac1..ac28fbd8f7 100644 --- a/packages/core/content-releases/server/src/controllers/release-action.ts +++ b/packages/core/content-releases/server/src/controllers/release-action.ts @@ -26,9 +26,9 @@ const releaseActionController = { const releaseService = getService('release', { strapi }); const releaseAction = await releaseService.createAction(releaseId, releaseActionArgs); - ctx.body = { + ctx.created({ data: releaseAction, - }; + }); }, async createMany(ctx: Koa.Context) { @@ -64,13 +64,13 @@ const releaseActionController = { const newReleaseActions = releaseActions.filter((action) => action !== null); - ctx.body = { + ctx.created({ data: newReleaseActions, meta: { entriesAlreadyInRelease: releaseActions.length - newReleaseActions.length, totalEntries: releaseActions.length, }, - }; + }); }, async findMany(ctx: Koa.Context) { diff --git a/packages/core/content-releases/server/src/controllers/release.ts b/packages/core/content-releases/server/src/controllers/release.ts index fca8eb9bfa..e8e6a39a9b 100644 --- a/packages/core/content-releases/server/src/controllers/release.ts +++ b/packages/core/content-releases/server/src/controllers/release.ts @@ -120,9 +120,11 @@ const releaseController = { model: RELEASE_MODEL_UID, }); - ctx.body = { - data: await permissionsManager.sanitizeOutput(release), - }; + ctx.created({ + body: { + data: await permissionsManager.sanitizeOutput(release), + }, + }); }, async update(ctx: Koa.Context) { diff --git a/packages/core/core/src/core-api/controller/collection-type.ts b/packages/core/core/src/core-api/controller/collection-type.ts index 2877fa70db..4ddd52674d 100644 --- a/packages/core/core/src/core-api/controller/collection-type.ts +++ b/packages/core/core/src/core-api/controller/collection-type.ts @@ -66,6 +66,7 @@ const createCollectionTypeController = ({ const sanitizedEntity = await this.sanitizeOutput(entity, ctx); + ctx.status = 201; return this.transformResponse(sanitizedEntity); }, diff --git a/packages/core/review-workflows/server/src/controllers/workflows.ts b/packages/core/review-workflows/server/src/controllers/workflows.ts index 675f0f4eda..42100604e6 100644 --- a/packages/core/review-workflows/server/src/controllers/workflows.ts +++ b/packages/core/review-workflows/server/src/controllers/workflows.ts @@ -59,9 +59,9 @@ export default { }) .then(formatWorkflowToAdmin); - ctx.body = { + ctx.created({ data: await sanitizeOutput(createdWorkflow), - }; + }); }, /** diff --git a/packages/core/upload/server/src/controllers/admin-folder.ts b/packages/core/upload/server/src/controllers/admin-folder.ts index e9d956cb8a..fc328e56ba 100644 --- a/packages/core/upload/server/src/controllers/admin-folder.ts +++ b/packages/core/upload/server/src/controllers/admin-folder.ts @@ -94,9 +94,9 @@ export default { model: FOLDER_MODEL_UID, }); - ctx.body = { + ctx.created({ data: await permissionsManager.sanitizeOutput(folder), - }; + }); }, async update(ctx: Context) { diff --git a/packages/core/upload/server/src/controllers/admin-upload.ts b/packages/core/upload/server/src/controllers/admin-upload.ts index 30c6c7db29..0ed3c81395 100644 --- a/packages/core/upload/server/src/controllers/admin-upload.ts +++ b/packages/core/upload/server/src/controllers/admin-upload.ts @@ -92,6 +92,7 @@ export default { const signedFiles = await async.map(uploadedFiles, getService('file').signFileUrls); ctx.body = await pm.sanitizeOutput(signedFiles, { action: ACTIONS.read }); + ctx.status = 201; }, // TODO: split into multiple endpoints diff --git a/packages/core/upload/server/src/controllers/content-api.ts b/packages/core/upload/server/src/controllers/content-api.ts index b968e2b83c..a651da3905 100644 --- a/packages/core/upload/server/src/controllers/content-api.ts +++ b/packages/core/upload/server/src/controllers/content-api.ts @@ -138,6 +138,7 @@ export default ({ strapi }: { strapi: Core.Strapi }) => { }); ctx.body = await sanitizeOutput(uploadedFiles as any, ctx); + ctx.status = 201; }, // TODO: split into multiple endpoints diff --git a/tests/api/core/content-manager/api/basic-compo-repeatable.test.api.js b/tests/api/core/content-manager/api/basic-compo-repeatable.test.api.js index 1af33b128a..56e6e4f3e2 100644 --- a/tests/api/core/content-manager/api/basic-compo-repeatable.test.api.js +++ b/tests/api/core/content-manager/api/basic-compo-repeatable.test.api.js @@ -78,7 +78,7 @@ describe('CM API - Basic + compo', () => { body: product, }); - expect(res.statusCode).toBe(200); + expect(res.statusCode).toBe(201); expect(res.body.data).toMatchObject(product); expect(res.body.data.publishedAt).toBeDefined(); data.productsWithCompo.push(res.body.data); diff --git a/tests/api/core/content-manager/api/basic-compo.test.api.js b/tests/api/core/content-manager/api/basic-compo.test.api.js index eff9a576c9..3339fe6181 100644 --- a/tests/api/core/content-manager/api/basic-compo.test.api.js +++ b/tests/api/core/content-manager/api/basic-compo.test.api.js @@ -75,7 +75,7 @@ describe('CM API - Basic + compo', () => { body: product, }); - expect(res.statusCode).toBe(200); + expect(res.statusCode).toBe(201); expect(res.body.data).toMatchObject(product); expect(res.body.data.publishedAt).toBeDefined(); data.productsWithCompo.push(res.body.data); diff --git a/tests/api/core/content-manager/api/basic-dp-compo-repeatable.test.api.js b/tests/api/core/content-manager/api/basic-dp-compo-repeatable.test.api.js index 88d3e07f3d..dae1968fb0 100644 --- a/tests/api/core/content-manager/api/basic-dp-compo-repeatable.test.api.js +++ b/tests/api/core/content-manager/api/basic-dp-compo-repeatable.test.api.js @@ -81,7 +81,7 @@ describe('CM API - Basic + compo', () => { body: product, }); - expect(res.statusCode).toBe(200); + expect(res.statusCode).toBe(201); expect(res.body.data).toMatchObject(product); expect(res.body.data.publishedAt).toBeNull(); data.productsWithCompoAndDP.push(res.body.data); diff --git a/tests/api/core/content-manager/api/basic-dp-compo.test.api.js b/tests/api/core/content-manager/api/basic-dp-compo.test.api.js index defafbccd0..0db84f4fb3 100644 --- a/tests/api/core/content-manager/api/basic-dp-compo.test.api.js +++ b/tests/api/core/content-manager/api/basic-dp-compo.test.api.js @@ -78,7 +78,7 @@ describe('CM API - Basic + compo', () => { body: product, }); - expect(res.statusCode).toBe(200); + expect(res.statusCode).toBe(201); expect(res.body.data).toMatchObject(product); expect(res.body.data.publishedAt).toBeNull(); data.productsWithCompoAndDP.push(res.body.data); @@ -140,7 +140,7 @@ describe('CM API - Basic + compo', () => { body: product, }); - expect(res.statusCode).toBe(200); + expect(res.statusCode).toBe(201); expect(res.body.data).toMatchObject(product); data.productsWithCompoAndDP.push(res.body.data); }); @@ -160,7 +160,7 @@ describe('CM API - Basic + compo', () => { body: product, }); - expect(res.statusCode).toBe(200); + expect(res.statusCode).toBe(201); expect(res.body.data).toMatchObject(product); data.productsWithCompoAndDP.push(res.body.data); }); @@ -214,7 +214,7 @@ describe('CM API - Basic + compo', () => { body: product, }); - expect(res.statusCode).toBe(200); + expect(res.statusCode).toBe(201); expect(res.body.data).toMatchObject(product); data.productsWithCompoAndDP.push(res.body.data); }); diff --git a/tests/api/core/content-manager/api/basic-dp-dz.test.api.js b/tests/api/core/content-manager/api/basic-dp-dz.test.api.js index 44567a08d6..6d2165f1a7 100644 --- a/tests/api/core/content-manager/api/basic-dp-dz.test.api.js +++ b/tests/api/core/content-manager/api/basic-dp-dz.test.api.js @@ -81,7 +81,7 @@ describe('CM API - Basic + dz', () => { body: product, }); - expect(res.statusCode).toBe(200); + expect(res.statusCode).toBe(201); expect(res.body.data).toMatchObject(product); expect(res.body.data.publishedAt).toBeNull(); data.productsWithDzAndDP.push(res.body.data); @@ -181,7 +181,7 @@ describe('CM API - Basic + dz', () => { body: product, }); - expect(res.statusCode).toBe(200); + expect(res.statusCode).toBe(method === 'create' ? 201 : 200); expect(res.body.data).toMatchObject(product); data.productsWithDzAndDP.push(res.body.data); }); @@ -206,7 +206,7 @@ describe('CM API - Basic + dz', () => { body: product, }); - expect(res.statusCode).toBe(200); + expect(res.statusCode).toBe(method === 'create' ? 201 : 200); expect(res.body.data).toMatchObject(product); data.productsWithDzAndDP.push(res.body.data); }); @@ -270,7 +270,7 @@ describe('CM API - Basic + dz', () => { body: product, }); - expect(res.statusCode).toBe(200); + expect(res.statusCode).toBe(method === 'create' ? 201 : 200); expect(res.body.data).toMatchObject(product); data.productsWithDzAndDP.push(res.body.data); }); diff --git a/tests/api/core/content-manager/api/basic-dp.test.api.js b/tests/api/core/content-manager/api/basic-dp.test.api.js index 5ad3dcfd85..6f6cea379c 100644 --- a/tests/api/core/content-manager/api/basic-dp.test.api.js +++ b/tests/api/core/content-manager/api/basic-dp.test.api.js @@ -73,7 +73,7 @@ describe('CM API - Basic', () => { body: product, }); - expect(res.statusCode).toBe(200); + expect(res.statusCode).toBe(201); expect(res.body.data).toMatchObject(product); expect(res.body.data.publishedAt).toBeNull(); data.productsWithDP.push(res.body.data); @@ -91,7 +91,7 @@ describe('CM API - Basic', () => { body: product, }); - expect(res.statusCode).toBe(200); + expect(res.statusCode).toBe(201); expect(res.body.data).toMatchObject(_.omit(product, 'publishedAt')); expect(res.body.data.publishedAt).toBeNull(); data.productsWithDP.push(res.body.data); @@ -409,7 +409,7 @@ describe('CM API - Basic', () => { body: product, }); - expect(res.statusCode).toBe(200); + expect(res.statusCode).toBe(201); expect(res.body.data).toMatchObject(product); data.productsWithDP.push(res.body.data); }); @@ -424,7 +424,7 @@ describe('CM API - Basic', () => { body: product, }); - expect(res.statusCode).toBe(200); + expect(res.statusCode).toBe(201); expect(res.body.data).toMatchObject({ ...product, }); diff --git a/tests/api/core/content-manager/api/basic-dz.test.api.js b/tests/api/core/content-manager/api/basic-dz.test.api.js index 5b914091f3..27338ec268 100644 --- a/tests/api/core/content-manager/api/basic-dz.test.api.js +++ b/tests/api/core/content-manager/api/basic-dz.test.api.js @@ -79,7 +79,7 @@ describe('CM API - Basic + dz', () => { body: product, }); - expect(res.statusCode).toBe(200); + expect(res.statusCode).toBe(201); expect(res.body.data).toMatchObject(product); expect(res.body.data.publishedAt).toBe(null); data.productsWithDz.push(res.body.data); diff --git a/tests/api/core/content-manager/api/basic.test.api.js b/tests/api/core/content-manager/api/basic.test.api.js index b06ce85340..808bbabc5c 100644 --- a/tests/api/core/content-manager/api/basic.test.api.js +++ b/tests/api/core/content-manager/api/basic.test.api.js @@ -68,7 +68,7 @@ describe('CM API - Basic', () => { body: product, }); - expect(res.statusCode).toBe(200); + expect(res.statusCode).toBe(201); expect(res.body.data).toMatchObject(omit('hiddenAttribute', product)); expect(res.body.data).not.toHaveProperty('hiddenAttribute'); expect(res.body.data.publishedAt).toBeDefined(); diff --git a/tests/api/core/content-manager/components/repeatable-not-required-min-max.test.api.js b/tests/api/core/content-manager/components/repeatable-not-required-min-max.test.api.js index 5c7ab523a2..41f82bc4d2 100644 --- a/tests/api/core/content-manager/components/repeatable-not-required-min-max.test.api.js +++ b/tests/api/core/content-manager/components/repeatable-not-required-min-max.test.api.js @@ -66,7 +66,7 @@ describe('Non repeatable and Not required component', () => { }, }); - expect(res.statusCode).toBe(200); + expect(res.statusCode).toBe(201); expect(Array.isArray(res.body.data.field)).toBe(true); expect(res.body.data.field).toEqual( expect.arrayContaining([ @@ -112,7 +112,7 @@ describe('Non repeatable and Not required component', () => { }, }); - expect(res.statusCode).toBe(200); + expect(res.statusCode).toBe(201); }); test('Throws when sending too many items', async () => { @@ -152,7 +152,7 @@ describe('Non repeatable and Not required component', () => { }, }); - expect(res.statusCode).toBe(200); + expect(res.statusCode).toBe(201); expect(res.body.data.field).toEqual([]); }); }); diff --git a/tests/api/core/content-manager/components/repeatable-not-required.test.api.js b/tests/api/core/content-manager/components/repeatable-not-required.test.api.js index 2f5f9e77d2..d961f74a31 100644 --- a/tests/api/core/content-manager/components/repeatable-not-required.test.api.js +++ b/tests/api/core/content-manager/components/repeatable-not-required.test.api.js @@ -61,7 +61,7 @@ describe('Non repeatable and Not required component', () => { }, }); - expect(res.statusCode).toBe(200); + expect(res.statusCode).toBe(201); expect(Array.isArray(res.body.data.field)).toBe(true); expect(res.body.data.field).toEqual( expect.arrayContaining([ @@ -96,7 +96,7 @@ describe('Non repeatable and Not required component', () => { }, }); - expect(res.statusCode).toBe(200); + expect(res.statusCode).toBe(201); expect(res.body.data.field).toEqual([]); }); @@ -108,7 +108,7 @@ describe('Non repeatable and Not required component', () => { }, }); - expect(res.statusCode).toBe(200); + expect(res.statusCode).toBe(201); expect(res.body.data.field).toEqual([]); }); }); diff --git a/tests/api/core/content-manager/components/repeatable-required-min-max.test.api.js b/tests/api/core/content-manager/components/repeatable-required-min-max.test.api.js index dcebfdb450..96dce10fce 100644 --- a/tests/api/core/content-manager/components/repeatable-required-min-max.test.api.js +++ b/tests/api/core/content-manager/components/repeatable-required-min-max.test.api.js @@ -63,7 +63,7 @@ describe('Non repeatable and Not required component', () => { }, }); - expect(res.statusCode).toBe(200); + expect(res.statusCode).toBe(201); expect(Array.isArray(res.body.data.field)).toBe(true); expect(res.body.data.field).toEqual( expect.arrayContaining([ @@ -89,7 +89,7 @@ describe('Non repeatable and Not required component', () => { }, }); - expect(res.statusCode).toBe(200); + expect(res.statusCode).toBe(201); expect(Array.isArray(res.body.data.field)).toBe(true); expect(res.body.data.field).toEqual( expect.arrayContaining([ diff --git a/tests/api/core/content-manager/components/repeatable-required.test.api.js b/tests/api/core/content-manager/components/repeatable-required.test.api.js index e8ae26f3c0..4cf2dee5ed 100644 --- a/tests/api/core/content-manager/components/repeatable-required.test.api.js +++ b/tests/api/core/content-manager/components/repeatable-required.test.api.js @@ -61,7 +61,7 @@ describe('Non repeatable and Not required component', () => { }, }); - expect(res.statusCode).toBe(200); + expect(res.statusCode).toBe(201); expect(Array.isArray(res.body.data.field)).toBe(true); expect(res.body.data.field).toEqual( expect.arrayContaining([ @@ -87,7 +87,7 @@ describe('Non repeatable and Not required component', () => { }, }); - expect(res.statusCode).toBe(200); + expect(res.statusCode).toBe(201); expect(Array.isArray(res.body.data.field)).toBe(true); expect(res.body.data.field).toEqual( expect.arrayContaining([ @@ -122,7 +122,7 @@ describe('Non repeatable and Not required component', () => { }, }); - expect(res.statusCode).toBe(200); + expect(res.statusCode).toBe(201); expect(res.body.data.field).toEqual([]); }); diff --git a/tests/api/core/content-manager/components/single-not-required.test.api.js b/tests/api/core/content-manager/components/single-not-required.test.api.js index 10e8459b90..03974b23ae 100644 --- a/tests/api/core/content-manager/components/single-not-required.test.api.js +++ b/tests/api/core/content-manager/components/single-not-required.test.api.js @@ -60,7 +60,7 @@ describe('Non repeatable and Not required component', () => { }, }); - expect(res.statusCode).toBe(200); + expect(res.statusCode).toBe(201); expect(res.body.data.field).toEqual( expect.objectContaining({ id: expect.anything(), @@ -81,7 +81,7 @@ describe('Non repeatable and Not required component', () => { }, }); - expect(res.statusCode).toBe(200); + expect(res.statusCode).toBe(201); expect(res.body.data.field).toEqual( expect.objectContaining({ id: expect.anything(), @@ -113,7 +113,7 @@ describe('Non repeatable and Not required component', () => { }, }); - expect(res.statusCode).toBe(200); + expect(res.statusCode).toBe(201); expect(res.body.data.field).toBe(null); }); @@ -125,7 +125,7 @@ describe('Non repeatable and Not required component', () => { }, }); - expect(res.statusCode).toBe(200); + expect(res.statusCode).toBe(201); expect(res.body.data.field).toBe(null); }); }); diff --git a/tests/api/core/content-manager/components/single-required.test.api.js b/tests/api/core/content-manager/components/single-required.test.api.js index efb30ca99d..1591ae2a43 100644 --- a/tests/api/core/content-manager/components/single-required.test.api.js +++ b/tests/api/core/content-manager/components/single-required.test.api.js @@ -59,7 +59,7 @@ describe('Non repeatable and required component', () => { }, }); - expect(res.statusCode).toBe(200); + expect(res.statusCode).toBe(201); expect(res.body.data.field).toEqual( expect.objectContaining({ id: expect.anything(), @@ -80,7 +80,7 @@ describe('Non repeatable and required component', () => { }, }); - expect(res.statusCode).toBe(200); + expect(res.statusCode).toBe(201); expect(res.body.data.field).toEqual( expect.objectContaining({ id: expect.anything(), diff --git a/tests/api/core/content-manager/dynamiczones/simple.test.api.js b/tests/api/core/content-manager/dynamiczones/simple.test.api.js index a3619f2708..e8d3e035a3 100644 --- a/tests/api/core/content-manager/dynamiczones/simple.test.api.js +++ b/tests/api/core/content-manager/dynamiczones/simple.test.api.js @@ -118,7 +118,7 @@ describe('Not required dynamiczone', () => { }, }); - expect(res.statusCode).toBe(200); + expect(res.statusCode).toBe(201); expect(Array.isArray(res.body.data.field)).toBe(true); expect(res.body.data).toMatchObject({ field: [ @@ -151,7 +151,7 @@ describe('Not required dynamiczone', () => { }, }); - expect(res.statusCode).toBe(200); + expect(res.statusCode).toBe(201); expect(Array.isArray(res.body.data.field)).toBe(true); expect(res.body.data.field.length).toBe(0); }); @@ -257,7 +257,7 @@ describe('Not required dynamiczone', () => { test('Can empty non required dynamic zone', async () => { const createRes = await createEntry(); - expect(createRes.statusCode).toBe(200); + expect(createRes.statusCode).toBe(201); const entryId = createRes.body.data.documentId; const res = await rq({ @@ -279,7 +279,7 @@ describe('Not required dynamiczone', () => { test('Can add items to empty dynamic zone', async () => { const createRes = await createEmpty(); - expect(createRes.statusCode).toBe(200); + expect(createRes.statusCode).toBe(201); const entryId = createRes.body.data.documentId; const res = await rq({ @@ -315,7 +315,7 @@ describe('Not required dynamiczone', () => { test('Can remove items from dynamic zone', async () => { const createRes = await createEntry(); - expect(createRes.statusCode).toBe(200); + expect(createRes.statusCode).toBe(201); const entryId = createRes.body.data.documentId; const res = await rq({ @@ -359,7 +359,7 @@ describe('Not required dynamiczone', () => { test('Respects min items', async () => { const createRes = await createEntry(); - expect(createRes.statusCode).toBe(200); + expect(createRes.statusCode).toBe(201); const entryId = createRes.body.data.documentId; const res = await rq({ @@ -381,7 +381,7 @@ describe('Not required dynamiczone', () => { test('Respects max items', async () => { const createRes = await createEntry(); - expect(createRes.statusCode).toBe(200); + expect(createRes.statusCode).toBe(201); const entryId = createRes.body.data.documentId; const res = await rq({ diff --git a/tests/api/core/content-manager/dynamiczones/with-media.test.api.js b/tests/api/core/content-manager/dynamiczones/with-media.test.api.js index 75188752ec..f09bdf9184 100644 --- a/tests/api/core/content-manager/dynamiczones/with-media.test.api.js +++ b/tests/api/core/content-manager/dynamiczones/with-media.test.api.js @@ -96,7 +96,7 @@ describe('Not required dynamiczone', () => { test('The medias are correctly related to the components on creation', async () => { const imgRes = await uploadImg(); - expect(imgRes.statusCode).toBe(200); + expect(imgRes.statusCode).toBe(201); const mediaId = imgRes.body[0].id; const res = await rq({ @@ -119,7 +119,7 @@ describe('Not required dynamiczone', () => { }, }); - expect(res.statusCode).toBe(200); + expect(res.statusCode).toBe(201); expect(Array.isArray(res.body.data.field)).toBe(true); expect(res.body.data).toMatchObject({ field: [ @@ -148,7 +148,7 @@ describe('Not required dynamiczone', () => { test('The medias are correctly related to the components on edition', async () => { const imgRes = await uploadImg(); - expect(imgRes.statusCode).toBe(200); + expect(imgRes.statusCode).toBe(201); const mediaId = imgRes.body[0].id; const res = await rq({ @@ -171,12 +171,12 @@ describe('Not required dynamiczone', () => { }, }); - expect(res.statusCode).toBe(200); + expect(res.statusCode).toBe(201); expect(Array.isArray(res.body.data.field)).toBe(true); const newImgRes = await uploadImg(); - expect(newImgRes.statusCode).toBe(200); + expect(newImgRes.statusCode).toBe(201); const newMediaId = newImgRes.body[0].id; const updateRes = await rq({ method: 'PUT', @@ -225,7 +225,7 @@ describe('Not required dynamiczone', () => { test('The media are populated on the components', async () => { const imgRes = await uploadImg(); - expect(imgRes.statusCode).toBe(200); + expect(imgRes.statusCode).toBe(201); const mediaId = imgRes.body[0].id; const res = await rq({ @@ -248,7 +248,7 @@ describe('Not required dynamiczone', () => { }, }); - expect(res.statusCode).toBe(200); + expect(res.statusCode).toBe(201); const getRes = await rq({ method: 'GET', @@ -287,7 +287,7 @@ describe('Not required dynamiczone', () => { test('The medias are correctly related to the nested components on creation', async () => { const imgRes = await uploadImg(); - expect(imgRes.statusCode).toBe(200); + expect(imgRes.statusCode).toBe(201); const mediaId = imgRes.body[0].id; const res = await rq({ @@ -311,7 +311,7 @@ describe('Not required dynamiczone', () => { }, }); - expect(res.statusCode).toBe(200); + expect(res.statusCode).toBe(201); expect(Array.isArray(res.body.data.field)).toBe(true); expect(res.body.data).toMatchObject({ field: [ diff --git a/tests/api/core/content-manager/fields/biginteger.test.api.js b/tests/api/core/content-manager/fields/biginteger.test.api.js index c9964861ae..14343d3c32 100644 --- a/tests/api/core/content-manager/fields/biginteger.test.api.js +++ b/tests/api/core/content-manager/fields/biginteger.test.api.js @@ -43,7 +43,7 @@ describe('Test type biginteger', () => { } ); - expect(res.statusCode).toBe(200); + expect(res.statusCode).toBe(201); expect(res.body.data).toMatchObject({ field: inputValue, }); @@ -60,7 +60,7 @@ describe('Test type biginteger', () => { } ); - expect(res.statusCode).toBe(200); + expect(res.statusCode).toBe(201); expect(res.body.data).toMatchObject({ field: `${inputValue}`, }); diff --git a/tests/api/core/content-manager/fields/boolean.test.api.js b/tests/api/core/content-manager/fields/boolean.test.api.js index e15bdb5086..fff43bb821 100644 --- a/tests/api/core/content-manager/fields/boolean.test.api.js +++ b/tests/api/core/content-manager/fields/boolean.test.api.js @@ -39,7 +39,7 @@ describe('Test type boolean', () => { }, }); - expect(res.statusCode).toBe(200); + expect(res.statusCode).toBe(201); expect(res.body.data).toMatchObject({ field: true, }); @@ -58,7 +58,7 @@ describe('Test type boolean', () => { body: { field: 1 }, }); - expect(res.statusCode).toBe(200); + expect(res.statusCode).toBe(201); expect(res.body.data).toMatchObject({ field: true, }); @@ -67,7 +67,7 @@ describe('Test type boolean', () => { body: { field: 0 }, }); - expect(res.statusCode).toBe(200); + expect(res.statusCode).toBe(201); expect(res.body.data).toMatchObject({ field: false, }); diff --git a/tests/api/core/content-manager/fields/decimal.test.api.js b/tests/api/core/content-manager/fields/decimal.test.api.js index a9f391605f..1de17bbccb 100644 --- a/tests/api/core/content-manager/fields/decimal.test.api.js +++ b/tests/api/core/content-manager/fields/decimal.test.api.js @@ -40,7 +40,7 @@ describe('Test type decimal', () => { }, }); - expect(res.statusCode).toBe(200); + expect(res.statusCode).toBe(201); expect(res.body.data).toMatchObject({ field: inputValue, }); @@ -54,7 +54,7 @@ describe('Test type decimal', () => { }, }); - expect(res.statusCode).toBe(200); + expect(res.statusCode).toBe(201); expect(res.body.data).toMatchObject({ field: 1821.0, }); diff --git a/tests/api/core/content-manager/fields/email.test.api.js b/tests/api/core/content-manager/fields/email.test.api.js index 17ee506dfa..2be4fe3696 100644 --- a/tests/api/core/content-manager/fields/email.test.api.js +++ b/tests/api/core/content-manager/fields/email.test.api.js @@ -39,7 +39,7 @@ describe('Test type email', () => { }, }); - expect(res.statusCode).toBe(200); + expect(res.statusCode).toBe(201); expect(res.body.data).toMatchObject({ field: 'validemail@test.fr', }); @@ -62,7 +62,7 @@ describe('Test type email', () => { }, }); - expect(res.statusCode).toBe(200); + expect(res.statusCode).toBe(201); expect(res.body.data).toMatchObject({ field: 'test@email.fr', }); diff --git a/tests/api/core/content-manager/fields/enumeration.test.api.js b/tests/api/core/content-manager/fields/enumeration.test.api.js index e86b35ed18..12abb2d1c1 100644 --- a/tests/api/core/content-manager/fields/enumeration.test.api.js +++ b/tests/api/core/content-manager/fields/enumeration.test.api.js @@ -43,7 +43,7 @@ describe('Test type enumeration', () => { } ); - expect(res.statusCode).toBe(200); // should return 201 + expect(res.statusCode).toBe(201); expect(res.body.data).toMatchObject({ field: 'one', }); @@ -98,7 +98,7 @@ describe('Test type enumeration', () => { } ); - expect(res.statusCode).toBe(200); // should return 201 + expect(res.statusCode).toBe(201); expect(res.body.data).toMatchObject({ field: null, }); diff --git a/tests/api/core/content-manager/fields/float.test.api.js b/tests/api/core/content-manager/fields/float.test.api.js index c56fc75c54..d726f41e77 100644 --- a/tests/api/core/content-manager/fields/float.test.api.js +++ b/tests/api/core/content-manager/fields/float.test.api.js @@ -40,7 +40,7 @@ describe('Test type float', () => { }, }); - expect(res.statusCode).toBe(200); + expect(res.statusCode).toBe(201); expect(res.body.data).toMatchObject({ field: inputValue, }); @@ -54,7 +54,7 @@ describe('Test type float', () => { }, }); - expect(res.statusCode).toBe(200); + expect(res.statusCode).toBe(201); expect(res.body.data).toMatchObject({ field: 1821.0, }); diff --git a/tests/api/core/content-manager/fields/integer.test.api.js b/tests/api/core/content-manager/fields/integer.test.api.js index a81ac779e2..e09d1633c5 100644 --- a/tests/api/core/content-manager/fields/integer.test.api.js +++ b/tests/api/core/content-manager/fields/integer.test.api.js @@ -39,7 +39,7 @@ describe('Test type integer', () => { }, }); - expect(res.statusCode).toBe(200); + expect(res.statusCode).toBe(201); expect(res.body.data).toMatchObject({ field: 123456, }); @@ -53,7 +53,7 @@ describe('Test type integer', () => { }, }); - expect(res.statusCode).toBe(200); + expect(res.statusCode).toBe(201); expect(res.body.data).toMatchObject({ field: 123456, }); diff --git a/tests/api/core/content-manager/fields/json.test.api.js b/tests/api/core/content-manager/fields/json.test.api.js index 50de7f9cb0..7e39ae0899 100644 --- a/tests/api/core/content-manager/fields/json.test.api.js +++ b/tests/api/core/content-manager/fields/json.test.api.js @@ -42,7 +42,7 @@ describe('Test type json', () => { }, }); - expect(res.statusCode).toBe(200); + expect(res.statusCode).toBe(201); expect(res.body.data).toMatchObject({ field: inputValue, }); @@ -63,7 +63,7 @@ describe('Test type json', () => { }, }); - expect(res.statusCode).toBe(200); + expect(res.statusCode).toBe(201); expect(res.body.data).toMatchObject({ field: inputValue, }); diff --git a/tests/api/core/content-manager/fields/password.test.api.js b/tests/api/core/content-manager/fields/password.test.api.js index 43cd38543c..bd7542de35 100644 --- a/tests/api/core/content-manager/fields/password.test.api.js +++ b/tests/api/core/content-manager/fields/password.test.api.js @@ -39,7 +39,7 @@ describe('Test type password', () => { }, }); - expect(res.statusCode).toBe(200); + expect(res.statusCode).toBe(201); expect(res.body.data.field).toBeUndefined(); }); @@ -52,7 +52,7 @@ describe('Test type password', () => { }, }); - expect(res.statusCode).toBe(200); + expect(res.statusCode).toBe(201); expect(res.body.data.field).toBeUndefined(); }); diff --git a/tests/api/core/content-manager/fields/richtext.test.api.js b/tests/api/core/content-manager/fields/richtext.test.api.js index 0bd4cf1283..9b86bde054 100644 --- a/tests/api/core/content-manager/fields/richtext.test.api.js +++ b/tests/api/core/content-manager/fields/richtext.test.api.js @@ -39,7 +39,7 @@ describe('Test type richtext', () => { }, }); - expect(res.statusCode).toBe(200); + expect(res.statusCode).toBe(201); expect(res.body.data).toMatchObject({ field: 'Some\ntext', }); diff --git a/tests/api/core/content-manager/fields/string.test.api.js b/tests/api/core/content-manager/fields/string.test.api.js index 608f34ad27..62eff5f95e 100644 --- a/tests/api/core/content-manager/fields/string.test.api.js +++ b/tests/api/core/content-manager/fields/string.test.api.js @@ -39,7 +39,7 @@ describe('Test type string', () => { }, }); - expect(res.statusCode).toBe(200); + expect(res.statusCode).toBe(201); expect(res.body.data).toMatchObject({ field: 'Some string', }); diff --git a/tests/api/core/content-manager/fields/text.test.api.js b/tests/api/core/content-manager/fields/text.test.api.js index c8d294577b..4ad43b6846 100644 --- a/tests/api/core/content-manager/fields/text.test.api.js +++ b/tests/api/core/content-manager/fields/text.test.api.js @@ -39,7 +39,7 @@ describe('Test type text', () => { }, }); - expect(res.statusCode).toBe(200); + expect(res.statusCode).toBe(201); expect(res.body.data).toMatchObject({ field: 'Some\ntext', }); diff --git a/tests/api/core/content-manager/fields/uid.test.api.js b/tests/api/core/content-manager/fields/uid.test.api.js index 991752741e..fd7a9b63bc 100644 --- a/tests/api/core/content-manager/fields/uid.test.api.js +++ b/tests/api/core/content-manager/fields/uid.test.api.js @@ -41,7 +41,7 @@ describe('Test type UID', () => { }, }); - expect(res.statusCode).toBe(200); + expect(res.statusCode).toBe(201); expect(res.body.data).toMatchObject({ slug: 'valid-uid', }); @@ -76,7 +76,7 @@ describe('Test type UID', () => { }, }); - expect(res.statusCode).toBe(200); + expect(res.statusCode).toBe(201); expect(res.body.data).toMatchObject({ slug: null, }); @@ -140,7 +140,7 @@ describe('Test type UID', () => { }, }); - expect(res.statusCode).toBe(200); + expect(res.statusCode).toBe(201); expect(res.body.data).toMatchObject({ slug: value, }); @@ -159,7 +159,7 @@ describe('Test type UID', () => { slug: value, }, }); - expect(newLocaleResult.statusCode).toBe(200); + expect(newLocaleResult.statusCode).toBe(201); }); }); @@ -200,7 +200,7 @@ describe('Test type UID', () => { } ); - expect(res.statusCode).toBe(200); + expect(res.statusCode).toBe(201); expect(res.body.data).toMatchObject({ slug: 'valid-uid', }); diff --git a/tests/api/core/review-workflows/review-workflows-content-types.test.api.ts b/tests/api/core/review-workflows/review-workflows-content-types.test.api.ts index e9caea2a51..d3f2d90a19 100644 --- a/tests/api/core/review-workflows/review-workflows-content-types.test.api.ts +++ b/tests/api/core/review-workflows/review-workflows-content-types.test.api.ts @@ -133,7 +133,7 @@ describeOnCondition(edition === 'EE')('Review workflows - Content Types', () => test('It should create a workflow and assign a content type', async () => { const res = await createWorkflow({ name: 'test-workflow', contentTypes: [productUID] }); - expect(res.status).toBe(200); + expect(res.status).toBe(201); expect(res.body.data).toMatchObject({ name: expect.any(String), contentTypes: [productUID], @@ -158,7 +158,7 @@ describeOnCondition(edition === 'EE')('Review workflows - Content Types', () => stages: [{ name: 'Review' }], }); - expect(res.status).toBe(200); + expect(res.status).toBe(201); expect(res.body.data).toMatchObject({ contentTypes: [productUID] }); workflow2 = res.body.data; }); diff --git a/tests/api/core/review-workflows/review-workflows.test.api.ts b/tests/api/core/review-workflows/review-workflows.test.api.ts index 30fe099f93..b8dcbe76a7 100644 --- a/tests/api/core/review-workflows/review-workflows.test.api.ts +++ b/tests/api/core/review-workflows/review-workflows.test.api.ts @@ -224,7 +224,7 @@ describeOnCondition(edition === 'EE')('Review workflows', () => { }); if (hasRW) { - expect(res.status).toBe(200); + expect(res.status).toBe(201); expect(res.body.data).toMatchObject({ name: 'createdWorkflow', stages: [ diff --git a/tests/api/core/strapi/api/basic-compo-repeatable.test.api.js b/tests/api/core/strapi/api/basic-compo-repeatable.test.api.js index 2c7f8edeab..8976f588f2 100644 --- a/tests/api/core/strapi/api/basic-compo-repeatable.test.api.js +++ b/tests/api/core/strapi/api/basic-compo-repeatable.test.api.js @@ -84,7 +84,7 @@ describe('Core API - Basic + compo', () => { }, }); - expect(statusCode).toBe(200); + expect(statusCode).toBe(201); expect(body.data).toMatchObject({ documentId: expect.anything(), diff --git a/tests/api/core/strapi/api/basic-compo.test.api.js b/tests/api/core/strapi/api/basic-compo.test.api.js index a98a60b804..fc45e17bae 100644 --- a/tests/api/core/strapi/api/basic-compo.test.api.js +++ b/tests/api/core/strapi/api/basic-compo.test.api.js @@ -85,7 +85,7 @@ describe('Core API - Basic + compo', () => { }, }); - expect(statusCode).toBe(200); + expect(statusCode).toBe(201); expect(body.data).toMatchObject({ documentId: expect.anything(), diff --git a/tests/api/core/strapi/api/basic-dp-compo-repeatable.test.api.js b/tests/api/core/strapi/api/basic-dp-compo-repeatable.test.api.js index 43302f124a..e593f8bd8c 100644 --- a/tests/api/core/strapi/api/basic-dp-compo-repeatable.test.api.js +++ b/tests/api/core/strapi/api/basic-dp-compo-repeatable.test.api.js @@ -85,7 +85,7 @@ describe('Core API - Basic + compo ', () => { }, }); - expect(statusCode).toBe(200); + expect(statusCode).toBe(201); expect(body.data).toMatchObject({ documentId: expect.anything(), diff --git a/tests/api/core/strapi/api/basic-dp-compo.test.api.js b/tests/api/core/strapi/api/basic-dp-compo.test.api.js index 124abf9c81..ea0e86d857 100644 --- a/tests/api/core/strapi/api/basic-dp-compo.test.api.js +++ b/tests/api/core/strapi/api/basic-dp-compo.test.api.js @@ -82,7 +82,7 @@ describe('Core API - Basic + compo', () => { }, }); - expect(statusCode).toBe(200); + expect(statusCode).toBe(201); expect(body.data).toMatchObject({ documentId: expect.anything(), diff --git a/tests/api/core/strapi/api/basic-dp.test.api.js b/tests/api/core/strapi/api/basic-dp.test.api.js index 92b701f34f..cac83c2b9e 100644 --- a/tests/api/core/strapi/api/basic-dp.test.api.js +++ b/tests/api/core/strapi/api/basic-dp.test.api.js @@ -75,7 +75,7 @@ describe('Core API - Basic', () => { }, }); - expect(statusCode).toBe(200); + expect(statusCode).toBe(201); expect(body.data).toMatchObject({ id: expect.anything(), ...product, @@ -101,7 +101,7 @@ describe('Core API - Basic', () => { }, }); - expect(statusCode).toBe(200); + expect(statusCode).toBe(201); expect(body.data).toMatchObject({ documentId: expect.anything(), ..._.omit(product, 'publishedAt'), diff --git a/tests/api/core/strapi/api/basic-dz.test.api.js b/tests/api/core/strapi/api/basic-dz.test.api.js index 7cc2779872..b36bdc76a9 100644 --- a/tests/api/core/strapi/api/basic-dz.test.api.js +++ b/tests/api/core/strapi/api/basic-dz.test.api.js @@ -84,7 +84,7 @@ describe('Core API - Basic + dz', () => { }, }); - expect(statusCode).toBe(200); + expect(statusCode).toBe(201); expect(body.data).toMatchObject({ documentId: expect.anything(), diff --git a/tests/api/core/strapi/api/basic.test.api.js b/tests/api/core/strapi/api/basic.test.api.js index 0af83fffd7..54d16655c5 100644 --- a/tests/api/core/strapi/api/basic.test.api.js +++ b/tests/api/core/strapi/api/basic.test.api.js @@ -70,7 +70,7 @@ describe('Core API - Basic', () => { const { statusCode, body } = res; - expect(statusCode).toBe(200); + expect(statusCode).toBe(201); expect(body).toMatchObject({ data: { id: expect.anything(), diff --git a/tests/api/core/strapi/api/validate-body.test.api.js b/tests/api/core/strapi/api/validate-body.test.api.js index 269899846a..9c925251b8 100644 --- a/tests/api/core/strapi/api/validate-body.test.api.js +++ b/tests/api/core/strapi/api/validate-body.test.api.js @@ -56,7 +56,7 @@ describe('Validate Body', () => { const response = await rq.post('/products', { body: createPayload }); - expect(response.statusCode).toBe(200); + expect(response.statusCode).toBe(201); const { documentId, ...attributes } = response.body.data; diff --git a/tests/api/core/strapi/components/repeatable-not-required-min-max.test.api.js b/tests/api/core/strapi/components/repeatable-not-required-min-max.test.api.js index 367e8de129..5bbc80c307 100644 --- a/tests/api/core/strapi/components/repeatable-not-required-min-max.test.api.js +++ b/tests/api/core/strapi/components/repeatable-not-required-min-max.test.api.js @@ -69,7 +69,7 @@ describe('Non repeatable and Not required component', () => { }, }); - expect(res.statusCode).toBe(200); + expect(res.statusCode).toBe(201); expect(Array.isArray(res.body.data.field)).toBe(true); expect(res.body.data.field).toEqual( expect.arrayContaining([ @@ -121,7 +121,7 @@ describe('Non repeatable and Not required component', () => { }, }); - expect(res.statusCode).toBe(200); + expect(res.statusCode).toBe(201); }); test('Throws when sending too many items', async () => { @@ -165,7 +165,7 @@ describe('Non repeatable and Not required component', () => { }, }); - expect(res.statusCode).toBe(200); + expect(res.statusCode).toBe(201); expect(res.body.data.field).toEqual([]); }); }); diff --git a/tests/api/core/strapi/components/repeatable-not-required.test.api.js b/tests/api/core/strapi/components/repeatable-not-required.test.api.js index fec2588b30..2876597ffa 100644 --- a/tests/api/core/strapi/components/repeatable-not-required.test.api.js +++ b/tests/api/core/strapi/components/repeatable-not-required.test.api.js @@ -64,7 +64,7 @@ describe('Non repeatable and Not required component', () => { }, }); - expect(res.statusCode).toBe(200); + expect(res.statusCode).toBe(201); expect(Array.isArray(res.body.data.field)).toBe(true); expect(res.body.data.field).toEqual( expect.arrayContaining([ @@ -103,7 +103,7 @@ describe('Non repeatable and Not required component', () => { }, }); - expect(res.statusCode).toBe(200); + expect(res.statusCode).toBe(201); expect(res.body.data.field).toEqual([]); }); @@ -117,7 +117,7 @@ describe('Non repeatable and Not required component', () => { }, }); - expect(res.statusCode).toBe(200); + expect(res.statusCode).toBe(201); expect(res.body.data.field).toEqual([]); }); }); diff --git a/tests/api/core/strapi/components/repeatable-required-min-max.test.api.js b/tests/api/core/strapi/components/repeatable-required-min-max.test.api.js index 8ca27c1584..3b25446061 100644 --- a/tests/api/core/strapi/components/repeatable-required-min-max.test.api.js +++ b/tests/api/core/strapi/components/repeatable-required-min-max.test.api.js @@ -66,7 +66,7 @@ describe('Non repeatable and Not required component', () => { }, }); - expect(res.statusCode).toBe(200); + expect(res.statusCode).toBe(201); expect(Array.isArray(res.body.data.field)).toBe(true); expect(res.body.data.field).toEqual( expect.arrayContaining([ @@ -94,7 +94,7 @@ describe('Non repeatable and Not required component', () => { }, }); - expect(res.statusCode).toBe(200); + expect(res.statusCode).toBe(201); expect(Array.isArray(res.body.data.field)).toBe(true); expect(res.body.data.field).toEqual( expect.arrayContaining([ diff --git a/tests/api/core/strapi/components/repeatable-required.test.api.js b/tests/api/core/strapi/components/repeatable-required.test.api.js index eb53d02084..a2ceb7ed35 100644 --- a/tests/api/core/strapi/components/repeatable-required.test.api.js +++ b/tests/api/core/strapi/components/repeatable-required.test.api.js @@ -64,7 +64,7 @@ describe('Non repeatable and Not required component', () => { }, }); - expect(res.statusCode).toBe(200); + expect(res.statusCode).toBe(201); expect(res.body.data.field).toEqual( expect.arrayContaining([ expect.objectContaining({ @@ -91,7 +91,7 @@ describe('Non repeatable and Not required component', () => { }, }); - expect(res.statusCode).toBe(200); + expect(res.statusCode).toBe(201); expect(res.body.data.field).toEqual( expect.arrayContaining([ expect.objectContaining({ @@ -129,7 +129,7 @@ describe('Non repeatable and Not required component', () => { }, }); - expect(res.statusCode).toBe(200); + expect(res.statusCode).toBe(201); expect(res.body.data.field).toEqual([]); }); diff --git a/tests/api/core/strapi/components/single-not-required.test.api.js b/tests/api/core/strapi/components/single-not-required.test.api.js index 318862aab4..7665978665 100644 --- a/tests/api/core/strapi/components/single-not-required.test.api.js +++ b/tests/api/core/strapi/components/single-not-required.test.api.js @@ -62,7 +62,7 @@ describe('Non repeatable and Not required component', () => { }, }); - expect(res.statusCode).toBe(200); + expect(res.statusCode).toBe(201); expect(res.body.data.field).toEqual( expect.objectContaining({ id: expect.anything(), @@ -85,7 +85,7 @@ describe('Non repeatable and Not required component', () => { }, }); - expect(res.statusCode).toBe(200); + expect(res.statusCode).toBe(201); expect(res.body.data.field).toEqual( expect.objectContaining({ id: expect.anything(), @@ -121,7 +121,7 @@ describe('Non repeatable and Not required component', () => { }, }); - expect(res.statusCode).toBe(200); + expect(res.statusCode).toBe(201); expect(res.body.data.field).toBe(null); }); @@ -135,7 +135,7 @@ describe('Non repeatable and Not required component', () => { }, }); - expect(res.statusCode).toBe(200); + expect(res.statusCode).toBe(201); expect(res.body.data.field).toBe(null); }); }); diff --git a/tests/api/core/strapi/components/single-required.test.api.js b/tests/api/core/strapi/components/single-required.test.api.js index 6672e807bb..3a25ab36c2 100644 --- a/tests/api/core/strapi/components/single-required.test.api.js +++ b/tests/api/core/strapi/components/single-required.test.api.js @@ -62,7 +62,7 @@ describe('Non repeatable and required component', () => { }, }); - expect(statusCode).toBe(200); + expect(statusCode).toBe(201); expect(body.data.field).toEqual( expect.objectContaining({ id: expect.anything(), @@ -85,7 +85,7 @@ describe('Non repeatable and required component', () => { }, }); - expect(statusCode).toBe(200); + expect(statusCode).toBe(201); expect(body.data.field).toEqual( expect.objectContaining({ id: expect.anything(), diff --git a/tests/api/core/strapi/dynamiczones/simple.test.api.js b/tests/api/core/strapi/dynamiczones/simple.test.api.js index 7ae48511a1..549e6d8334 100644 --- a/tests/api/core/strapi/dynamiczones/simple.test.api.js +++ b/tests/api/core/strapi/dynamiczones/simple.test.api.js @@ -122,7 +122,7 @@ describe('Not required dynamiczone', () => { }, }); - expect(res.statusCode).toBe(200); + expect(res.statusCode).toBe(201); expect(Array.isArray(res.body.data.field)).toBe(true); expect(res.body.data).toMatchObject({ field: [ @@ -157,7 +157,7 @@ describe('Not required dynamiczone', () => { }, }); - expect(res.statusCode).toBe(200); + expect(res.statusCode).toBe(201); expect(Array.isArray(res.body.data.field)).toBe(true); expect(res.body.data.field.length).toBe(0); }); @@ -266,7 +266,7 @@ describe('Not required dynamiczone', () => { test('Can empty non required dynamic zone', async () => { const createRes = await createEntry(); - expect(createRes.statusCode).toBe(200); + expect(createRes.statusCode).toBe(201); const documentId = createRes.body.data.documentId; const res = await rq({ @@ -290,7 +290,7 @@ describe('Not required dynamiczone', () => { test('Can add items to empty dynamic zone', async () => { const createRes = await createEmpty(); - expect(createRes.statusCode).toBe(200); + expect(createRes.statusCode).toBe(201); const documentId = createRes.body.data.documentId; const res = await rq({ @@ -328,7 +328,7 @@ describe('Not required dynamiczone', () => { test('Can remove items from dynamic zone', async () => { const createRes = await createEntry(); - expect(createRes.statusCode).toBe(200); + expect(createRes.statusCode).toBe(201); const documentId = createRes.body.data.documentId; const res = await rq({ @@ -374,7 +374,7 @@ describe('Not required dynamiczone', () => { test('Respects min items', async () => { const createRes = await createEntry(); - expect(createRes.statusCode).toBe(200); + expect(createRes.statusCode).toBe(201); const documentId = createRes.body.data.documentId; const res = await rq({ @@ -398,7 +398,7 @@ describe('Not required dynamiczone', () => { test('Respects max items', async () => { const createRes = await createEntry(); - expect(createRes.statusCode).toBe(200); + expect(createRes.statusCode).toBe(201); const documentId = createRes.body.data.documentId; const res = await rq({ diff --git a/tests/api/core/strapi/dynamiczones/with-media.test.api.js b/tests/api/core/strapi/dynamiczones/with-media.test.api.js index e890a94d9d..57388033bc 100644 --- a/tests/api/core/strapi/dynamiczones/with-media.test.api.js +++ b/tests/api/core/strapi/dynamiczones/with-media.test.api.js @@ -94,7 +94,7 @@ describe('Not required dynamiczone', () => { test('The medias are correctly related to the components on creation', async () => { const imgRes = await uploadImg(); - expect(imgRes.statusCode).toBe(200); + expect(imgRes.statusCode).toBe(201); const mediaId = imgRes.body[0].id; const res = await rq({ @@ -119,7 +119,7 @@ describe('Not required dynamiczone', () => { }, }); - expect(res.statusCode).toBe(200); + expect(res.statusCode).toBe(201); expect(Array.isArray(res.body.data.field)).toBe(true); expect(res.body.data).toMatchObject({ field: [ @@ -148,7 +148,7 @@ describe('Not required dynamiczone', () => { test('The medias are correctly related to the components on edition', async () => { const imgRes = await uploadImg(); - expect(imgRes.statusCode).toBe(200); + expect(imgRes.statusCode).toBe(201); const mediaId = imgRes.body[0].id; const res = await rq({ @@ -173,12 +173,12 @@ describe('Not required dynamiczone', () => { }, }); - expect(res.statusCode).toBe(200); + expect(res.statusCode).toBe(201); expect(Array.isArray(res.body.data.field)).toBe(true); const newImgRes = await uploadImg(); - expect(newImgRes.statusCode).toBe(200); + expect(newImgRes.statusCode).toBe(201); const newMediaId = newImgRes.body[0].id; const updateRes = await rq({ method: 'PUT', @@ -229,7 +229,7 @@ describe('Not required dynamiczone', () => { test('The media are populated on the components', async () => { const imgRes = await uploadImg(); - expect(imgRes.statusCode).toBe(200); + expect(imgRes.statusCode).toBe(201); const mediaId = imgRes.body[0].id; const res = await rq({ @@ -254,7 +254,7 @@ describe('Not required dynamiczone', () => { }, }); - expect(res.statusCode).toBe(200); + expect(res.statusCode).toBe(201); const getRes = await rq({ method: 'GET', @@ -293,7 +293,7 @@ describe('Not required dynamiczone', () => { test('The medias are correctly related to the nested components on creation', async () => { const imgRes = await uploadImg(); - expect(imgRes.statusCode).toBe(200); + expect(imgRes.statusCode).toBe(201); const mediaId = imgRes.body[0].id; const res = await rq({ @@ -319,7 +319,7 @@ describe('Not required dynamiczone', () => { }, }); - expect(res.statusCode).toBe(200); + expect(res.statusCode).toBe(201); expect(Array.isArray(res.body.data.field)).toBe(true); expect(res.body.data).toMatchObject({ field: [ diff --git a/tests/api/core/strapi/migrations/migration-draft-publish.test.api.js b/tests/api/core/strapi/migrations/migration-draft-publish.test.api.js index 6c2fe4350b..8000774428 100644 --- a/tests/api/core/strapi/migrations/migration-draft-publish.test.api.js +++ b/tests/api/core/strapi/migrations/migration-draft-publish.test.api.js @@ -170,7 +170,7 @@ describe('Migration - draft and publish', () => { body: dogToCreate, }); - expect(res.statusCode).toBe(200); + expect(res.statusCode).toBe(201); expect(res.body.data).toMatchObject(dogToCreate); data.dogs.push(res.body); diff --git a/tests/api/core/upload/admin/file-folder.test.api.js b/tests/api/core/upload/admin/file-folder.test.api.js index 15635b3225..354aa0b23d 100644 --- a/tests/api/core/upload/admin/file-folder.test.api.js +++ b/tests/api/core/upload/admin/file-folder.test.api.js @@ -55,7 +55,7 @@ describe('File', () => { }, }); - expect(res.statusCode).toBe(200); + expect(res.statusCode).toBe(201); expect(Array.isArray(res.body)).toBe(true); expect(res.body.length).toBe(1); @@ -94,7 +94,7 @@ describe('File', () => { }, }); - expect(res.statusCode).toBe(200); + expect(res.statusCode).toBe(201); expect(Array.isArray(res.body)).toBe(true); expect(res.body.length).toBe(1); diff --git a/tests/api/core/upload/admin/file-image.test.api.js b/tests/api/core/upload/admin/file-image.test.api.js index 8c7de413bf..594a588213 100644 --- a/tests/api/core/upload/admin/file-image.test.api.js +++ b/tests/api/core/upload/admin/file-image.test.api.js @@ -46,7 +46,7 @@ describe('Upload', () => { }, }); - expect(res.statusCode).toBe(200); + expect(res.statusCode).toBe(201); expect(Array.isArray(res.body)).toBe(true); expect(res.body.length).toBe(1); expect(res.body[0]).toEqual( @@ -74,7 +74,7 @@ describe('Upload', () => { }, }); - expect(res.statusCode).toBe(200); + expect(res.statusCode).toBe(201); expect(Array.isArray(res.body)).toBe(true); expect(res.body.length).toBe(1); expect(res.body[0]).toEqual( diff --git a/tests/api/core/upload/admin/file-size-limit.test.api.js b/tests/api/core/upload/admin/file-size-limit.test.api.js index f52a23bfff..3fd870bfad 100644 --- a/tests/api/core/upload/admin/file-size-limit.test.api.js +++ b/tests/api/core/upload/admin/file-size-limit.test.api.js @@ -57,7 +57,7 @@ describe('Upload', () => { formData: { files: fs.createReadStream(path.join(__dirname, '../utils/rec.jpg')) }, }); - expect(res.statusCode).toBe(200); + expect(res.statusCode).toBe(201); }); }); }); diff --git a/tests/api/core/upload/admin/file.test.api.js b/tests/api/core/upload/admin/file.test.api.js index 5e1aaff92c..3cae41ebc7 100644 --- a/tests/api/core/upload/admin/file.test.api.js +++ b/tests/api/core/upload/admin/file.test.api.js @@ -48,7 +48,7 @@ describe('Upload', () => { formData: { files: fs.createReadStream(path.join(__dirname, '../utils/rec.jpg')) }, }); - expect(res.statusCode).toBe(200); + expect(res.statusCode).toBe(201); }); }); diff --git a/tests/api/core/upload/admin/folder.test.api.js b/tests/api/core/upload/admin/folder.test.api.js index ce65bf4ba3..e03cf436a5 100644 --- a/tests/api/core/upload/admin/folder.test.api.js +++ b/tests/api/core/upload/admin/folder.test.api.js @@ -71,7 +71,7 @@ describe.skip('Folder', () => { }, }); - expect(res.status).toBe(200); + expect(res.status).toBe(201); expect(res.body.data).toMatchObject({ id: expect.anything(), name: 'folder 1', diff --git a/tests/api/core/upload/admin/image-dimension.test.api.js b/tests/api/core/upload/admin/image-dimension.test.api.js index 044fdfc4c0..261b8ae21a 100644 --- a/tests/api/core/upload/admin/image-dimension.test.api.js +++ b/tests/api/core/upload/admin/image-dimension.test.api.js @@ -31,7 +31,7 @@ describe('Dimensions are populated when uploading an image', () => { formData: { files: fs.createReadStream(path.join(__dirname, `../utils/strapi${ext}`)) }, }); - expect(res.statusCode).toBe(200); + expect(res.statusCode).toBe(201); expect(res.body[0]).toMatchObject({ width: 256, height: 256, diff --git a/tests/api/core/upload/content-api/upload-automatic-folder.test.api.js b/tests/api/core/upload/content-api/upload-automatic-folder.test.api.js index 2a1cff30a7..d818124114 100644 --- a/tests/api/core/upload/content-api/upload-automatic-folder.test.api.js +++ b/tests/api/core/upload/content-api/upload-automatic-folder.test.api.js @@ -67,7 +67,7 @@ describe('Uploads folder', () => { }, }); - expect(res.statusCode).toBe(200); + expect(res.statusCode).toBe(201); const { body: file } = await rqAdmin({ method: 'GET', @@ -102,7 +102,7 @@ describe('Uploads folder', () => { }, }); - expect(res.statusCode).toBe(200); + expect(res.statusCode).toBe(201); const { body: file } = await rqAdmin({ method: 'GET', @@ -146,7 +146,7 @@ describe('Uploads folder', () => { }, }); - expect(res.statusCode).toBe(200); + expect(res.statusCode).toBe(201); const { body: file } = await rqAdmin({ method: 'GET', @@ -308,7 +308,7 @@ describe('Uploads folder', () => { }, }); - expect(res.statusCode).toBe(200); + expect(res.statusCode).toBe(201); const { body: { results: files }, @@ -370,7 +370,7 @@ describe('Uploads folder', () => { }, }); - expect(res.statusCode).toBe(200); + expect(res.statusCode).toBe(201); const { body: { results: files }, @@ -425,7 +425,7 @@ describe('Uploads folder', () => { }, }); - expect(res.statusCode).toBe(200); + expect(res.statusCode).toBe(201); const { body: { results: files }, @@ -486,7 +486,7 @@ describe('Uploads folder', () => { }, }); - expect(res.statusCode).toBe(200); + expect(res.statusCode).toBe(201); const { body: { results: files }, diff --git a/tests/api/core/upload/content-api/upload.test.api.js b/tests/api/core/upload/content-api/upload.test.api.js index 762a8409ad..8262e1930f 100644 --- a/tests/api/core/upload/content-api/upload.test.api.js +++ b/tests/api/core/upload/content-api/upload.test.api.js @@ -83,7 +83,7 @@ describe('Upload plugin', () => { }, }); - expect(res.statusCode).toBe(200); + expect(res.statusCode).toBe(201); expect(Array.isArray(res.body)).toBe(true); expect(res.body.length).toBe(1); expect(res.body[0]).toEqual( @@ -116,7 +116,7 @@ describe('Upload plugin', () => { }, }); - expect(res.statusCode).toBe(200); + expect(res.statusCode).toBe(201); expect(Array.isArray(res.body)).toBe(true); expect(res.body.length).toBe(1); expect(res.body[0]).toEqual( diff --git a/tests/api/plugins/i18n/content-manager/crud.test.api.js b/tests/api/plugins/i18n/content-manager/crud.test.api.js index 4b7ccbb944..c7fe7272af 100644 --- a/tests/api/plugins/i18n/content-manager/crud.test.api.js +++ b/tests/api/plugins/i18n/content-manager/crud.test.api.js @@ -76,7 +76,7 @@ describe('i18n - Content API', () => { const { statusCode, body } = res; - expect(statusCode).toBe(200); + expect(statusCode).toBe(201); expect(body.data).toMatchObject({ locale: 'en', name: 'category in english', @@ -98,7 +98,7 @@ describe('i18n - Content API', () => { const { statusCode, body } = res; - expect(statusCode).toBe(200); + expect(statusCode).toBe(201); expect(body.data).toMatchObject({ locale: 'ko', name: 'category in korean', @@ -125,12 +125,12 @@ describe('i18n - Content API', () => { }, }); - expect(res.statusCode).toBe(200); + expect(res.statusCode).toBe(201); expect(res.body.data.locale).toBe(locale); } const { statusCode, body } = res; - expect(statusCode).toBe(200); + expect(statusCode).toBe(201); data.categories.push(body.data); });