mirror of
https://github.com/n8n-io/n8n.git
synced 2025-01-11 04:47:29 -08:00
fix(API): Fix workflow project transfer (#10651)
Co-authored-by: Benjamin Roedell <2271599+benrobot@users.noreply.github.com>
This commit is contained in:
parent
f20e9454a3
commit
5f89e3a01c
|
@ -84,11 +84,7 @@ export declare namespace WorkflowRequest {
|
||||||
type Activate = Get;
|
type Activate = Get;
|
||||||
type GetTags = Get;
|
type GetTags = Get;
|
||||||
type UpdateTags = AuthenticatedRequest<{ id: string }, {}, TagEntity[]>;
|
type UpdateTags = AuthenticatedRequest<{ id: string }, {}, TagEntity[]>;
|
||||||
type Transfer = AuthenticatedRequest<
|
type Transfer = AuthenticatedRequest<{ id: string }, {}, { destinationProjectId: string }>;
|
||||||
{ workflowId: string },
|
|
||||||
{},
|
|
||||||
{ destinationProjectId: string }
|
|
||||||
>;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export declare namespace UserRequest {
|
export declare namespace UserRequest {
|
||||||
|
|
|
@ -73,11 +73,13 @@ export = {
|
||||||
transferWorkflow: [
|
transferWorkflow: [
|
||||||
projectScope('workflow:move', 'workflow'),
|
projectScope('workflow:move', 'workflow'),
|
||||||
async (req: WorkflowRequest.Transfer, res: express.Response) => {
|
async (req: WorkflowRequest.Transfer, res: express.Response) => {
|
||||||
|
const { id: workflowId } = req.params;
|
||||||
|
|
||||||
const body = z.object({ destinationProjectId: z.string() }).parse(req.body);
|
const body = z.object({ destinationProjectId: z.string() }).parse(req.body);
|
||||||
|
|
||||||
await Container.get(EnterpriseWorkflowService).transferOne(
|
await Container.get(EnterpriseWorkflowService).transferOne(
|
||||||
req.user,
|
req.user,
|
||||||
req.params.workflowId,
|
workflowId,
|
||||||
body.destinationProjectId,
|
body.destinationProjectId,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -1512,6 +1512,10 @@ describe('PUT /workflows/:id/transfer', () => {
|
||||||
const secondProject = await createTeamProject('second-project', member);
|
const secondProject = await createTeamProject('second-project', member);
|
||||||
const workflow = await createWorkflow({}, firstProject);
|
const workflow = await createWorkflow({}, firstProject);
|
||||||
|
|
||||||
|
// Make data more similar to real world scenario by injecting additional records into the database
|
||||||
|
await createTeamProject('third-project', member);
|
||||||
|
await createWorkflow({}, firstProject);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Act
|
* Act
|
||||||
*/
|
*/
|
||||||
|
@ -1523,6 +1527,13 @@ describe('PUT /workflows/:id/transfer', () => {
|
||||||
* Assert
|
* Assert
|
||||||
*/
|
*/
|
||||||
expect(response.statusCode).toBe(204);
|
expect(response.statusCode).toBe(204);
|
||||||
|
|
||||||
|
const workflowsInProjectResponse = await authMemberAgent
|
||||||
|
.get(`/workflows?projectId=${secondProject.id}`)
|
||||||
|
.send();
|
||||||
|
|
||||||
|
expect(workflowsInProjectResponse.statusCode).toBe(200);
|
||||||
|
expect(workflowsInProjectResponse.body.data[0].id).toBe(workflow.id);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('if no destination project, should reject', async () => {
|
test('if no destination project, should reject', async () => {
|
||||||
|
|
Loading…
Reference in a new issue