Merge pull request #8362 from ngranander/xcmetrics/bugfix

[XCMetrics] Bugfix: Handle missing Xcode data
This commit is contained in:
Fredrik Adelöw
2021-12-03 19:39:39 +01:00
committed by GitHub
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 backend (before 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,
};