From 4ea8d22914471d6b2f2c51e9cca8cb5721d58d49 Mon Sep 17 00:00:00 2001 From: Mohammed Saud Date: Fri, 24 Nov 2023 18:37:18 +0530 Subject: [PATCH] fix(commit): avoid using test pipeline for commit --- .../Commits/CommitDetails/CommitDetailsView.tsx | 11 +++++++++-- .../__tests__/CommitDetailsView.spec.tsx | 7 +++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/components/Commits/CommitDetails/CommitDetailsView.tsx b/src/components/Commits/CommitDetails/CommitDetailsView.tsx index 802f1701f..f226a6d41 100644 --- a/src/components/Commits/CommitDetails/CommitDetailsView.tsx +++ b/src/components/Commits/CommitDetails/CommitDetailsView.tsx @@ -1,5 +1,6 @@ import React from 'react'; import { Bullseye, Spinner, Text, TextVariants } from '@patternfly/react-core'; +import { PipelineRunLabel, PipelineRunType } from '../../../consts/pipelinerun'; import { usePipelineRunsForCommit } from '../../../hooks/usePipelineRuns'; import { PipelineRunGroupVersionKind } from '../../../models'; import DetailsPage from '../../../shared/components/details-page/DetailsPage'; @@ -36,11 +37,17 @@ const CommitDetailsView: React.FC loaded && pipelineruns?.length && createCommitObjectFromPLR(pipelineruns[0]), + () => + loaded && + pipelineruns?.length && + createCommitObjectFromPLR( + pipelineruns.find( + (p) => p.metadata.labels[PipelineRunLabel.PIPELINE_TYPE] === PipelineRunType.BUILD, + ), + ), [loaded, pipelineruns], ); diff --git a/src/components/Commits/CommitDetails/__tests__/CommitDetailsView.spec.tsx b/src/components/Commits/CommitDetails/__tests__/CommitDetailsView.spec.tsx index 707913227..6520d4e8b 100644 --- a/src/components/Commits/CommitDetails/__tests__/CommitDetailsView.spec.tsx +++ b/src/components/Commits/CommitDetails/__tests__/CommitDetailsView.spec.tsx @@ -74,4 +74,11 @@ describe('CommitDetailsView', () => { routerRenderer(); screen.getAllByText(getCommitShortName('commit123')); }); + + it('should not use integration test pipeline to get details', () => { + watchResourceMock.mockReturnValue([[pipelineWithCommits[0], pipelineWithCommits[4]], true]); + routerRenderer(); + expect(screen.getByText('test-title')).toBeVisible(); + expect(screen.queryByRole('test-title-4')).toBeNull(); + }); });