Skip to content

Commit

Permalink
fix(core): Fix issue that GET /workflows/:id does not return tags (#3522
Browse files Browse the repository at this point in the history
)
  • Loading branch information
RicardoE105 authored Jun 18, 2022
1 parent 1bef4df commit f75f5d7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand All @@ -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'],
});
}

Expand Down
3 changes: 2 additions & 1 deletion packages/cli/test/integration/publicApi/workflows.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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());
Expand Down

0 comments on commit f75f5d7

Please sign in to comment.