mirror of
https://github.com/strapi/strapi.git
synced 2025-11-02 19:04:38 +00:00
fix(ee): api test
This commit is contained in:
parent
d07a862ec4
commit
e78576d03f
@ -1,5 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
const { mapAsync } = require('@strapi/utils');
|
||||||
|
|
||||||
const { createStrapiInstance } = require('api-tests/strapi');
|
const { createStrapiInstance } = require('api-tests/strapi');
|
||||||
const { createAuthRequest, createRequest } = require('api-tests/request');
|
const { createAuthRequest, createRequest } = require('api-tests/request');
|
||||||
const { createTestBuilder } = require('api-tests/builder');
|
const { createTestBuilder } = require('api-tests/builder');
|
||||||
@ -489,22 +491,21 @@ describeOnCondition(edition === 'EE')('Review workflows', () => {
|
|||||||
const res = await requests.admin.get(`/admin/review-workflows/workflows/1/stages`);
|
const res = await requests.admin.get(`/admin/review-workflows/workflows/1/stages`);
|
||||||
const defaultStages = res.body.data;
|
const defaultStages = res.body.data;
|
||||||
|
|
||||||
// Get all products and move ~30% of them to the last stage of the workflow
|
|
||||||
const entriesMovedToEnd = [];
|
|
||||||
const productsBefore = await findAll(productUID);
|
const productsBefore = await findAll(productUID);
|
||||||
productsBefore.results.forEach(async (entry) => {
|
const entriesMovedToEnd = productsBefore.results
|
||||||
if (Math.random() < 0.3) {
|
.filter((entry) => entry.id % 2 === 0)
|
||||||
await requests.admin.put(
|
.map((entry) => entry.id);
|
||||||
`/admin/content-manager/collection-types/${productUID}/${entry.id}/stage`,
|
|
||||||
{
|
await mapAsync(entriesMovedToEnd, async (entityId) =>
|
||||||
body: {
|
requests.admin.put(
|
||||||
data: { id: defaultStages.slice(-1)[0].id },
|
`/admin/content-manager/collection-types/${productUID}/${entityId}/stage`,
|
||||||
},
|
{
|
||||||
}
|
body: {
|
||||||
);
|
data: { id: defaultStages.slice(-1)[0].id },
|
||||||
entriesMovedToEnd.push(entry.id);
|
},
|
||||||
}
|
}
|
||||||
});
|
)
|
||||||
|
);
|
||||||
|
|
||||||
// Delete the first and last stage stage of the default workflow
|
// Delete the first and last stage stage of the default workflow
|
||||||
await requests.admin.put(`/admin/review-workflows/workflows/1/stages`, {
|
await requests.admin.put(`/admin/review-workflows/workflows/1/stages`, {
|
||||||
@ -513,7 +514,7 @@ describeOnCondition(edition === 'EE')('Review workflows', () => {
|
|||||||
|
|
||||||
// Expect the content in these stages to be moved to the nearest available stage
|
// Expect the content in these stages to be moved to the nearest available stage
|
||||||
const productsAfter = await findAll(productUID);
|
const productsAfter = await findAll(productUID);
|
||||||
productsAfter.results.forEach(async (entry) => {
|
await mapAsync(productsAfter.results, async (entry) => {
|
||||||
if (entriesMovedToEnd.includes(entry.id)) {
|
if (entriesMovedToEnd.includes(entry.id)) {
|
||||||
expect(await entry[ENTITY_STAGE_ATTRIBUTE].name).toEqual(defaultStages[2].name);
|
expect(await entry[ENTITY_STAGE_ATTRIBUTE].name).toEqual(defaultStages[2].name);
|
||||||
return;
|
return;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user