From bad61555093f59a647b20df75f83e1cf9687f7b5 Mon Sep 17 00:00:00 2001 From: Peixuan Ding Date: Wed, 26 May 2021 11:32:43 -0400 Subject: [PATCH] fix(ui): Fix link for archived logs (#6019) Signed-off-by: Peixuan Ding --- .../shared/services/workflow-service.test.ts | 43 +++++++++++++++++++ .../app/shared/services/workflows-service.ts | 2 +- 2 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 ui/src/app/shared/services/workflow-service.test.ts diff --git a/ui/src/app/shared/services/workflow-service.test.ts b/ui/src/app/shared/services/workflow-service.test.ts new file mode 100644 index 000000000000..3cbd76fed54c --- /dev/null +++ b/ui/src/app/shared/services/workflow-service.test.ts @@ -0,0 +1,43 @@ +/** + * @jest-environment jsdom + */ +import {Workflow} from '../../../models'; +import {WorkflowsService} from './workflows-service'; + +const workflow = (name: string, namespace: string, uid: string): Workflow => { + return { + metadata: { + name, + namespace, + uid + }, + spec: {} + }; +}; + +describe('workflow service', () => { + const service = new WorkflowsService(); + test('getArtifactLogsUrl', () => { + expect(service.getArtifactLogsUrl(workflow('hello-world', 'argo', 'test-uid'), 'test-node', 'test-container', false)).toBe( + 'artifacts/argo/hello-world/test-node/test-container-logs' + ); + expect(service.getArtifactLogsUrl(workflow('hello-world', 'argo', 'test-uid'), 'test-node', 'test-container', true)).toBe( + 'artifacts-by-uid/test-uid/test-node/test-container-logs' + ); + }); + + test('getArtifactDownloadUrl', () => { + expect(service.getArtifactDownloadUrl(workflow('hello-world', 'argo', 'test-uid'), 'test-node', 'test-artifact', false, false)).toBe( + 'artifacts/argo/hello-world/test-node/test-artifact' + ); + expect(service.getArtifactDownloadUrl(workflow('hello-world', 'argo', 'test-uid'), 'test-node', 'test-artifact', true, false)).toBe( + 'artifacts-by-uid/test-uid/test-node/test-artifact' + ); + expect(service.getArtifactDownloadUrl(workflow('hello-world', 'argo', 'test-uid'), 'test-node', 'test-artifact', false, true)).toBe( + 'input-artifacts/argo/hello-world/test-node/test-artifact' + ); + expect(service.getArtifactDownloadUrl(workflow('hello-world', 'argo', 'test-uid'), 'test-node', 'test-artifact', true, true)).toBe( + 'input-artifacts-by-uid/test-uid/test-node/test-artifact' + ); + }); +}); diff --git a/ui/src/app/shared/services/workflows-service.ts b/ui/src/app/shared/services/workflows-service.ts index 0b108eed8ea4..7b3bbde2ccf6 100644 --- a/ui/src/app/shared/services/workflows-service.ts +++ b/ui/src/app/shared/services/workflows-service.ts @@ -198,7 +198,7 @@ export class WorkflowsService { } public getArtifactLogsUrl(workflow: Workflow, nodeId: string, container: string, archived: boolean) { - return this.getArtifactDownloadUrl(workflow, nodeId, container + '-logs', archived, true); + return this.getArtifactDownloadUrl(workflow, nodeId, container + '-logs', archived, false); } public getArtifactDownloadUrl(workflow: Workflow, nodeId: string, artifactName: string, archived: boolean, isInput: boolean) {