mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-23 11:44:06 -08:00
fix(core): Fix issue that GET /workflows/:id does not return tags (#3522)
This commit is contained in:
parent
1bef4df75f
commit
f75f5d711f
|
@ -8,6 +8,11 @@ import { WorkflowEntity } from '../../../../databases/entities/WorkflowEntity';
|
|||
import { SharedWorkflow } from '../../../../databases/entities/SharedWorkflow';
|
||||
import { isInstanceOwner } from '../users/users.service';
|
||||
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[]> {
|
||||
const sharedWorkflows = await Db.collections.SharedWorkflow.find({
|
||||
|
@ -26,7 +31,7 @@ export async function getSharedWorkflow(
|
|||
...(!isInstanceOwner(user) && { user }),
|
||||
...(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);
|
||||
|
||||
const { id, connections, active, staticData, nodes, settings, name, createdAt, updatedAt } =
|
||||
const { id, connections, active, staticData, nodes, settings, name, createdAt, updatedAt, tags } =
|
||||
response.body;
|
||||
|
||||
expect(id).toEqual(workflow.id);
|
||||
|
@ -422,6 +422,7 @@ test('GET /workflows/:id should retrieve workflow', async () => {
|
|||
expect(active).toBe(false);
|
||||
expect(staticData).toEqual(workflow.staticData);
|
||||
expect(nodes).toEqual(workflow.nodes);
|
||||
expect(tags).toEqual([]);
|
||||
expect(settings).toEqual(workflow.settings);
|
||||
expect(createdAt).toEqual(workflow.createdAt.toISOString());
|
||||
expect(updatedAt).toEqual(workflow.updatedAt.toISOString());
|
||||
|
|
Loading…
Reference in a new issue