Skip to content

Commit f9dcbc3

Browse files
committed
Integ test: PR badge shows failed status immediately
Adds integration (integ) Cypress test to verify that the PR checks badge on the branch card updates immediately to show failure if any PR CI check fails, as introduced in the previous commit. Covers review creation, badge display, and instant badge failure visual feedback.
1 parent 86474d6 commit f9dcbc3

File tree

1 file changed

+148
-0
lines changed

1 file changed

+148
-0
lines changed

apps/desktop/cypress/e2e/review.cy.ts

Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -826,4 +826,152 @@ describe('Review - stacked branches', () => {
826826
cy.getByTestId('pr-checks-badge-reduced').should('be.visible');
827827
});
828828
});
829+
830+
it('Should fail fast when checking for multiple checks', () => {
831+
const data: CustomChecksData = {
832+
total_count: 2,
833+
check_runs: [
834+
{
835+
id: 1,
836+
started_at: new Date(Date.now() - 10000).toISOString(),
837+
conclusion: null,
838+
completed_at: null,
839+
head_sha: 'abc123',
840+
name: 'CI Check 1',
841+
status: 'in_progress'
842+
},
843+
{
844+
id: 2,
845+
started_at: new Date(Date.now() - 10000).toISOString(),
846+
conclusion: null,
847+
completed_at: null,
848+
head_sha: 'abc123',
849+
name: 'CI Check 2',
850+
status: 'in_progress'
851+
}
852+
]
853+
};
854+
855+
const oneCheckFailed: CustomChecksData = {
856+
total_count: 1,
857+
check_runs: [
858+
{
859+
...data.check_runs[0]
860+
},
861+
{
862+
...data.check_runs[1],
863+
status: 'completed',
864+
conclusion: 'failure',
865+
completed_at: new Date().toISOString()
866+
}
867+
]
868+
};
869+
870+
let requestCount = 0;
871+
872+
cy.intercept(
873+
{
874+
method: 'GET',
875+
url: 'https://api.github.com/repos/example/repo/commits/check-runs'
876+
},
877+
(req) => {
878+
requestCount++;
879+
if (requestCount > 2) {
880+
req.reply({
881+
statusCode: 200,
882+
body: oneCheckFailed
883+
});
884+
return;
885+
}
886+
887+
req.reply({
888+
statusCode: 200,
889+
body: data
890+
});
891+
}
892+
).as('getChecksWithActualChecks');
893+
894+
const prTitle = 'Test PR Title';
895+
const prDescription = 'Test PR Description';
896+
897+
// Open the top branch.
898+
cy.getByTestId('branch-header', mockBackend.topBranchName).should('be.visible').click();
899+
900+
// The PR card should not be visible for the top branch.
901+
cy.getByTestId('stacked-pull-request-card').should('not.exist');
902+
903+
// Now, open a review for the top branch.
904+
cy.getByDataValue('series-name', mockBackend.topBranchName).within(() => {
905+
cy.getByTestId('create-review-button')
906+
.should('have.length', 1)
907+
.should('be.visible')
908+
.should('be.enabled')
909+
.click();
910+
});
911+
912+
// The Review Drawer should be visible.
913+
cy.getByTestId('create-review-box').should('be.visible').should('have.length', 1);
914+
915+
// Since this branch has a single commit, the commit message should be pre-filled.
916+
// Update both.
917+
cy.getByTestId('create-review-box-title-input')
918+
.should('be.visible')
919+
.should('be.enabled')
920+
.should('have.value', mockBackend.getCommitTitle(mockBackend.topBranchName))
921+
.clear()
922+
.type(prTitle);
923+
924+
cy.getByTestId('create-review-box-description-input')
925+
.should('be.visible')
926+
.should('contain', mockBackend.getCommitMessage(mockBackend.topBranchName))
927+
.click()
928+
.clear()
929+
.type(prDescription);
930+
931+
// The Create Review button should be visible.
932+
// Click it.
933+
cy.getByTestId('create-review-box-create-button')
934+
.should('be.visible')
935+
.should('be.enabled')
936+
.click();
937+
938+
// The PR card should be visible.
939+
cy.getByTestId('stacked-pull-request-card').should('be.visible');
940+
941+
cy.getByTestId('stacked-pull-request-card').within(() => {
942+
cy.getByTestId('pr-status-badge').should('be.visible');
943+
cy.getByDataValue('pr-status', 'open').should('be.visible');
944+
cy.getByTestId('pr-checks-badge').should('be.visible').contains('Checks running');
945+
});
946+
947+
cy.getByTestId('branch-card', mockBackend.topBranchName)
948+
.should('be.visible')
949+
.within(() => {
950+
cy.getByTestId('pr-checks-badge-reduced').should('be.visible');
951+
});
952+
953+
cy.wait(
954+
['@getChecksWithActualChecks', '@getChecksWithActualChecks', '@getChecksWithActualChecks'],
955+
{ timeout: 11000 }
956+
).spread((first, second, third) => {
957+
expect(first.response.body).to.deep.equal(data);
958+
expect(second.response.body).to.deep.equal(data);
959+
expect(third.response.body).to.deep.equal(oneCheckFailed);
960+
});
961+
962+
cy.getByTestId('branch-card', mockBackend.topBranchName)
963+
.should('be.visible')
964+
.within(() => {
965+
cy.getByTestId('pr-checks-badge-reduced').should('be.visible');
966+
});
967+
968+
cy.getByTestId('stacked-pull-request-card').within(() => {
969+
cy.getByTestId('pr-status-badge').should('be.visible');
970+
cy.getByDataValue('pr-status', 'open').should('be.visible');
971+
cy.getByTestId('pr-checks-badge')
972+
.should('be.visible')
973+
.contains('Checks failed')
974+
.trigger('mouseover');
975+
});
976+
});
829977
});

0 commit comments

Comments
 (0)