Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: fix flaky tests #26505

Merged
merged 11 commits into from
Apr 17, 2023
2 changes: 1 addition & 1 deletion .circleci/workflows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ windowsWorkflowFilters: &windows-workflow-filters
or:
- equal: [ develop, << pipeline.git.branch >> ]
# use the following branch as well to ensure that v8 snapshot cache updates are fully tested
- equal: [ 'lmiller/fixing-vite-windows', << pipeline.git.branch >> ]
- equal: [ 'windows-flake', << pipeline.git.branch >> ]
- equal: [ 'update-v8-snapshot-cache-on-develop', << pipeline.git.branch >> ]
- matches:
pattern: /^release\/\d+\.\d+\.\d+$/
Expand Down
2 changes: 1 addition & 1 deletion packages/app/cypress/e2e/runs.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ describe('App: Runs', { viewportWidth: 1200 }, () => {
moveToRunsPage()
cy.findByText(defaultMessages.runs.connect.buttonProject).click()
cy.contains('button', defaultMessages.runs.connect.modal.selectProject.createProject).click()
cy.findByText(defaultMessages.runs.connectSuccessAlert.title).should('be.visible')
cy.findByText(defaultMessages.runs.connectSuccessAlert.title, { timeout: 10000 }).should('be.visible')

cy.withCtx(async (ctx) => {
const config = await ctx.project.getConfig()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ describe('Config files error handling', () => {

cy.findByRole('button', { name: 'Try again' }).click()

cy.get('h1').should('contain', 'Welcome to Cypress')
cy.get('h1', { timeout: 10000 }).should('contain', 'Welcome to Cypress')
})

it('shows the upgrade screen if there is a legacy config file', () => {
Expand Down Expand Up @@ -92,7 +92,7 @@ describe('Config files error handling', () => {

cy.findByRole('button', { name: 'Try again' }).click()

cy.get('h1').should('contain', 'Choose a browser')
cy.get('h1', { timeout: 10000 }).should('contain', 'Choose a browser')
})
})

Expand Down Expand Up @@ -279,7 +279,7 @@ describe('setupNodeEvents', () => {

cy.findByRole('button', { name: 'Try again' }).click()

cy.get('h1').should('contain', 'Choose a browser')
cy.get('h1', { timeout: 10000 }).should('contain', 'Choose a browser')
})

it('handles multiple config errors and then recovers', () => {
Expand Down Expand Up @@ -310,7 +310,7 @@ describe('setupNodeEvents', () => {
})

cy.findByRole('button', { name: 'Try again' }).click()
cy.get('h1').should('contain', 'Choose a browser')
cy.get('h1', { timeout: 10000 }).should('contain', 'Choose a browser')
cy.get('[data-cy="alert"]').should('contain', 'Warning: Cannot Connect Base Url Warning')
})

Expand Down
2 changes: 1 addition & 1 deletion packages/launchpad/cypress/e2e/config-warning.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ describe('component testing dependency warnings', () => {
cy.contains('vueclivue3-configured').click()
cy.get('[data-cy="warning-alert"]').should('not.exist')
cy.get('a').contains('Projects').click()
cy.get('[data-cy-testingtype="component"]').click()
cy.get('[data-cy-testingtype="component"]', { timeout: 10000 }).click()

// Wait until launch browser screen and assert warning does not exist
cy.contains('Choose a browser', { timeout: 12000 })
Expand Down
4 changes: 2 additions & 2 deletions packages/launchpad/cypress/e2e/migration.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ function finishMigrationAndContinue () {
}

function checkOutcome () {
cy.contains('Welcome to Cypress!').should('be.visible')
cy.contains('Welcome to Cypress!', { timeout: 10000 }).should('be.visible')
}

function runAutoRename () {
Expand Down Expand Up @@ -95,7 +95,7 @@ describe('global mode', () => {
cy.contains('migration-e2e-export-default').click()

// rename integration->e2e
cy.get(renameAutoStep).should('exist')
cy.get(renameAutoStep, { timeout: 10000 }).should('exist')
cy.get(renameManualStep).should('not.exist')

// cypress/support/index.ts -> cypress/support/e2e.ts
Expand Down
15 changes: 7 additions & 8 deletions packages/launchpad/cypress/e2e/project-setup.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -556,8 +556,7 @@ describe('Launchpad: Setup Project', () => {
})
})

// TODO: fix flaky test https://github.com/cypress-io/cypress/issues/23153
describe('Command for package managers', { retries: 15 }, () => {
describe('Command for package managers', () => {
it('makes the right command for yarn', () => {
scaffoldAndOpenProject('pristine-yarn')

Expand All @@ -566,7 +565,7 @@ describe('Launchpad: Setup Project', () => {
cy.get('[data-cy-testingtype="component"]').click()
cy.get('[data-testid="select-framework"]').click()
cy.findByText('Create React App').click()
cy.findByText('Next step').click()
cy.findByText('Next step').should('not.be.disabled').click()
cy.findByDisplayValue('yarn add -D react-scripts react-dom react').should('be.visible')
})

Expand All @@ -578,7 +577,7 @@ describe('Launchpad: Setup Project', () => {
cy.get('[data-cy-testingtype="component"]').click()
cy.get('[data-testid="select-framework"]').click()
cy.findByText('Create React App').click()
cy.findByText('Next step').click()
cy.findByText('Next step').should('not.be.disabled').click()
cy.findByDisplayValue('pnpm install -D react-scripts react-dom react')
})

Expand All @@ -588,9 +587,9 @@ describe('Launchpad: Setup Project', () => {
cy.visitLaunchpad()

cy.get('[data-cy-testingtype="component"]').click()
cy.get('button').should('be.visible').contains('Vue.js 3(detected)')
cy.get('button').should('be.visible').contains('Vite(detected)')
cy.findByText('Next step').click()
cy.contains('button', 'Vue.js 3(detected)').should('be.visible')
cy.contains('button', 'Vite(detected)').should('be.visible')
cy.findByText('Next step').should('not.be.disabled').click()
cy.findByTestId('alert').contains(`You've successfully installed all required dependencies.`)
})

Expand All @@ -602,7 +601,7 @@ describe('Launchpad: Setup Project', () => {
cy.get('[data-cy-testingtype="component"]').click()
cy.get('[data-testid="select-framework"]').click()
cy.findByText('Create React App').click()
cy.findByText('Next step').click()
cy.findByText('Next step').should('not.be.disabled').click()
cy.findByDisplayValue('npm install -D react-scripts react-dom react')
})
})
Expand Down
10 changes: 9 additions & 1 deletion packages/launchpad/cypress/e2e/scaffold-project.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,10 @@ describe('scaffolding new projects', { defaultCommandTimeout: 7000 }, () => {
})

it('generates valid config file for pristine project without cypress installed', () => {
cy.intercept('mutation-ScaffoldedFiles_completeSetup').as('mutationScaffoldedFiles')
cy.intercept('query-MainLaunchpadQuery').as('mainLaunchpadQuery')
cy.intercept('query-HeaderBar_HeaderBarQuery').as('headerBarQuery')
cy.intercept('query-CloudViewerAndProject_RequiredData').as('cloudViewerAndProjectRequiredData')
cy.scaffoldProject('pristine')
cy.openProject('pristine')
cy.withCtx((ctx) => ctx.currentProject).then((currentProject) => {
Expand All @@ -178,6 +182,10 @@ describe('scaffolding new projects', { defaultCommandTimeout: 7000 }, () => {
cy.skipWelcome()
cy.contains('button', cy.i18n.testingType.e2e.name).click()
cy.contains('button', cy.i18n.setupPage.step.continue).click()
cy.contains('h1', cy.i18n.setupPage.testingCard.chooseABrowser).should('be.visible')
cy.wait('@mutationScaffoldedFiles')
cy.wait('@mainLaunchpadQuery')
cy.wait('@headerBarQuery')
cy.wait('@cloudViewerAndProjectRequiredData')
cy.get('h1').contains(cy.i18n.setupPage.testingCard.chooseABrowser).should('be.visible')
})
})
8 changes: 4 additions & 4 deletions packages/launchpad/cypress/e2e/top-nav-launchpad.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -366,12 +366,12 @@ describe('Launchpad Top Nav Workflows', () => {
options.sinon.stub(ctx._apis.authApi, 'logIn').callsFake(async (onMessage) => {
setTimeout(() => {
onMessage({ browserOpened: true })
}, 500)
}, 2000)

return new Promise((resolve) => {
setTimeout(() => {
resolve(options.user)
}, 2000)
}, 3000)
})
})
}, { user })
Expand Down Expand Up @@ -687,7 +687,7 @@ describe('Launchpad Top Nav Workflows', () => {

cy.get('[data-cy="project-card"]').click()

cy.contains('E2E Testing').click()
cy.contains('E2E Testing', { timeout: 10000 }).click()

mockLogInActionsForUser(mockUser)
logIn({ expectedNextStepText: 'Continue', displayName: mockUser.name })
Expand All @@ -707,7 +707,7 @@ describe('Launchpad Top Nav Workflows', () => {

cy.get('[data-cy="project-card"]').click()

cy.contains('E2E Testing').click()
cy.contains('E2E Testing', { timeout: 10000 }).click()

mockLogInActionsForUser(mockUser)
logIn({ expectedNextStepText: 'Connect project', displayName: mockUser.name })
Expand Down