2
0

fix(tests): 💚 Fix e2e window reload bug

This commit is contained in:
Baptiste Arnaud
2022-01-08 08:38:39 +01:00
parent 47162cb28a
commit 8391bcce5e
5 changed files with 32 additions and 15 deletions

View File

@ -72,3 +72,8 @@ export const parseTestTypebot = ({
updatedAt: new Date(), updatedAt: new Date(),
} }
} }
export const preventUserFromRefreshing = (e: BeforeUnloadEvent) => {
e.preventDefault()
e.returnValue = ''
}

View File

@ -38,6 +38,12 @@ declare global {
} }
} }
Cypress.on('uncaught:exception', (err) => {
if (err.message.includes('ResizeObserver loop limit exceeded')) {
return false
}
})
// Import commands.js using ES2015 syntax: // Import commands.js using ES2015 syntax:
import '@testing-library/cypress/add-commands' import '@testing-library/cypress/add-commands'
import 'cypress-file-upload' import 'cypress-file-upload'

View File

@ -1,12 +0,0 @@
describe('BoardPage', () => {
beforeEach(() => {
cy.task('seed')
cy.signOut()
})
it('steps should be droppable', () => {
cy.signIn('test2@gmail.com')
cy.visit('/typebots/typebot1/edit')
// Can't find an easy way to implement this
})
})

View File

@ -1,4 +1,7 @@
import { parseTestTypebot } from 'cypress/plugins/utils' import {
parseTestTypebot,
preventUserFromRefreshing,
} from 'cypress/plugins/utils'
import { BubbleStepType } from 'models' import { BubbleStepType } from 'models'
describe('Text bubbles', () => { describe('Text bubbles', () => {
@ -37,6 +40,12 @@ describe('Text bubbles', () => {
cy.signOut() cy.signOut()
}) })
afterEach(() => {
cy.window().then((win) => {
win.removeEventListener('beforeunload', preventUserFromRefreshing)
})
})
it('rich text features should work', () => { it('rich text features should work', () => {
cy.signIn('test2@gmail.com') cy.signIn('test2@gmail.com')
cy.visit('/typebots/typebot3/edit') cy.visit('/typebots/typebot3/edit')

View File

@ -1,4 +1,7 @@
import { parseTestTypebot } from 'cypress/plugins/utils' import {
parseTestTypebot,
preventUserFromRefreshing,
} from 'cypress/plugins/utils'
import { InputStep, InputStepType } from 'models' import { InputStep, InputStepType } from 'models'
describe('Text input', () => { describe('Text input', () => {
@ -8,6 +11,12 @@ describe('Text input', () => {
cy.signOut() cy.signOut()
}) })
afterEach(() => {
cy.window().then((win) => {
win.removeEventListener('beforeunload', preventUserFromRefreshing)
})
})
it('options should work', () => { it('options should work', () => {
cy.signIn('test2@gmail.com') cy.signIn('test2@gmail.com')
cy.visit('/typebots/typebot3/edit') cy.visit('/typebots/typebot3/edit')
@ -71,7 +80,7 @@ describe('Email input', () => {
cy.signOut() cy.signOut()
}) })
it.only('options should work', () => { it('options should work', () => {
cy.signIn('test2@gmail.com') cy.signIn('test2@gmail.com')
cy.visit('/typebots/typebot3/edit') cy.visit('/typebots/typebot3/edit')
cy.findByRole('button', { name: 'Preview' }).click() cy.findByRole('button', { name: 'Preview' }).click()