Handle missing Xcode data from old versions of XCMetrics

Signed-off-by: Niklas Granander <ngranander@spotify.com>
This commit is contained in:
Niklas Granander
2021-12-03 16:10:55 +01:00
parent f046799197
commit 343ef34599
4 changed files with 21 additions and 2 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-xcmetrics': patch
---
Handle a case where Xcode data from XCMetrics version < 0.0.8 could be missing
+1 -1
View File
@@ -163,7 +163,7 @@ export type Xcode = {
export type BuildResponse = {
build: Build;
targets: Target[];
xcode: Xcode;
xcode?: Xcode; // Can be undefined if XCMetrics version < v0.0.8
};
export type BuildFilters = {
@@ -51,6 +51,20 @@ describe('BuildDetails', () => {
).toBeInTheDocument();
expect(rendered.getByText(client.mockBuild.schema)).toBeInTheDocument();
});
it('should render if xcode data is not present', async () => {
const rendered = await renderInTestApp(
<TestApiProvider apis={[[xcmetricsApiRef, client.XcmetricsClient]]}>
<BuildDetails
buildData={{ ...client.mockBuildResponse, xcode: undefined }}
/>
</TestApiProvider>,
);
expect(
rendered.getByText('Xcode').parentNode?.childNodes[1].textContent,
).toEqual('Unknown');
});
});
describe('BuildDetails with request', () => {
@@ -78,7 +78,7 @@ export const BuildDetails = ({
{formatStatus(build.buildStatus)}
</>
),
xcode: `${xcode.version} (${xcode.buildNumber})`,
xcode: xcode ? `${xcode.version} (${xcode.buildNumber})` : 'Unknown',
CI: build.isCi,
};