diff --git a/.changeset/beige-worms-deny.md b/.changeset/beige-worms-deny.md new file mode 100644 index 0000000000..2492f35ea6 --- /dev/null +++ b/.changeset/beige-worms-deny.md @@ -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 diff --git a/plugins/github-pull-requests-board/src/components/Card/Card.tsx b/plugins/github-pull-requests-board/src/components/Card/Card.tsx index 6642cdeb06..a84978cb28 100644 --- a/plugins/github-pull-requests-board/src/components/Card/Card.tsx +++ b/plugins/github-pull-requests-board/src/components/Card/Card.tsx @@ -29,7 +29,7 @@ type Props = { isDraft: boolean; repositoryIsArchived: boolean; labels?: Label[]; - status?: Status; + status?: Status[]; }; const Card: FunctionComponent> = ( diff --git a/plugins/github-pull-requests-board/src/components/Card/CardHeader.test.tsx b/plugins/github-pull-requests-board/src/components/Card/CardHeader.test.tsx index 02f8b8c837..47d3713466 100644 --- a/plugins/github-pull-requests-board/src/components/Card/CardHeader.test.tsx +++ b/plugins/github-pull-requests-board/src/components/Card/CardHeader.test.tsx @@ -37,13 +37,15 @@ const props = { name: 'documentation', }, ], - status: { - commit: { - statusCheckRollup: { - state: 'SUCCESS', + status: [ + { + commit: { + statusCheckRollup: { + state: 'SUCCESS', + }, }, }, - }, + ], }; describe('', () => { @@ -65,7 +67,7 @@ describe('', () => { it('finds commit status in PR Card Header', async () => { await renderInTestApp(); 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 () => { diff --git a/plugins/github-pull-requests-board/src/components/Card/CardHeader.tsx b/plugins/github-pull-requests-board/src/components/Card/CardHeader.tsx index 6c8c02da24..28b5acae2f 100644 --- a/plugins/github-pull-requests-board/src/components/Card/CardHeader.tsx +++ b/plugins/github-pull-requests-board/src/components/Card/CardHeader.tsx @@ -32,7 +32,7 @@ type Props = { isDraft: boolean; repositoryIsArchived: boolean; labels?: Label[]; - status?: Status; + status?: Status[]; }; const CardHeader: FunctionComponent = (props: Props) => { @@ -92,7 +92,9 @@ const CardHeader: FunctionComponent = (props: Props) => { Commit Status:{' '} - {status.commit.statusCheckRollup?.state || 'N/A'} + + {status[0]?.commit.statusCheckRollup?.state || 'N/A'} + )} diff --git a/plugins/github-pull-requests-board/src/components/EntityTeamPullRequestsCard/EntityTeamPullRequestsCard.test.tsx b/plugins/github-pull-requests-board/src/components/EntityTeamPullRequestsCard/EntityTeamPullRequestsCard.test.tsx index 28e1c89fc7..c839d72fe6 100644 --- a/plugins/github-pull-requests-board/src/components/EntityTeamPullRequestsCard/EntityTeamPullRequestsCard.test.tsx +++ b/plugins/github-pull-requests-board/src/components/EntityTeamPullRequestsCard/EntityTeamPullRequestsCard.test.tsx @@ -71,7 +71,7 @@ jest.mock('../../hooks/usePullRequestsByTeam', () => { nodes: [], }, commits: { - nodes: status, + nodes: [status], }, isDraft: isDraft, author: { diff --git a/plugins/github-pull-requests-board/src/components/EntityTeamPullRequestsContent/EntityTeamPullRequestsContent.test.tsx b/plugins/github-pull-requests-board/src/components/EntityTeamPullRequestsContent/EntityTeamPullRequestsContent.test.tsx index c38500a1ef..9580b820be 100644 --- a/plugins/github-pull-requests-board/src/components/EntityTeamPullRequestsContent/EntityTeamPullRequestsContent.test.tsx +++ b/plugins/github-pull-requests-board/src/components/EntityTeamPullRequestsContent/EntityTeamPullRequestsContent.test.tsx @@ -71,7 +71,7 @@ jest.mock('../../hooks/usePullRequestsByTeam', () => { nodes: [], }, commits: { - nodes: status, + nodes: [status], }, isDraft: isDraft, author: { diff --git a/plugins/github-pull-requests-board/src/components/PullRequestCard/PullRequestCard.tsx b/plugins/github-pull-requests-board/src/components/PullRequestCard/PullRequestCard.tsx index 59f7892d0e..b8549052a7 100644 --- a/plugins/github-pull-requests-board/src/components/PullRequestCard/PullRequestCard.tsx +++ b/plugins/github-pull-requests-board/src/components/PullRequestCard/PullRequestCard.tsx @@ -30,7 +30,7 @@ type Props = { author: Author; url: string; reviews: Reviews; - status?: Status; + status?: Status[]; repositoryName: string; repositoryIsArchived: boolean; isDraft: boolean; diff --git a/plugins/github-pull-requests-board/src/utils/types.tsx b/plugins/github-pull-requests-board/src/utils/types.tsx index 41ba42c533..bd1261e8d7 100644 --- a/plugins/github-pull-requests-board/src/utils/types.tsx +++ b/plugins/github-pull-requests-board/src/utils/types.tsx @@ -99,7 +99,7 @@ export type PullRequest = { nodes: Reviews; }; commits: { - nodes: Status; + nodes: Status[]; }; mergeable: boolean; state: string;