Skip to content

Commit

Permalink
Merge pull request #869 from rottencandy/fix/commit-test-plr-987
Browse files Browse the repository at this point in the history
fix(commits): Avoid using test pipelineruns for commit details
  • Loading branch information
openshift-merge-bot[bot] authored Nov 28, 2023
2 parents 2574a6f + 4ea8d22 commit 2900fc0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/components/Commits/CommitDetails/CommitDetailsView.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -36,11 +37,17 @@ const CommitDetailsView: React.FC<React.PropsWithChildren<CommitDetailsViewProps
namespace,
applicationName,
commitName,
1,
);

const commit = React.useMemo(
() => loaded && pipelineruns?.length && createCommitObjectFromPLR(pipelineruns[0]),
() =>
loaded &&
pipelineruns?.length &&
createCommitObjectFromPLR(
pipelineruns.find(
(p) => p.metadata.labels[PipelineRunLabel.PIPELINE_TYPE] === PipelineRunType.BUILD,
),
),
[loaded, pipelineruns],
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,11 @@ describe('CommitDetailsView', () => {
routerRenderer(<CommitDetailsView applicationName="test-application" commitName="commit123" />);
screen.getAllByText(getCommitShortName('commit123'));
});

it('should not use integration test pipeline to get details', () => {
watchResourceMock.mockReturnValue([[pipelineWithCommits[0], pipelineWithCommits[4]], true]);
routerRenderer(<CommitDetailsView applicationName="test-application" commitName="commit123" />);
expect(screen.getByText('test-title')).toBeVisible();
expect(screen.queryByRole('test-title-4')).toBeNull();
});
});

0 comments on commit 2900fc0

Please sign in to comment.