From 2bfeb5302caf6f8bc8d8943dae0b563f05193bfb Mon Sep 17 00:00:00 2001 From: Mark Noonan Date: Mon, 13 Feb 2023 11:12:25 -0500 Subject: [PATCH] fix: implement new graphql fields for spec counts (#25757) Co-authored-by: Stokes Player Co-authored-by: Mike Plummer --- cli/CHANGELOG.md | 1 + packages/app/src/debug/DebugContainer.cy.tsx | 47 +++++++++++++ packages/app/src/debug/DebugContainer.vue | 10 +-- .../src/sources/RelevantRunSpecsDataSource.ts | 61 ++++++++--------- .../RelevantRunSpecsDataSource.spec.ts | 68 +++++++++++++++++++ .../unit/sources/fixtures/graphqlFixtures.ts | 38 ++++++++++- packages/graphql/schemas/cloud.graphql | 50 ++++++++++++++ packages/graphql/schemas/schema.graphql | 46 +++++++++++++ packages/graphql/test/stubCloudTypes.ts | 6 ++ 9 files changed, 290 insertions(+), 37 deletions(-) create mode 100644 packages/data-context/test/unit/sources/RelevantRunSpecsDataSource.spec.ts diff --git a/cli/CHANGELOG.md b/cli/CHANGELOG.md index 8fc5ec96fa00..899a0ead4532 100644 --- a/cli/CHANGELOG.md +++ b/cli/CHANGELOG.md @@ -7,6 +7,7 @@ _Released 02/14/2023 (PENDING)_ - Fixed an issue with the Cloud project selection modal not showing the correct prompts. Fixes [#25520](https://github.com/cypress-io/cypress/issues/25520). - Fixed an issue in middleware where error-handling code could itself generate an error and fail to report the original issue. Fixes [#22825](https://github.com/cypress-io/cypress/issues/22825). +- Fixed an issue that could cause the Debug page to display a different number of specs for in-progress runs than shown in Cypress Cloud. Fixes [#25647](https://github.com/cypress-io/cypress/issues/25647). **Features:** diff --git a/packages/app/src/debug/DebugContainer.cy.tsx b/packages/app/src/debug/DebugContainer.cy.tsx index 0a995496efe8..797b029faad5 100644 --- a/packages/app/src/debug/DebugContainer.cy.tsx +++ b/packages/app/src/debug/DebugContainer.cy.tsx @@ -241,6 +241,8 @@ describe('', () => { result.currentProject.cloudProject.runByNumber = { ...CloudRunStubs.running, runNumber: 1, + completedInstanceCount: 2, + totalInstanceCount: 3, } as typeof test } }, @@ -255,6 +257,51 @@ describe('', () => { }) }) + it('does not render DebugPendingRunSplash and DebugNewRelevantRunBar at the same time', () => { + cy.mountFragment(DebugSpecsFragmentDoc, { + variableTypes: DebugSpecVariableTypes, + variables: { + hasNextRun: false, + runNumber: 1, + nextRunNumber: -1, + }, + onResult: (result) => { + if (result.currentProject?.cloudProject?.__typename === 'CloudProject') { + const test = result.currentProject.cloudProject.runByNumber + + // Testing this to confirm we are "making impossible states impossible" in the UI, + // and document the expectation in this scenario. For clarity, + // we do not expect a 'RUNNING` current and next run at the same time, so + // the data below represents an invalid state. + + result.currentProject.cloudProject.runByNumber = { + ...CloudRunStubs.running, + runNumber: 1, + completedInstanceCount: 2, + totalInstanceCount: 3, + } as typeof test + + result.currentProject.cloudProject.nextRun = { + ...CloudRunStubs.running, + runNumber: 1, + completedInstanceCount: 5, + totalInstanceCount: 6, + } as typeof test + } + }, + render: (gqlVal) => , + }) + + cy.findByTestId('debug-header').should('be.visible') + cy.findByTestId('debug-pending-splash') + .should('be.visible') + .within(() => { + cy.findByTestId('debug-pending-counts').should('have.text', '0 of 0 specs completed') + }) + + cy.findByTestId('newer-relevant-run').should('not.exist') + }) + it('renders specs and tests when completed run available', () => { cy.mountFragment(DebugSpecsFragmentDoc, { variableTypes: DebugSpecVariableTypes, diff --git a/packages/app/src/debug/DebugContainer.vue b/packages/app/src/debug/DebugContainer.vue index 6c5371a005da..01cbacbdc756 100644 --- a/packages/app/src/debug/DebugContainer.vue +++ b/packages/app/src/debug/DebugContainer.vue @@ -28,15 +28,15 @@ :gql="run" :commits-ahead="props.commitsAhead" /> - - + +