mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-21 11:49:59 +00:00
fix(core): Detach workflow from parent folder in source project when transferring ownership (#14414)
This commit is contained in:
@@ -343,6 +343,9 @@ export class EnterpriseWorkflowService {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// 9. detach workflow from parent folder in source project
|
||||||
|
await this.workflowRepository.update({ id: workflow.id }, { parentFolder: null });
|
||||||
|
|
||||||
// 9. try to activate it again if it was active
|
// 9. try to activate it again if it was active
|
||||||
if (wasActive) {
|
if (wasActive) {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import { WorkflowRepository } from '@/databases/repositories/workflow.repository
|
|||||||
import { UserManagementMailer } from '@/user-management/email';
|
import { UserManagementMailer } from '@/user-management/email';
|
||||||
import type { WorkflowWithSharingsMetaDataAndCredentials } from '@/workflows/workflows.types';
|
import type { WorkflowWithSharingsMetaDataAndCredentials } from '@/workflows/workflows.types';
|
||||||
import { mockInstance } from '@test/mocking';
|
import { mockInstance } from '@test/mocking';
|
||||||
|
import { createFolder } from '@test-integration/db/folders';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
affixRoleToSaveCredential,
|
affixRoleToSaveCredential,
|
||||||
@@ -1619,6 +1620,38 @@ describe('PUT /:workflowId/transfer', () => {
|
|||||||
expect(activeWorkflowManager.add).toHaveBeenCalledWith(workflow.id, 'update');
|
expect(activeWorkflowManager.add).toHaveBeenCalledWith(workflow.id, 'update');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('should detach workflow from parent folder in source project', 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 })
|
||||||
|
.expect(200);
|
||||||
|
|
||||||
|
//
|
||||||
|
// ASSERT
|
||||||
|
//
|
||||||
|
expect(response.body).toEqual({});
|
||||||
|
|
||||||
|
const workflowFromDB = await workflowRepository.findOneOrFail({
|
||||||
|
where: { id: workflow.id },
|
||||||
|
relations: ['parentFolder'],
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(workflowFromDB.parentFolder).toBeNull();
|
||||||
|
});
|
||||||
|
|
||||||
test('deactivates the workflow if it cannot be added to the active workflow manager again and returns the WorkflowActivationError as data', async () => {
|
test('deactivates the workflow if it cannot be added to the active workflow manager again and returns the WorkflowActivationError as data', async () => {
|
||||||
//
|
//
|
||||||
// ARRANGE
|
// ARRANGE
|
||||||
|
|||||||
Reference in New Issue
Block a user