Skip to content

Commit

Permalink
fix(snapshot): add test plrs, capitalize breadcrumb and environment
Browse files Browse the repository at this point in the history
  • Loading branch information
abhinandan13jan committed Oct 30, 2023
1 parent 01b7b7b commit c7c149f
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/components/SnapshotDetails/SnapshotDetailsView.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import { useK8sWatchResource } from '@openshift/dynamic-plugin-sdk-utils';
import { Bullseye, Spinner, Text, TextVariants } from '@patternfly/react-core';
import { Bullseye, Spinner, Text, TextVariants, capitalize } from '@patternfly/react-core';
import { useEnvironments } from '../../hooks/useEnvironments';
import { usePipelineRun } from '../../hooks/usePipelineRuns';
import { SnapshotEnvironmentBindingGroupVersionKind, SnapshotGroupVersionKind } from '../../models';
Expand Down Expand Up @@ -113,7 +113,7 @@ const SnapshotDetailsView: React.FC<SnapshotDetailsViewProps> = ({
...applicationBreadcrumbs,
{
path: `#`,
name: 'snapshots',
name: 'Snapshots',
},
{
path: `/application-pipeline/workspaces/${workspace}/applications/${applicationName}/snapshots/${snapshotName}`,
Expand Down Expand Up @@ -147,7 +147,7 @@ const SnapshotDetailsView: React.FC<SnapshotDetailsViewProps> = ({
<>
<StatusIconWithTextLabel
key={env.metadata?.name}
text={env.metadata.name}
text={capitalize(env.metadata.name)}
dataTestAttribute="snapshot-env-label"
status={isDeployed ? runStatus.Succeeded : runStatus.Cancelling}
/>{' '}
Expand Down
3 changes: 2 additions & 1 deletion src/components/SnapshotDetails/tabs/SnapshotOverview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
FlexItem,
Skeleton,
Title,
capitalize,
} from '@patternfly/react-core';
import { ScanStatus } from '../../../components/PipelineRunListView/ScanStatus';
import { useScanResults } from '../../../hooks/useScanResults';
Expand Down Expand Up @@ -101,7 +102,7 @@ const SnapshotOverviewTab: React.FC<SnapshotOverviewTabProps> = ({
<Link
to={`/application-pipeline/workspaces/${workspace}/applications/${snapshot.spec.application}/deployments`}
>
{env}
{capitalize(env)}
</Link>
</div>
))}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,25 @@ const snapShotPLRs = [
spec: null,
status: null,
},

{
apiVersion: mockPipelineRuns[0].apiVersion,
kind: mockPipelineRuns[0].kind,
metadata: {
...mockPipelineRuns[2].metadata,
name: 'plr-with snapshot-label-only',
labels: {
...mockPipelineRuns[2].metadata.labels,
[PipelineRunLabel.PIPELINE_TYPE]: PipelineRunType.TEST,
[PipelineRunLabel.SNAPSHOT]: 'test-snapshot',
},
annotations: {
...mockPipelineRuns[2].metadata.annotations,
},
},
spec: null,
status: null,
},
];

describe('SnapshotPipelinerunsTab', () => {
Expand Down Expand Up @@ -175,6 +194,18 @@ describe('SnapshotPipelinerunsTab', () => {
);
});

it('should render pipelineruns with snapshot labels instead of annotations', () => {
render(
<SnapshotPipelineRunsList
applicationName={appName}
getNextPage={null}
snapshotPipelineRuns={snapShotPLRs}
loaded={true}
/>,
);
expect(screen.queryByText('plr-with snapshot-label-only')).toBeInTheDocument();
});

it('should render entire pipelineRuns list when no filter value', () => {
render(
<SnapshotPipelineRunsList
Expand Down

0 comments on commit c7c149f

Please sign in to comment.