test: publish entity with required component

This commit is contained in:
Marc-Roig 2023-06-27 10:23:40 +02:00
parent e7e8146e2e
commit 65294d29a4
No known key found for this signature in database
GPG Key ID: FB4E2C43A0BEE249

View File

@ -222,4 +222,60 @@ describe('CM API - Basic + compo + draftAndPublish', () => {
data.productsWithCompoAndDP.push(res.body); data.productsWithCompoAndDP.push(res.body);
}); });
}); });
describe('Publication', () => {
test('Can publish product with compo - required', async () => {
const product = {
name: 'Product 1',
description: 'Product description',
compo: {
name: 'compo name',
description: 'short',
},
};
const res = await rq({
method: 'POST',
url: '/content-manager/collection-types/api::product-with-compo-and-dp.product-with-compo-and-dp',
body: product,
});
const publishRes = await rq({
method: 'POST',
url: `/content-manager/collection-types/api::product-with-compo-and-dp.product-with-compo-and-dp/${res.body.id}/actions/publish`,
body: product,
});
expect(publishRes.statusCode).toBe(200);
expect(publishRes.body).toMatchObject(product);
expect(publishRes.body.id).toEqual(res.body.id);
expect(publishRes.body.publishedAt).not.toBeNull();
});
test('Can bulk publish product with compo - required', async () => {
const product = {
name: 'Product 1',
description: 'Product description',
compo: {
name: 'compo name',
description: 'short',
},
};
const res = await rq({
method: 'POST',
url: '/content-manager/collection-types/api::product-with-compo-and-dp.product-with-compo-and-dp',
body: product,
});
const publishRes = await rq({
method: 'POST',
url: `/content-manager/collection-types/api::product-with-compo-and-dp.product-with-compo-and-dp/actions/bulkPublish`,
body: {
ids: [res.body.id],
},
});
expect(publishRes.statusCode).toBe(200);
expect(publishRes.body).toMatchObject({ count: 1 });
});
});
}); });