diff --git a/.changeset/four-fireants-whisper.md b/.changeset/four-fireants-whisper.md new file mode 100644 index 0000000000..4815751e31 --- /dev/null +++ b/.changeset/four-fireants-whisper.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-xcmetrics': patch +--- + +Fix bug where invalid build statuses led to crashes diff --git a/plugins/xcmetrics/src/components/StatusIcon/StatusIcon.test.tsx b/plugins/xcmetrics/src/components/StatusIcon/StatusIcon.test.tsx index a208432f59..0801a34b48 100644 --- a/plugins/xcmetrics/src/components/StatusIcon/StatusIcon.test.tsx +++ b/plugins/xcmetrics/src/components/StatusIcon/StatusIcon.test.tsx @@ -17,6 +17,7 @@ import React from 'react'; import { renderInTestApp } from '@backstage/test-utils'; import { StatusIcon } from './StatusIcon'; +import { BuildStatus } from '../../api'; describe('StatusIcon', () => { it('should render', async () => { @@ -31,4 +32,11 @@ describe('StatusIcon', () => { rendered = await renderInTestApp(); expect(rendered.getByLabelText('Status warning')).toBeInTheDocument(); }); + + it('should render invalid statuses', async () => { + const rendered = await renderInTestApp( + , + ); + expect(rendered.getByLabelText('Status aborted')).toBeInTheDocument(); + }); }); diff --git a/plugins/xcmetrics/src/components/StatusIcon/StatusIcon.tsx b/plugins/xcmetrics/src/components/StatusIcon/StatusIcon.tsx index 610575b817..f28b5e4fe4 100644 --- a/plugins/xcmetrics/src/components/StatusIcon/StatusIcon.tsx +++ b/plugins/xcmetrics/src/components/StatusIcon/StatusIcon.tsx @@ -15,6 +15,7 @@ */ import React from 'react'; import { + StatusAborted, StatusError, StatusOK, StatusWarning, @@ -32,4 +33,4 @@ interface StatusIconProps { } export const StatusIcon = ({ buildStatus }: StatusIconProps) => - STATUS_ICONS[buildStatus]; + STATUS_ICONS[buildStatus] ?? ;