mirror of
https://github.com/PostHog/posthog.git
synced 2024-11-25 02:49:32 +01:00
ed049830df
* chore: add some cypress tests that exercise turbo mode more * a little before eaching
55 lines
1.7 KiB
JavaScript
55 lines
1.7 KiB
JavaScript
import 'givens/setup'
|
|
import './commands'
|
|
import 'cypress-axe'
|
|
import { decideResponse } from 'cypress/fixtures/api/decide'
|
|
|
|
try {
|
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
require('cypress-terminal-report/src/installLogsCollector')()
|
|
} catch {}
|
|
|
|
// Add console errors into cypress logs. This helps with failures in Github Actions which otherwise swallows them.
|
|
// From: https://github.com/cypress-io/cypress/issues/300#issuecomment-688915086
|
|
Cypress.on('window:before:load', (win) => {
|
|
cy.spy(win.console, 'error')
|
|
cy.spy(win.console, 'warn')
|
|
})
|
|
|
|
beforeEach(() => {
|
|
cy.intercept('api/prompts/my_prompts/', { sequences: [], state: {} })
|
|
|
|
cy.intercept('https://app.posthog.com/decide/*', (req) =>
|
|
req.reply(
|
|
decideResponse({
|
|
// set feature flags here e.g.
|
|
// 'toolbar-launch-side-action': true,
|
|
})
|
|
)
|
|
)
|
|
|
|
if (Cypress.spec.name.includes('Premium')) {
|
|
cy.intercept('/api/users/@me/', { fixture: 'api/user-enterprise' })
|
|
|
|
cy.request('POST', '/api/login/', {
|
|
email: 'test@posthog.com',
|
|
password: '12345678',
|
|
})
|
|
cy.visit('/?no-preloaded-app-context=true')
|
|
} else {
|
|
cy.request('POST', '/api/login/', {
|
|
email: 'test@posthog.com',
|
|
password: '12345678',
|
|
})
|
|
cy.visit('/insights')
|
|
cy.get('.saved-insights').should('exist')
|
|
}
|
|
})
|
|
|
|
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
|
|
}
|
|
})
|