feat(core): Allow setting folder destination when transferring workflow ownership (#14935)

This commit is contained in:
Ricardo Espinoza
2025-04-28 09:35:02 -04:00
committed by GitHub
parent 0a2b740063
commit dbffcdc2ff
5 changed files with 91 additions and 4 deletions

View File

@@ -1620,7 +1620,7 @@ describe('PUT /:workflowId/transfer', () => {
expect(activeWorkflowManager.add).toHaveBeenCalledWith(workflow.id, 'update');
});
test('should detach workflow from parent folder in source project', async () => {
test('should move workflow to project root if `destinationParentFolderId` is not provided', async () => {
//
// ARRANGE
//
@@ -1652,6 +1652,72 @@ describe('PUT /:workflowId/transfer', () => {
expect(workflowFromDB.parentFolder).toBeNull();
});
test('should move workflow to the parent folder in source project if `destinationParentFolderId` is provided', async () => {
//
// ARRANGE
//
const destinationProject = await createTeamProject('Team Project', member);
const folder = await createFolder(destinationProject, { name: 'Test Folder' });
const workflow = await createWorkflow({ active: true, parentFolder: folder }, member);
//
// ACT
//
const response = await testServer
.authAgentFor(member)
.put(`/workflows/${workflow.id}/transfer`)
.send({ destinationProjectId: destinationProject.id, destinationParentFolderId: folder.id })
.expect(200);
//
// ASSERT
//
expect(response.body).toEqual({});
const workflowFromDB = await workflowRepository.findOneOrFail({
where: { id: workflow.id },
relations: ['parentFolder'],
});
expect(workflowFromDB.parentFolder?.id).toBe(folder.id);
});
test('should fail destination parent folder does not exist in project', async () => {
//
// ARRANGE
//
const destinationProject = await createTeamProject('Team Project', member);
const anotherProject = await createTeamProject('Another Project', member);
const folderInDestinationProject = await createFolder(destinationProject, {
name: 'Test Folder',
});
const anotherFolder = await createFolder(destinationProject, {
name: 'Another Test Folder',
});
const workflow = await createWorkflow(
{ active: true, parentFolder: folderInDestinationProject },
member,
);
//
// ACT
//
await testServer
.authAgentFor(member)
.put(`/workflows/${workflow.id}/transfer`)
.send({
destinationProjectId: anotherProject.id,
destinationParentFolderId: anotherFolder.id,
})
.expect(400);
});
test('deactivates the workflow if it cannot be added to the active workflow manager again and returns the WorkflowActivationError as data', async () => {
//
// ARRANGE