Merge pull request #8313 from ngranander/xcmetrics/bugfix
[XCMetrics] Handle invalid build statuses
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/plugin-xcmetrics': patch
|
||||
---
|
||||
|
||||
Fix bug where invalid build statuses led to crashes
|
||||
@@ -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(<StatusIcon buildStatus="stopped" />);
|
||||
expect(rendered.getByLabelText('Status warning')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('should render invalid statuses', async () => {
|
||||
const rendered = await renderInTestApp(
|
||||
<StatusIcon buildStatus={'invalid' as BuildStatus} />,
|
||||
);
|
||||
expect(rendered.getByLabelText('Status aborted')).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -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] ?? <StatusAborted />;
|
||||
|
||||
Reference in New Issue
Block a user