Merge pull request #24082 from gilfthde/bugfix/commit-status-array

Fix `plugin-github-pull-requests-board` failing to render because commit status returned by GraphQL query is a list
This commit is contained in:
Fredrik Adelöw
2024-04-10 13:06:19 +02:00
committed by GitHub
8 changed files with 22 additions and 13 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-github-pull-requests-board': minor
---
Fixed bug in CardHeader not expecting commit status as an array as returned by GraphQL
@@ -29,7 +29,7 @@ type Props = {
isDraft: boolean;
repositoryIsArchived: boolean;
labels?: Label[];
status?: Status;
status?: Status[];
};
const Card: FunctionComponent<PropsWithChildren<Props>> = (
@@ -37,13 +37,15 @@ const props = {
name: 'documentation',
},
],
status: {
commit: {
statusCheckRollup: {
state: 'SUCCESS',
status: [
{
commit: {
statusCheckRollup: {
state: 'SUCCESS',
},
},
},
},
],
};
describe('<CardHeader/>', () => {
@@ -65,7 +67,7 @@ describe('<CardHeader/>', () => {
it('finds commit status in PR Card Header', async () => {
await renderInTestApp(<CardHeader {...props} />);
expect(screen.getByText('Commit Status:')).toBeInTheDocument();
expect(props.status?.commit.statusCheckRollup.state).toBeTruthy();
expect(props.status[0].commit.statusCheckRollup.state).toBeTruthy();
});
it('does not find commit status in PR Card Header when PR does not include status', async () => {
@@ -32,7 +32,7 @@ type Props = {
isDraft: boolean;
repositoryIsArchived: boolean;
labels?: Label[];
status?: Status;
status?: Status[];
};
const CardHeader: FunctionComponent<Props> = (props: Props) => {
@@ -92,7 +92,9 @@ const CardHeader: FunctionComponent<Props> = (props: Props) => {
<Box display="flex" alignItems="center" flexWrap="wrap" paddingTop={1}>
<Typography variant="body2" component="p">
Commit Status:{' '}
<strong>{status.commit.statusCheckRollup?.state || 'N/A'}</strong>
<strong>
{status[0]?.commit.statusCheckRollup?.state || 'N/A'}
</strong>
</Typography>
</Box>
)}
@@ -71,7 +71,7 @@ jest.mock('../../hooks/usePullRequestsByTeam', () => {
nodes: [],
},
commits: {
nodes: status,
nodes: [status],
},
isDraft: isDraft,
author: {
@@ -71,7 +71,7 @@ jest.mock('../../hooks/usePullRequestsByTeam', () => {
nodes: [],
},
commits: {
nodes: status,
nodes: [status],
},
isDraft: isDraft,
author: {
@@ -30,7 +30,7 @@ type Props = {
author: Author;
url: string;
reviews: Reviews;
status?: Status;
status?: Status[];
repositoryName: string;
repositoryIsArchived: boolean;
isDraft: boolean;
@@ -99,7 +99,7 @@ export type PullRequest = {
nodes: Reviews;
};
commits: {
nodes: Status;
nodes: Status[];
};
mergeable: boolean;
state: string;