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 219e587971..a8ef9a9e2c 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 @@ -15,7 +15,7 @@ */ import React from 'react'; import { EntityTeamPullRequestsCard } from '../EntityTeamPullRequestsCard'; -import { PullRequestsColumn } from '../../utils/types'; +import { PullRequestsColumn, Status } from '../../utils/types'; import { render } from '@testing-library/react'; import { fireEvent } from '@testing-library/react'; @@ -39,6 +39,7 @@ jest.mock('../../hooks/usePullRequestsByTeam', () => { repoName: string, isDraft: boolean, isArchived: boolean, + status: Status, ) => { return { id: 'id', @@ -62,6 +63,9 @@ jest.mock('../../hooks/usePullRequestsByTeam', () => { labels: { nodes: [], }, + commits: { + nodes: status, + }, isDraft: isDraft, author: { login: authorLogin, @@ -83,6 +87,13 @@ jest.mock('../../hooks/usePullRequestsByTeam', () => { 'team-repo', false, false, + { + commit: { + statusCheckRollup: { + state: 'FAILURE', + }, + }, + }, ), buildPullRequest( 'non-team-non-draft-is-archive', @@ -90,6 +101,13 @@ jest.mock('../../hooks/usePullRequestsByTeam', () => { 'team-repo', false, true, + { + commit: { + statusCheckRollup: { + state: 'FAILURE', + }, + }, + }, ), buildPullRequest( 'non-team-is-draft-non-archive', @@ -97,6 +115,13 @@ jest.mock('../../hooks/usePullRequestsByTeam', () => { 'team-repo', true, false, + { + commit: { + statusCheckRollup: { + state: 'FAILURE', + }, + }, + }, ), buildPullRequest( 'non-team-is-draft-is-archive', @@ -104,6 +129,13 @@ jest.mock('../../hooks/usePullRequestsByTeam', () => { 'team-repo', true, true, + { + commit: { + statusCheckRollup: { + state: 'SUCCESS', + }, + }, + }, ), buildPullRequest( 'is-team-non-draft-non-archive', @@ -111,6 +143,13 @@ jest.mock('../../hooks/usePullRequestsByTeam', () => { 'non-team-repo', false, false, + { + commit: { + statusCheckRollup: { + state: 'FAILURE', + }, + }, + }, ), buildPullRequest( 'is-team-non-draft-is-archive', @@ -118,6 +157,13 @@ jest.mock('../../hooks/usePullRequestsByTeam', () => { 'non-team-repo', false, true, + { + commit: { + statusCheckRollup: { + state: 'FAILURE', + }, + }, + }, ), buildPullRequest( 'is-team-is-draft-non-archive', @@ -125,6 +171,13 @@ jest.mock('../../hooks/usePullRequestsByTeam', () => { 'non-team-repo', true, false, + { + commit: { + statusCheckRollup: { + state: 'FAILURE', + }, + }, + }, ), buildPullRequest( 'is-team-is-draft-is-archive', @@ -132,6 +185,13 @@ jest.mock('../../hooks/usePullRequestsByTeam', () => { 'non-team-repo', true, true, + { + commit: { + statusCheckRollup: { + state: 'SUCCESS', + }, + }, + }, ), ], }, 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 35c323a4f1..dc02030f47 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 @@ -15,7 +15,7 @@ */ import React from 'react'; import { EntityTeamPullRequestsContent } from '../EntityTeamPullRequestsContent'; -import { PullRequestsColumn } from '../../utils/types'; +import { PullRequestsColumn, Status } from '../../utils/types'; import { render } from '@testing-library/react'; import { fireEvent } from '@testing-library/react'; @@ -33,13 +33,21 @@ jest.mock('../../hooks/useUserRepositoriesAndTeam', () => { }); jest.mock('../../hooks/usePullRequestsByTeam', () => { - const buildPullRequest = ( - prTitle: string, - authorLogin: string, - repoName: string, - isDraft: boolean, - isArchived: boolean, - ) => { + 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, @@ -62,6 +70,9 @@ jest.mock('../../hooks/usePullRequestsByTeam', () => { labels: { nodes: [], }, + commits: { + nodes: status, + }, isDraft: isDraft, author: { login: authorLogin, @@ -77,62 +88,118 @@ jest.mock('../../hooks/usePullRequestsByTeam', () => { { title: 'column', content: [ - buildPullRequest( - 'non-team-non-draft-non-archive', - 'non-team-member', - 'team-repo', - false, - false, - ), - buildPullRequest( - 'non-team-non-draft-is-archive', - 'non-team-member', - 'team-repo', - false, - true, - ), - buildPullRequest( - 'non-team-is-draft-non-archive', - 'non-team-member', - 'team-repo', - true, - false, - ), - buildPullRequest( - 'non-team-is-draft-is-archive', - 'non-team-member', - 'team-repo', - true, - true, - ), - buildPullRequest( - 'is-team-non-draft-non-archive', - 'team-member', - 'non-team-repo', - false, - false, - ), - buildPullRequest( - 'is-team-non-draft-is-archive', - 'team-member', - 'non-team-repo', - false, - true, - ), - buildPullRequest( - 'is-team-is-draft-non-archive', - 'team-member', - 'non-team-repo', - true, - false, - ), - buildPullRequest( - 'is-team-is-draft-is-archive', - 'team-member', - 'non-team-repo', - true, - true, - ), + 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({ + prTitle: 'non-team-non-draft-is-archive', + authorLogin: 'non-team-member', + repoName: 'team-repo', + isDraft: false, + isArchived: true, + status: { + commit: { + statusCheckRollup: { + state: 'FAILURE', + }, + }, + }, + }), + 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({ + prTitle: 'non-team-is-draft-is-archive', + authorLogin: 'non-team-member', + repoName: 'team-repo', + isDraft: true, + isArchived: true, + status: { + commit: { + statusCheckRollup: { + state: 'SUCCESS', + }, + }, + }, + }), + 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({ + prTitle: 'is-team-non-draft-is-archive', + authorLogin: 'team-member', + repoName: 'non-team-repo', + isDraft: false, + isArchived: true, + status: { + commit: { + statusCheckRollup: { + state: 'FAILURE', + }, + }, + }, + }), + 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({ + prTitle: 'is-team-is-draft-is-archive', + authorLogin: 'team-member', + repoName: 'non-team-repo', + isDraft: true, + isArchived: true, + status: { + commit: { + statusCheckRollup: { + state: 'SUCCESS', + }, + }, + }, + }), ], }, ]; @@ -152,7 +219,7 @@ describe('EntityTeamPullRequestsContent', () => { describe('non-team PRs', () => { describe('non-draft PRs', () => { it('should show non-team PRs for un-archived repos when archived option is not checked', async () => { - const { getByText, getAllByText, queryAllByTitle } = await render( + const { getByText, getAllByText, queryAllByTitle } = render( , ); expect(getByText('non-team-non-draft-non-archive')).toBeInTheDocument(); @@ -162,8 +229,9 @@ describe('EntityTeamPullRequestsContent', () => { }); it('should show non-team PRs for archived repos when archived option is checked', async () => { - const { getByText, getAllByText, getByTitle, queryAllByTitle } = - await render(); + const { getByText, getAllByText, getByTitle, queryAllByTitle } = render( + , + ); const archiveToggle = getByTitle('Show archived repos'); fireEvent.click(archiveToggle); expect(getByText('non-team-non-draft-is-archive')).toBeInTheDocument(); @@ -175,8 +243,9 @@ describe('EntityTeamPullRequestsContent', () => { describe('draft PRs', () => { it('should show draft non-team PRs for un-archived repos when archived option is not checked', async () => { - const { getByText, getAllByText, getByTitle, queryAllByTitle } = - await render(); + const { getByText, getAllByText, getByTitle, queryAllByTitle } = render( + , + ); const draftToggle = getByTitle('Show draft PRs'); fireEvent.click(draftToggle); expect(getByText('non-team-is-draft-non-archive')).toBeInTheDocument(); @@ -186,8 +255,9 @@ describe('EntityTeamPullRequestsContent', () => { }); it('should show draft non-team PRs for archived repos when archived option is checked', async () => { - const { getByText, getAllByText, getByTitle, queryAllByTitle } = - await render(); + const { getByText, getAllByText, getByTitle, queryAllByTitle } = render( + , + ); const draftToggle = getByTitle('Show draft PRs'); fireEvent.click(draftToggle); const archiveToggle = getByTitle('Show archived repos'); @@ -203,8 +273,9 @@ describe('EntityTeamPullRequestsContent', () => { describe('team PRs', () => { describe('non-draft PRs', () => { it('should show team PRs for un-archived repos when archived option is not checked', async () => { - const { getByText, getAllByText, getByTitle, queryAllByTitle } = - await render(); + const { getByText, getAllByText, getByTitle, queryAllByTitle } = render( + , + ); const teamToggle = getByTitle('Show PRs from your team'); fireEvent.click(teamToggle); expect(getByText('is-team-non-draft-non-archive')).toBeInTheDocument(); @@ -214,8 +285,9 @@ describe('EntityTeamPullRequestsContent', () => { }); it('should show team PRs for archived repos when archived option is checked', async () => { - const { getByText, getAllByText, getByTitle, queryAllByTitle } = - await render(); + const { getByText, getAllByText, getByTitle, queryAllByTitle } = render( + , + ); const teamToggle = getByTitle('Show PRs from your team'); fireEvent.click(teamToggle); const archiveToggle = getByTitle('Show archived repos'); @@ -229,8 +301,9 @@ describe('EntityTeamPullRequestsContent', () => { describe('draft PRs', () => { it('should show draft team PRs for un-archived repos when archived option is not checked', async () => { - const { getByText, getAllByText, getByTitle, queryAllByTitle } = - await render(); + const { getByText, getAllByText, getByTitle, queryAllByTitle } = render( + , + ); const teamToggle = getByTitle('Show PRs from your team'); fireEvent.click(teamToggle); const draftToggle = getByTitle('Show draft PRs'); @@ -242,8 +315,9 @@ describe('EntityTeamPullRequestsContent', () => { }); it('should show draft team PRs for archived repos when archived option is checked', async () => { - const { getByText, getAllByText, getByTitle, queryAllByTitle } = - await render(); + const { getByText, getAllByText, getByTitle, queryAllByTitle } = render( + , + ); const teamToggle = getByTitle('Show PRs from your team'); fireEvent.click(teamToggle); const draftToggle = getByTitle('Show draft PRs');