test clone dynamic zones

This commit is contained in:
Marc-Roig 2023-03-28 11:04:11 +02:00 committed by Josh
parent d90a0c34bb
commit 52bf461b06
2 changed files with 64 additions and 4 deletions

View File

@ -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 () => {

View File

@ -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 = {