feat: adds last commit status to PR cardheader component and changeset

Signed-off-by: Josh Uvi <joshuauvbiekpahor@gmail.com>
This commit is contained in:
Josh Uvi
2024-02-13 12:57:29 +00:00
parent 59d1a43b46
commit 6899c2dcf5
6 changed files with 97 additions and 78 deletions
@@ -37,6 +37,13 @@ const props = {
name: 'documentation',
},
],
status: {
commit: {
statusCheckRollup: {
state: 'SUCCESS',
},
},
},
};
describe('<CardHeader/>', () => {
@@ -54,4 +61,10 @@ describe('<CardHeader/>', () => {
await renderInTestApp(<CardHeader {...propsWithNoLabels} />);
expect(screen.queryByRole('listitem')).not.toBeInTheDocument();
});
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();
});
});
@@ -48,7 +48,7 @@ const CardHeader: FunctionComponent<Props> = (props: Props) => {
isDraft,
repositoryIsArchived,
labels,
status: commitStatus,
status,
} = props;
return (
@@ -91,7 +91,7 @@ const CardHeader: FunctionComponent<Props> = (props: Props) => {
<Box display="flex" alignItems="center" flexWrap="wrap" paddingTop={1}>
<Typography variant="body2" component="p">
Commit Status:{' '}
<strong>{commitStatus.commit.statusCheckRollup.state}</strong>
<strong>{status.commit.statusCheckRollup.state}</strong>
</Typography>
</Box>
{labels && (
@@ -33,14 +33,21 @@ jest.mock('../../hooks/useUserRepositoriesAndTeam', () => {
});
jest.mock('../../hooks/usePullRequestsByTeam', () => {
const buildPullRequest = (
prTitle: string,
authorLogin: string,
repoName: string,
isDraft: boolean,
isArchived: boolean,
status: Status,
) => {
const buildPullRequest = ({
prTitle,
authorLogin,
repoName,
isDraft,
isArchived,
status,
}: {
prTitle: string;
authorLogin: string;
repoName: string;
isDraft: boolean;
isArchived: boolean;
status: Status;
}) => {
return {
id: 'id',
title: prTitle,
@@ -81,118 +88,118 @@ jest.mock('../../hooks/usePullRequestsByTeam', () => {
{
title: 'column',
content: [
buildPullRequest(
'non-team-non-draft-non-archive',
'non-team-member',
'team-repo',
false,
false,
{
buildPullRequest({
prTitle: 'non-team-non-draft-non-archive',
authorLogin: 'non-team-member',
repoName: 'team-repo',
isDraft: false,
isArchived: false,
status: {
commit: {
statusCheckRollup: {
state: 'FAILURE',
},
},
},
),
buildPullRequest(
'non-team-non-draft-is-archive',
'non-team-member',
'team-repo',
false,
true,
{
}),
buildPullRequest({
prTitle: 'non-team-non-draft-is-archive',
authorLogin: 'non-team-member',
repoName: 'team-repo',
isDraft: false,
isArchived: true,
status: {
commit: {
statusCheckRollup: {
state: 'FAILURE',
},
},
},
),
buildPullRequest(
'non-team-is-draft-non-archive',
'non-team-member',
'team-repo',
true,
false,
{
}),
buildPullRequest({
prTitle: 'non-team-is-draft-non-archive',
authorLogin: 'non-team-member',
repoName: 'team-repo',
isDraft: true,
isArchived: false,
status: {
commit: {
statusCheckRollup: {
state: 'FAILURE',
},
},
},
),
buildPullRequest(
'non-team-is-draft-is-archive',
'non-team-member',
'team-repo',
true,
true,
{
}),
buildPullRequest({
prTitle: 'non-team-is-draft-is-archive',
authorLogin: 'non-team-member',
repoName: 'team-repo',
isDraft: true,
isArchived: true,
status: {
commit: {
statusCheckRollup: {
state: 'SUCCESS',
},
},
},
),
buildPullRequest(
'is-team-non-draft-non-archive',
'team-member',
'non-team-repo',
false,
false,
{
}),
buildPullRequest({
prTitle: 'is-team-non-draft-non-archive',
authorLogin: 'team-member',
repoName: 'non-team-repo',
isDraft: false,
isArchived: false,
status: {
commit: {
statusCheckRollup: {
state: 'FAILURE',
},
},
},
),
buildPullRequest(
'is-team-non-draft-is-archive',
'team-member',
'non-team-repo',
false,
true,
{
}),
buildPullRequest({
prTitle: 'is-team-non-draft-is-archive',
authorLogin: 'team-member',
repoName: 'non-team-repo',
isDraft: false,
isArchived: true,
status: {
commit: {
statusCheckRollup: {
state: 'FAILURE',
},
},
},
),
buildPullRequest(
'is-team-is-draft-non-archive',
'team-member',
'non-team-repo',
true,
false,
{
}),
buildPullRequest({
prTitle: 'is-team-is-draft-non-archive',
authorLogin: 'team-member',
repoName: 'non-team-repo',
isDraft: true,
isArchived: false,
status: {
commit: {
statusCheckRollup: {
state: 'FAILURE',
},
},
},
),
buildPullRequest(
'is-team-is-draft-is-archive',
'team-member',
'non-team-repo',
true,
true,
{
}),
buildPullRequest({
prTitle: 'is-team-is-draft-is-archive',
authorLogin: 'team-member',
repoName: 'non-team-repo',
isDraft: true,
isArchived: true,
status: {
commit: {
statusCheckRollup: {
state: 'SUCCESS',
},
},
},
),
}),
],
},
];
@@ -114,6 +114,7 @@ const EntityTeamPullRequestsCard = (props: EntityTeamPullRequestsCardProps) => {
repository,
isDraft,
labels,
commits,
},
index,
) =>
@@ -137,6 +138,7 @@ const EntityTeamPullRequestsCard = (props: EntityTeamPullRequestsCardProps) => {
repositoryIsArchived={repository.isArchived}
isDraft={isDraft}
labels={labels.nodes}
status={commits.nodes}
/>
),
)}
@@ -87,9 +87,6 @@ const EntityTeamPullRequestsContent = (
return <Progress />;
}
// eslint-disable-next-line no-console
console.log('pull - ', pullRequests);
return (
<Grid container spacing={2}>
{pullRequests.length ? (
@@ -84,7 +84,7 @@ export type Label = {
export type Status = {
commit: {
statusCheckRollup: {
state: 'SUCCESS' | 'FAILURE' | 'ERROR' | 'EXPECTED' | 'PENDING';
state: string;
};
};
};