mirror of
https://github.com/PostHog/posthog.git
synced 2024-11-28 09:16:49 +01:00
a9fae11074
* preload user via django * create django app context * persist feature flags in localStorage * add preflight into app context * return undefined if no context * keep user as `null`, it'll be overriden before anything renders anyway via `afterMount` * remove broken and unused user code * call `registerInstrumentationProps` when preloading `preflight` * for cypress premium tests: add a search param to opt-out of using the preloaded context, so we could intercept the users api call
49 lines
1.3 KiB
JavaScript
49 lines
1.3 KiB
JavaScript
import '@cypress/react/support'
|
|
import 'givens/setup'
|
|
import './commands'
|
|
|
|
import { unmount } from '@cypress/react'
|
|
|
|
try {
|
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
require('cypress-terminal-report/src/installLogsCollector')()
|
|
} catch {}
|
|
|
|
beforeEach(() => {
|
|
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 {
|
|
if (Cypress.spec.name.includes('Premium')) {
|
|
cy.visit('/login?next=/?no-preloaded-app-context=true')
|
|
cy.intercept('/api/users/@me/', { fixture: 'api/user-enterprise' })
|
|
cy.login()
|
|
} else {
|
|
cy.visit('/')
|
|
|
|
cy.url().then((url) => {
|
|
if (url.includes('login')) {
|
|
cy.login()
|
|
}
|
|
})
|
|
}
|
|
}
|
|
})
|
|
|
|
beforeEach(() => {
|
|
if (Cypress.spec.specType !== 'component') {
|
|
// Make sure the insights page is actually loaded before running tests
|
|
cy.get('.insights-page').should('exist')
|
|
}
|
|
})
|
|
|
|
afterEach(() => {
|
|
if (Cypress.spec.specType === 'component') {
|
|
unmount()
|
|
}
|
|
})
|
|
|
|
Cypress.on('uncaught:exception', () => {
|
|
return false
|
|
})
|