diff --git a/api-tests/core/content-manager/api/basic-dp-dz.test.api.js b/api-tests/core/content-manager/api/basic-dp-dz.test.api.js index 708183380c..24b5307bd1 100644 --- a/api-tests/core/content-manager/api/basic-dp-dz.test.api.js +++ b/api-tests/core/content-manager/api/basic-dp-dz.test.api.js @@ -136,6 +136,38 @@ describe('CM API - Basic + dz + draftAndPublish', () => { data.productsWithDzAndDP.shift(); }); + test('Clone product with compo', async () => { + const product = { + name: 'Product 1', + description: 'Product description', + dz: [ + { + __component: 'default.compo', + name: 'compo name', + description: 'short', + }, + ], + }; + const { body: createdProduct } = await rq({ + method: 'POST', + url: '/content-manager/collection-types/api::product-with-dz-and-dp.product-with-dz-and-dp', + body: product, + }); + + const res = await rq({ + method: 'POST', + url: `/content-manager/collection-types/api::product-with-dz-and-dp.product-with-dz-and-dp/clone/${createdProduct.id}`, + body: { + publishedAt: new Date().toISOString(), + }, + }); + + expect(res.statusCode).toBe(200); + expect(res.body).toMatchObject(product); + // When cloning the new entry must be a draft + expect(res.body.publishedAt).toBeNull(); + }); + describe('validation', () => { describe.each(['create', 'update'])('%p', (method) => { test(`Can ${method} product with compo - compo required - []`, async () => { diff --git a/api-tests/core/content-manager/api/basic-dz.test.api.js b/api-tests/core/content-manager/api/basic-dz.test.api.js index 0e09c0f323..5f4aaea754 100644 --- a/api-tests/core/content-manager/api/basic-dz.test.api.js +++ b/api-tests/core/content-manager/api/basic-dz.test.api.js @@ -97,13 +97,13 @@ describe('CM API - Basic + dz', () => { test('Update product with compo', async () => { const product = { - name: 'Product 1 updated', - description: 'Updated Product description', + name: 'Product 1', + description: 'Product description', dz: [ { __component: 'default.compo', - name: 'compo name updated', - description: 'update', + name: 'compo name', + description: 'short', }, ], }; @@ -133,6 +133,34 @@ describe('CM API - Basic + dz', () => { data.productsWithDz.shift(); }); + test('Clone product with compo', async () => { + const product = { + name: 'Product 1', + description: 'Product description', + dz: [ + { + __component: 'default.compo', + name: 'compo name', + description: 'short', + }, + ], + }; + const { body: createdProduct } = await rq({ + method: 'POST', + url: '/content-manager/collection-types/api::product-with-dz.product-with-dz', + body: product, + }); + + const res = await rq({ + method: 'POST', + url: `/content-manager/collection-types/api::product-with-dz.product-with-dz/clone/${createdProduct.id}`, + body: {}, + }); + + expect(res.statusCode).toBe(200); + expect(res.body).toMatchObject(product); + }); + describe('validation', () => { test('Cannot create product with compo - compo required', async () => { const product = {