mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
fix(core): Don't create multiple owners when importing credentials or workflows (#9112)
This commit is contained in:
@@ -12,8 +12,13 @@ import { SharedWorkflowRepository } from '@/databases/repositories/sharedWorkflo
|
||||
|
||||
import * as testDb from './shared/testDb';
|
||||
import { mockInstance } from '../shared/mocking';
|
||||
import { createOwner } from './shared/db/users';
|
||||
import { createWorkflow, getWorkflowById } from './shared/db/workflows';
|
||||
import { createMember, createOwner } from './shared/db/users';
|
||||
import {
|
||||
createWorkflow,
|
||||
getAllSharedWorkflows,
|
||||
getWorkflowById,
|
||||
newWorkflow,
|
||||
} from './shared/db/workflows';
|
||||
|
||||
import type { User } from '@db/entities/User';
|
||||
|
||||
@@ -57,7 +62,7 @@ describe('ImportService', () => {
|
||||
});
|
||||
|
||||
test('should make user owner of imported workflow', async () => {
|
||||
const workflowToImport = await createWorkflow();
|
||||
const workflowToImport = newWorkflow();
|
||||
|
||||
await importService.importWorkflows([workflowToImport], owner.id);
|
||||
|
||||
@@ -68,6 +73,23 @@ describe('ImportService', () => {
|
||||
expect(dbSharing.userId).toBe(owner.id);
|
||||
});
|
||||
|
||||
test('should not change the owner if it already exists', async () => {
|
||||
const member = await createMember();
|
||||
const workflowToImport = await createWorkflow(undefined, owner);
|
||||
|
||||
await importService.importWorkflows([workflowToImport], member.id);
|
||||
|
||||
const sharings = await getAllSharedWorkflows();
|
||||
|
||||
expect(sharings).toMatchObject([
|
||||
expect.objectContaining({
|
||||
workflowId: workflowToImport.id,
|
||||
userId: owner.id,
|
||||
role: 'workflow:owner',
|
||||
}),
|
||||
]);
|
||||
});
|
||||
|
||||
test('should deactivate imported workflow if active', async () => {
|
||||
const workflowToImport = await createWorkflow({ active: true });
|
||||
|
||||
|
||||
Reference in New Issue
Block a user