mirror of
https://github.com/strapi/strapi.git
synced 2025-09-03 13:50:38 +00:00
test clone dynamic zones
This commit is contained in:
parent
d90a0c34bb
commit
52bf461b06
@ -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 () => {
|
||||
|
@ -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 = {
|
||||
|
Loading…
x
Reference in New Issue
Block a user