mirror of
https://github.com/strapi/strapi.git
synced 2025-11-14 01:02:04 +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';
|
'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');
|
||||||
@ -494,22 +496,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) =>
|
||||||
|
requests.admin.put(
|
||||||
|
`/admin/content-manager/collection-types/${productUID}/${entityId}/stage`,
|
||||||
{
|
{
|
||||||
body: {
|
body: {
|
||||||
data: { id: defaultStages.slice(-1)[0].id },
|
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`, {
|
||||||
@ -518,7 +519,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;
|
||||||
|
|||||||
@ -53,7 +53,7 @@ const workflowMock = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const entityServiceMock = {
|
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]),
|
findMany: jest.fn(() => [stageMock]),
|
||||||
create: jest.fn((uid, { data }) => ({
|
create: jest.fn((uid, { data }) => ({
|
||||||
...data,
|
...data,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user