Skip to content

Commit

Permalink
fix(tests): 💚 Fix e2e window reload bug
Browse files Browse the repository at this point in the history
  • Loading branch information
baptisteArno committed Jan 8, 2022
1 parent 47162cb commit 8391bcc
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 15 deletions.
5 changes: 5 additions & 0 deletions apps/builder/cypress/plugins/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,8 @@ export const parseTestTypebot = ({
updatedAt: new Date(),
}
}

export const preventUserFromRefreshing = (e: BeforeUnloadEvent) => {
e.preventDefault()
e.returnValue = ''
}
6 changes: 6 additions & 0 deletions apps/builder/cypress/support/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 '@testing-library/cypress/add-commands'
import 'cypress-file-upload'
Expand Down
12 changes: 0 additions & 12 deletions apps/builder/cypress/tests/board.ts

This file was deleted.

11 changes: 10 additions & 1 deletion apps/builder/cypress/tests/bubbles.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import { parseTestTypebot } from 'cypress/plugins/utils'
import {
parseTestTypebot,
preventUserFromRefreshing,
} from 'cypress/plugins/utils'
import { BubbleStepType } from 'models'

describe('Text bubbles', () => {
Expand Down Expand Up @@ -37,6 +40,12 @@ describe('Text bubbles', () => {
cy.signOut()
})

afterEach(() => {
cy.window().then((win) => {
win.removeEventListener('beforeunload', preventUserFromRefreshing)
})
})

it('rich text features should work', () => {
cy.signIn('test2@gmail.com')
cy.visit('/typebots/typebot3/edit')
Expand Down
13 changes: 11 additions & 2 deletions apps/builder/cypress/tests/inputs.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import { parseTestTypebot } from 'cypress/plugins/utils'
import {
parseTestTypebot,
preventUserFromRefreshing,
} from 'cypress/plugins/utils'
import { InputStep, InputStepType } from 'models'

describe('Text input', () => {
Expand All @@ -8,6 +11,12 @@ describe('Text input', () => {
cy.signOut()
})

afterEach(() => {
cy.window().then((win) => {
win.removeEventListener('beforeunload', preventUserFromRefreshing)
})
})

it('options should work', () => {
cy.signIn('test2@gmail.com')
cy.visit('/typebots/typebot3/edit')
Expand Down Expand Up @@ -71,7 +80,7 @@ describe('Email input', () => {
cy.signOut()
})

it.only('options should work', () => {
it('options should work', () => {
cy.signIn('test2@gmail.com')
cy.visit('/typebots/typebot3/edit')
cy.findByRole('button', { name: 'Preview' }).click()
Expand Down

2 comments on commit 8391bcc

@vercel
Copy link

@vercel vercel bot commented on 8391bcc Jan 8, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

viewer-v2 – ./apps/viewer

viewer-v2-typebot-io.vercel.app
typebot-io.vercel.app
viewer-v2-git-main-typebot-io.vercel.app

@vercel
Copy link

@vercel vercel bot commented on 8391bcc Jan 8, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

builder-v2 – ./apps/builder

builder-v2-typebot-io.vercel.app
next.typebot.io
builder-v2-git-main-typebot-io.vercel.app

Please sign in to comment.