mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 01:56:46 +00:00
feat(core): Allow setting folder destination when transferring workflow ownership (#14935)
This commit is contained in:
@@ -36,6 +36,7 @@ describe('EnterpriseWorkflowService', () => {
|
||||
mock(),
|
||||
mock(),
|
||||
mock(),
|
||||
mock(),
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user