mirror of
https://github.com/strapi/strapi.git
synced 2025-11-01 18:33:55 +00:00
Merge branch 'feature/review-workflow' into review-workflow/stage-one-way-relation
This commit is contained in:
commit
debba04c13
@ -1,5 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
const { mapAsync } = require('@strapi/utils');
|
||||
|
||||
const { createStrapiInstance } = require('api-tests/strapi');
|
||||
const { createAuthRequest, createRequest } = require('api-tests/request');
|
||||
const { createTestBuilder } = require('api-tests/builder');
|
||||
@ -494,22 +496,21 @@ describeOnCondition(edition === 'EE')('Review workflows', () => {
|
||||
const res = await requests.admin.get(`/admin/review-workflows/workflows/1/stages`);
|
||||
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);
|
||||
productsBefore.results.forEach(async (entry) => {
|
||||
if (Math.random() < 0.3) {
|
||||
await requests.admin.put(
|
||||
`/admin/content-manager/collection-types/${productUID}/${entry.id}/stage`,
|
||||
{
|
||||
body: {
|
||||
data: { id: defaultStages.slice(-1)[0].id },
|
||||
},
|
||||
}
|
||||
);
|
||||
entriesMovedToEnd.push(entry.id);
|
||||
}
|
||||
});
|
||||
const entriesMovedToEnd = productsBefore.results
|
||||
.filter((entry) => entry.id % 2 === 0)
|
||||
.map((entry) => entry.id);
|
||||
|
||||
await mapAsync(entriesMovedToEnd, async (entityId) =>
|
||||
requests.admin.put(
|
||||
`/admin/content-manager/collection-types/${productUID}/${entityId}/stage`,
|
||||
{
|
||||
body: {
|
||||
data: { id: defaultStages.slice(-1)[0].id },
|
||||
},
|
||||
}
|
||||
)
|
||||
);
|
||||
|
||||
// Delete the first and last stage stage of the default workflow
|
||||
await requests.admin.put(`/admin/review-workflows/workflows/1/stages`, {
|
||||
@ -518,7 +519,7 @@ describeOnCondition(edition === 'EE')('Review workflows', () => {
|
||||
|
||||
// Expect the content in these stages to be moved to the nearest available stage
|
||||
const productsAfter = await findAll(productUID);
|
||||
productsAfter.results.forEach(async (entry) => {
|
||||
await mapAsync(productsAfter.results, async (entry) => {
|
||||
if (entriesMovedToEnd.includes(entry.id)) {
|
||||
expect(await entry[ENTITY_STAGE_ATTRIBUTE].name).toEqual(defaultStages[2].name);
|
||||
return;
|
||||
|
||||
@ -53,7 +53,7 @@ const workflowMock = {
|
||||
};
|
||||
|
||||
const entityServiceMock = {
|
||||
findOne: jest.fn((uid, id) => workflowMock.stages.find((stage) => stage.id === id)),
|
||||
findOne: jest.fn((uid, id) => workflowMock.stages.find((stage) => stage.id === id) || { id }),
|
||||
findMany: jest.fn(() => [stageMock]),
|
||||
create: jest.fn((uid, { data }) => ({
|
||||
...data,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user