mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 10:02:05 +00:00
feat(core): Update POST /workflows to link folder (no-changelog) (#13449)
This commit is contained in:
@@ -58,13 +58,14 @@ let projectService: ProjectService;
|
||||
|
||||
beforeEach(async () => {
|
||||
await testDb.truncate([
|
||||
'Workflow',
|
||||
'SharedWorkflow',
|
||||
'Tag',
|
||||
'WorkflowHistory',
|
||||
'Project',
|
||||
'ProjectRelation',
|
||||
'Folder',
|
||||
'Workflow',
|
||||
'Tag',
|
||||
'Project',
|
||||
'User',
|
||||
]);
|
||||
projectRepository = Container.get(ProjectRepository);
|
||||
projectService = Container.get(ProjectService);
|
||||
@@ -378,6 +379,115 @@ describe('POST /workflows', () => {
|
||||
message: "You don't have the permissions to save the workflow in this project.",
|
||||
});
|
||||
});
|
||||
|
||||
test('create link workflow with folder if one is provided', async () => {
|
||||
//
|
||||
// ARRANGE
|
||||
//
|
||||
const personalProject = await projectRepository.getPersonalProjectForUserOrFail(owner.id);
|
||||
const folder = await createFolder(personalProject, { name: 'Folder 1' });
|
||||
|
||||
const workflow = makeWorkflow();
|
||||
|
||||
//
|
||||
// ACT
|
||||
//
|
||||
const response = await authOwnerAgent
|
||||
.post('/workflows')
|
||||
.send({ ...workflow, parentFolderId: folder.id });
|
||||
|
||||
//
|
||||
// ASSERT
|
||||
//
|
||||
|
||||
expect(response.body.data).toMatchObject({
|
||||
active: false,
|
||||
id: expect.any(String),
|
||||
name: workflow.name,
|
||||
sharedWithProjects: [],
|
||||
usedCredentials: [],
|
||||
homeProject: {
|
||||
id: personalProject.id,
|
||||
name: personalProject.name,
|
||||
type: personalProject.type,
|
||||
},
|
||||
parentFolder: {
|
||||
id: folder.id,
|
||||
name: folder.name,
|
||||
},
|
||||
});
|
||||
expect(response.body.data.shared).toBeUndefined();
|
||||
});
|
||||
|
||||
test('create workflow without parent folder if no folder is provided', async () => {
|
||||
//
|
||||
// ARRANGE
|
||||
//
|
||||
const personalProject = await projectRepository.getPersonalProjectForUserOrFail(owner.id);
|
||||
const workflow = makeWorkflow();
|
||||
|
||||
//
|
||||
// ACT
|
||||
//
|
||||
const response = await authOwnerAgent
|
||||
.post('/workflows')
|
||||
.send({ ...workflow })
|
||||
.expect(200);
|
||||
|
||||
//
|
||||
// ASSERT
|
||||
//
|
||||
|
||||
expect(response.body.data).toMatchObject({
|
||||
active: false,
|
||||
id: expect.any(String),
|
||||
name: workflow.name,
|
||||
sharedWithProjects: [],
|
||||
usedCredentials: [],
|
||||
homeProject: {
|
||||
id: personalProject.id,
|
||||
name: personalProject.name,
|
||||
type: personalProject.type,
|
||||
},
|
||||
parentFolder: null,
|
||||
});
|
||||
expect(response.body.data.shared).toBeUndefined();
|
||||
});
|
||||
|
||||
test('create workflow without parent is provided folder does not exist in the project', async () => {
|
||||
//
|
||||
// ARRANGE
|
||||
//
|
||||
const personalProject = await projectRepository.getPersonalProjectForUserOrFail(owner.id);
|
||||
const workflow = makeWorkflow();
|
||||
|
||||
//
|
||||
// ACT
|
||||
//
|
||||
const response = await authOwnerAgent
|
||||
.post('/workflows')
|
||||
.send({ ...workflow, parentFolderId: 'non-existing-folder-id' })
|
||||
.expect(200);
|
||||
|
||||
//
|
||||
// ASSERT
|
||||
//
|
||||
|
||||
expect(response.body.data).toMatchObject({
|
||||
active: false,
|
||||
id: expect.any(String),
|
||||
name: workflow.name,
|
||||
sharedWithProjects: [],
|
||||
usedCredentials: [],
|
||||
homeProject: {
|
||||
id: personalProject.id,
|
||||
name: personalProject.name,
|
||||
type: personalProject.type,
|
||||
},
|
||||
parentFolder: null,
|
||||
});
|
||||
expect(response.body.data.shared).toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
||||
describe('GET /workflows/:workflowId', () => {
|
||||
|
||||
Reference in New Issue
Block a user