mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
fix(core): Fix issue that GET /workflows/:id does not return tags (#3522)
This commit is contained in:
@@ -8,6 +8,11 @@ import { WorkflowEntity } from '../../../../databases/entities/WorkflowEntity';
|
|||||||
import { SharedWorkflow } from '../../../../databases/entities/SharedWorkflow';
|
import { SharedWorkflow } from '../../../../databases/entities/SharedWorkflow';
|
||||||
import { isInstanceOwner } from '../users/users.service';
|
import { isInstanceOwner } from '../users/users.service';
|
||||||
import { Role } from '../../../../databases/entities/Role';
|
import { Role } from '../../../../databases/entities/Role';
|
||||||
|
import config from '../../../../../config';
|
||||||
|
|
||||||
|
function insertIf(condition: boolean, elements: string[]): string[] {
|
||||||
|
return condition ? elements : [];
|
||||||
|
}
|
||||||
|
|
||||||
export async function getSharedWorkflowIds(user: User): Promise<number[]> {
|
export async function getSharedWorkflowIds(user: User): Promise<number[]> {
|
||||||
const sharedWorkflows = await Db.collections.SharedWorkflow.find({
|
const sharedWorkflows = await Db.collections.SharedWorkflow.find({
|
||||||
@@ -26,7 +31,7 @@ export async function getSharedWorkflow(
|
|||||||
...(!isInstanceOwner(user) && { user }),
|
...(!isInstanceOwner(user) && { user }),
|
||||||
...(workflowId && { workflow: { id: workflowId } }),
|
...(workflowId && { workflow: { id: workflowId } }),
|
||||||
},
|
},
|
||||||
relations: ['workflow'],
|
relations: [...insertIf(!config.getEnv('workflowTagsDisabled'), ['workflow.tags']), 'workflow'],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -413,7 +413,7 @@ test('GET /workflows/:id should retrieve workflow', async () => {
|
|||||||
|
|
||||||
expect(response.statusCode).toBe(200);
|
expect(response.statusCode).toBe(200);
|
||||||
|
|
||||||
const { id, connections, active, staticData, nodes, settings, name, createdAt, updatedAt } =
|
const { id, connections, active, staticData, nodes, settings, name, createdAt, updatedAt, tags } =
|
||||||
response.body;
|
response.body;
|
||||||
|
|
||||||
expect(id).toEqual(workflow.id);
|
expect(id).toEqual(workflow.id);
|
||||||
@@ -422,6 +422,7 @@ test('GET /workflows/:id should retrieve workflow', async () => {
|
|||||||
expect(active).toBe(false);
|
expect(active).toBe(false);
|
||||||
expect(staticData).toEqual(workflow.staticData);
|
expect(staticData).toEqual(workflow.staticData);
|
||||||
expect(nodes).toEqual(workflow.nodes);
|
expect(nodes).toEqual(workflow.nodes);
|
||||||
|
expect(tags).toEqual([]);
|
||||||
expect(settings).toEqual(workflow.settings);
|
expect(settings).toEqual(workflow.settings);
|
||||||
expect(createdAt).toEqual(workflow.createdAt.toISOString());
|
expect(createdAt).toEqual(workflow.createdAt.toISOString());
|
||||||
expect(updatedAt).toEqual(workflow.updatedAt.toISOString());
|
expect(updatedAt).toEqual(workflow.updatedAt.toISOString());
|
||||||
|
|||||||
Reference in New Issue
Block a user