2021-02-09 16:28:01 +01:00
|
|
|
import '@cypress/react/support'
|
|
|
|
import 'givens/setup'
|
2020-05-19 20:48:10 +02:00
|
|
|
import './commands'
|
|
|
|
|
2021-02-09 16:28:01 +01:00
|
|
|
import { unmount } from '@cypress/react'
|
|
|
|
|
|
|
|
try {
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
|
|
require('cypress-terminal-report/src/installLogsCollector')()
|
|
|
|
} catch {}
|
2020-08-11 10:52:43 +02:00
|
|
|
|
2020-05-19 20:48:10 +02:00
|
|
|
beforeEach(() => {
|
2021-02-09 16:28:01 +01:00
|
|
|
if (Cypress.spec.specType === 'component') {
|
|
|
|
// Freeze time to 2021.01.05 Noon UTC - this should be the same date regardless of timezone.
|
|
|
|
cy.clock(1578225600000, ['Date'])
|
|
|
|
} else {
|
2021-03-27 01:38:13 +01:00
|
|
|
if (Cypress.spec.name.includes('Premium')) {
|
2021-06-09 11:08:49 +02:00
|
|
|
cy.visit('/login?next=/?no-preloaded-app-context=true')
|
2021-04-08 22:40:29 +02:00
|
|
|
cy.intercept('/api/users/@me/', { fixture: 'api/user-enterprise' })
|
2021-05-01 03:21:23 +02:00
|
|
|
cy.login()
|
2021-03-27 01:38:13 +01:00
|
|
|
} else {
|
|
|
|
cy.visit('/')
|
|
|
|
|
|
|
|
cy.url().then((url) => {
|
|
|
|
if (url.includes('login')) {
|
2021-05-01 03:21:23 +02:00
|
|
|
cy.login()
|
2021-03-27 01:38:13 +01:00
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
2021-02-09 16:28:01 +01:00
|
|
|
}
|
|
|
|
})
|
2020-05-19 20:48:10 +02:00
|
|
|
|
2021-05-20 16:42:26 +02:00
|
|
|
beforeEach(() => {
|
|
|
|
if (Cypress.spec.specType !== 'component') {
|
|
|
|
// Make sure the insights page is actually loaded before running tests
|
|
|
|
cy.get('.insights-page').should('exist')
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2021-02-09 16:28:01 +01:00
|
|
|
afterEach(() => {
|
|
|
|
if (Cypress.spec.specType === 'component') {
|
|
|
|
unmount()
|
|
|
|
}
|
2020-05-19 20:48:10 +02:00
|
|
|
})
|
|
|
|
|
2021-06-29 22:20:02 +02:00
|
|
|
const resizeObserverLoopErrRe = /^[^(ResizeObserver loop limit exceeded)]/
|
|
|
|
Cypress.on('uncaught:exception', (err) => {
|
|
|
|
/* returning false here prevents Cypress from failing the test */
|
|
|
|
if (resizeObserverLoopErrRe.test(err.message)) {
|
|
|
|
return false
|
|
|
|
}
|
2020-05-19 20:48:10 +02:00
|
|
|
})
|