mirror of
https://github.com/strapi/strapi.git
synced 2025-09-05 06:43:07 +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();
|
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('validation', () => {
|
||||||
describe.each(['create', 'update'])('%p', (method) => {
|
describe.each(['create', 'update'])('%p', (method) => {
|
||||||
test(`Can ${method} product with compo - compo required - []`, async () => {
|
test(`Can ${method} product with compo - compo required - []`, async () => {
|
||||||
|
@ -97,13 +97,13 @@ describe('CM API - Basic + dz', () => {
|
|||||||
|
|
||||||
test('Update product with compo', async () => {
|
test('Update product with compo', async () => {
|
||||||
const product = {
|
const product = {
|
||||||
name: 'Product 1 updated',
|
name: 'Product 1',
|
||||||
description: 'Updated Product description',
|
description: 'Product description',
|
||||||
dz: [
|
dz: [
|
||||||
{
|
{
|
||||||
__component: 'default.compo',
|
__component: 'default.compo',
|
||||||
name: 'compo name updated',
|
name: 'compo name',
|
||||||
description: 'update',
|
description: 'short',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
@ -133,6 +133,34 @@ describe('CM API - Basic + dz', () => {
|
|||||||
data.productsWithDz.shift();
|
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', () => {
|
describe('validation', () => {
|
||||||
test('Cannot create product with compo - compo required', async () => {
|
test('Cannot create product with compo - compo required', async () => {
|
||||||
const product = {
|
const product = {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user