|
| 1 | +import RelevantRunsDataSource_RunsByCommitShas from '../fixtures/gql-RelevantRunsDataSource_RunsByCommitShas.json' |
| 2 | + |
| 3 | +Cypress.on('window:before:load', (win) => { |
| 4 | + win.__CYPRESS_GQL_NO_SOCKET__ = 'true' |
| 5 | +}) |
| 6 | + |
| 7 | +// These mocks all the responses so we can get deterministic |
| 8 | +// results to test the debug page. |
| 9 | +// The JSON fixtures were generated by using a real app and capturing |
| 10 | +// the responses. |
| 11 | +describe('App - Debug Page', () => { |
| 12 | + beforeEach(() => { |
| 13 | + cy.scaffoldProject('cypress-in-cypress') |
| 14 | + cy.openProject('cypress-in-cypress') |
| 15 | + cy.startAppServer('component') |
| 16 | + |
| 17 | + cy.loginUser() |
| 18 | + cy.withCtx((ctx) => { |
| 19 | + ctx.git?.__setGitHashesForTesting(['commit1', 'commit2']) |
| 20 | + }) |
| 21 | + |
| 22 | + cy.remoteGraphQLIntercept((obj, _testState, options) => { |
| 23 | + if (obj.operationName === 'RelevantRunsDataSource_RunsByCommitShas') { |
| 24 | + obj.result.data = options.RelevantRunsDataSource_RunsByCommitShas.data |
| 25 | + } |
| 26 | + |
| 27 | + return obj.result |
| 28 | + }, { RelevantRunsDataSource_RunsByCommitShas }) |
| 29 | + }) |
| 30 | + |
| 31 | + it('all tests passed', () => { |
| 32 | + // This mocks all the responses so we can get deterministic |
| 33 | + // results to test the debug page. |
| 34 | + cy.intercept('POST', '/__cypress/graphql/query-Debug', { |
| 35 | + fixture: 'debug-Passing/gql-Debug.json', |
| 36 | + }) |
| 37 | + |
| 38 | + cy.intercept('POST', '/__cypress/graphql/query-CloudViewerAndProject_RequiredData', { |
| 39 | + fixture: 'debug-Passing/gql-CloudViewerAndProject_RequiredData.json', |
| 40 | + }) |
| 41 | + |
| 42 | + cy.intercept('POST', '/__cypress/graphql/query-MainAppQuery', { |
| 43 | + fixture: 'debug-Passing/gql-MainAppQuery.json', |
| 44 | + }) |
| 45 | + |
| 46 | + cy.intercept('POST', '/__cypress/graphql/query-SideBarNavigationContainer', { |
| 47 | + fixture: 'debug-Passing/gql-SideBarNavigationContainer', |
| 48 | + }) |
| 49 | + |
| 50 | + cy.intercept('POST', '/__cypress/graphql/query-HeaderBar_HeaderBarQuery', { |
| 51 | + fixture: 'debug-Passing/gql-HeaderBar_HeaderBarQuery', |
| 52 | + }) |
| 53 | + |
| 54 | + cy.intercept('POST', '/__cypress/graphql/query-SpecsPageContainer', { |
| 55 | + fixture: 'debug-Passing/gql-SpecsPageContainer', |
| 56 | + }) |
| 57 | + |
| 58 | + cy.visitApp() |
| 59 | + |
| 60 | + cy.findByTestId('sidebar-link-debug-page').click() |
| 61 | + cy.findByTestId('debug-container').should('be.visible') |
| 62 | + |
| 63 | + cy.findByTestId('header-top').contains('update projectId') |
| 64 | + cy.findByTestId('debug-header-dashboard-link') |
| 65 | + .contains('View in Cypress Cloud') |
| 66 | + .should('have.attr', 'href', 'https://cloud.cypress.io/projects/7p5uce/runs/2') |
| 67 | + |
| 68 | + cy.findByTestId('debug-runNumber-PASSED').contains('#2') |
| 69 | + cy.findByTestId('debug-commitsAhead').contains('You are 1 commit ahead') |
| 70 | + |
| 71 | + cy.findByTestId('metadata').within(() => { |
| 72 | + cy.get('[title="passed"]').contains('2') |
| 73 | + cy.get('[title="failed"]').contains('0') |
| 74 | + cy.get('[title="skipped"]').contains('0') |
| 75 | + cy.get('[title="pending"]').contains('2') |
| 76 | + cy.findByTestId('debug-header-branch').contains('main') |
| 77 | + cy.findByTestId('debug-header-commitHash').contains('e9d176f') |
| 78 | + cy.findByTestId('debug-header-author').contains('Lachlan Miller') |
| 79 | + cy.findByTestId('debug-header-createdAt').contains('01:18') |
| 80 | + }) |
| 81 | + |
| 82 | + cy.findByTestId('debug-passed').contains('Well Done!') |
| 83 | + cy.findByTestId('debug-passed').contains('All your tests passed.') |
| 84 | + cy.findByLabelText('Relevant run passed').should('be.visible').contains('0') |
| 85 | + cy.findByTestId('run-failures').should('not.exist') |
| 86 | + }) |
| 87 | + |
| 88 | + it('shows information about a failed spec', () => { |
| 89 | + cy.intercept('POST', '/__cypress/graphql/query-Debug', { |
| 90 | + fixture: 'debug-Failing/gql-Debug.json', |
| 91 | + }) |
| 92 | + |
| 93 | + cy.intercept('POST', '/__cypress/graphql/query-CloudViewerAndProject_RequiredData', { |
| 94 | + fixture: 'debug-Failing/gql-CloudViewerAndProject_RequiredData.json', |
| 95 | + }) |
| 96 | + |
| 97 | + cy.intercept('POST', '/__cypress/graphql/query-MainAppQuery', { |
| 98 | + fixture: 'debug-Failing/gql-MainAppQuery.json', |
| 99 | + }) |
| 100 | + |
| 101 | + cy.intercept('POST', '/__cypress/graphql/query-SideBarNavigationContainer', { |
| 102 | + fixture: 'debug-Failing/gql-SideBarNavigationContainer', |
| 103 | + }) |
| 104 | + |
| 105 | + cy.intercept('POST', '/__cypress/graphql/query-HeaderBar_HeaderBarQuery', { |
| 106 | + fixture: 'debug-Failing/gql-HeaderBar_HeaderBarQuery', |
| 107 | + }) |
| 108 | + |
| 109 | + cy.intercept('POST', '/__cypress/graphql/query-SpecsPageContainer', { |
| 110 | + fixture: 'debug-Failing/gql-SpecsPageContainer', |
| 111 | + }) |
| 112 | + |
| 113 | + cy.visitApp() |
| 114 | + |
| 115 | + cy.findByTestId('sidebar-link-debug-page').click() |
| 116 | + cy.findByTestId('debug-container').should('be.visible') |
| 117 | + |
| 118 | + cy.findByTestId('header-top').contains('chore: testing cypress') |
| 119 | + cy.findByTestId('debug-header-dashboard-link') |
| 120 | + .contains('View in Cypress Cloud') |
| 121 | + .should('have.attr', 'href', 'https://cloud.cypress.io/projects/vgqrwp/runs/136') |
| 122 | + |
| 123 | + cy.findByLabelText('Relevant run had 1 test failure').should('be.visible').contains('1') |
| 124 | + |
| 125 | + cy.findByTestId('debug-runNumber-FAILED').contains('#136') |
| 126 | + cy.findByTestId('debug-commitsAhead').contains('You are 1 commit ahead') |
| 127 | + |
| 128 | + cy.findByTestId('metadata').within(() => { |
| 129 | + cy.get('[title="passed"]').contains('1') |
| 130 | + cy.get('[title="failed"]').contains('1') |
| 131 | + cy.get('[title="skipped"]').contains('0') |
| 132 | + cy.get('[title="pending"]').contains('0') |
| 133 | + cy.findByTestId('debug-header-branch').contains('main') |
| 134 | + cy.findByTestId('debug-header-commitHash').contains('commit1') |
| 135 | + cy.findByTestId('debug-header-author').contains('Lachlan Miller') |
| 136 | + cy.findByTestId('debug-header-createdAt').contains('00:19') |
| 137 | + }) |
| 138 | + |
| 139 | + cy.findByTestId('spec-contents').within(() => { |
| 140 | + cy.contains('src/components/InfoPanel/InfoPanel.cy.ts') |
| 141 | + cy.findByTestId('metaData-Results-spec-duration').contains('00:04') |
| 142 | + cy.findByTestId('metaData-Results-operating-system').contains('Linux Ubuntu') |
| 143 | + cy.findByTestId('metaData-Results-browser').contains('Electron 106') |
| 144 | + cy.findByTestId('metaData-Results-testing-type').contains('Component') |
| 145 | + }) |
| 146 | + |
| 147 | + cy.findByTestId('test-row').contains('InfoPanel') |
| 148 | + cy.findByTestId('test-row').contains('renders') |
| 149 | + cy.findByTestId('run-failures').should('exist').should('have.attr', 'href', '#/specs/runner?file=src/components/InfoPanel/InfoPanel.cy.ts&mode=debug') |
| 150 | + }) |
| 151 | +}) |
0 commit comments