Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug 1995523: Add checks for annotations in pipeline quicksearch utils #9820

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ const PipelineQuickSearchDetails: React.FC<QuickSearchDetailsRendererProps> = ({
{buttonText}
</Button>
</SplitItem>
{
{versions.length > 0 && (
<SplitItem>
<Dropdown
data-test={'task-version'}
Expand All @@ -120,7 +120,7 @@ const PipelineQuickSearchDetails: React.FC<QuickSearchDetailsRendererProps> = ({
}}
/>
</SplitItem>
}
)}
</Split>
{getTaskAlert}
<TextContent className="opp-quick-search-details__description" data-test={'task-description'}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,12 @@ describe('pipeline-quicksearch-utils', () => {
});

describe('isInstalledNamespaceTask', () => {
it('should return false if the annotations are missing in the metadata', () => {
expect(
isInstalledNamespaceTask(omit(sampleClusterTaskCatalogItem, 'data.metadata.annotations')),
).toBe(false);
});

it('should return false if the tekton hub task is passed', () => {
expect(isInstalledNamespaceTask(sampleTektonHubCatalogItem)).toBe(false);
});
Expand Down Expand Up @@ -215,6 +221,15 @@ describe('pipeline-quicksearch-utils', () => {
});

describe('findInstalledTask', () => {
it('should return undefined if the annotations are missing in the metadata', () => {
expect(
findInstalledTask(
sampleCatalogItems,
omit(sampleClusterTaskCatalogItem, 'data.metadata.annotations'),
),
).toBeUndefined();
});

it('should return undefined the catalogItem is not installed through pipeline builder', () => {
expect(findInstalledTask(sampleCatalogItems, sampleTektonHubCatalogItem)).toBeUndefined();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export const getCtaButtonText = (item: CatalogItem, selectedVersion: string): st
export const isInstalledNamespaceTask = (item: CatalogItem) => {
return (
item.data.kind === TaskModel.kind &&
item.data.metadata?.annotations[TektonTaskAnnotation.installedFrom] === TEKTONHUB
item.data.metadata?.annotations?.[TektonTaskAnnotation.installedFrom] === TEKTONHUB
);
};

Expand Down Expand Up @@ -81,7 +81,7 @@ export const findInstalledTask = (items: CatalogItem[], item: CatalogItem): Cata
i.name === item.name &&
item.data.kind !== ClusterTaskModel.kind &&
i.data.kind === TaskModel.kind &&
i.data.metadata?.annotations[TektonTaskAnnotation.installedFrom] === TEKTONHUB,
i.data.metadata?.annotations?.[TektonTaskAnnotation.installedFrom] === TEKTONHUB,
);
};

Expand Down