mirror of
https://github.com/PostHog/posthog.git
synced 2024-11-30 19:41:46 +01:00
30b6692920
* WIP: get cypress something doing * Get a test running * Get css loading, stub posthog * Move helpers to separate file * Givens > given2 It plays nicer with beforeEach * Test for session filters * Test date navigation * Test filtering * Try keep old tests running * Try get tests running under CI * Prettify fixtures * Cleanup, use cypress 6 * Add yarn build * Fix e2e cypress tests * given2 => givens * Rename `frontend-test-runner` to `e2e-test-runner` * Fix cypress test * Add webpack-preprocessor as a devDependency * Improve freezing time * Make css inclusions automatic for component tests
40 lines
984 B
JavaScript
40 lines
984 B
JavaScript
import React from 'react'
|
|
|
|
import { mount } from '@cypress/react'
|
|
import { Provider } from 'react-redux'
|
|
import { getContext } from 'kea'
|
|
import { initKea } from '~/initKea'
|
|
import { GlobalStyles } from '~/GlobalStyles'
|
|
import posthog from 'posthog-js'
|
|
|
|
export const mountPage = (component) => {
|
|
initKea()
|
|
return mount(
|
|
<Provider store={getContext().store}>
|
|
<GlobalStyles />
|
|
{component}
|
|
</Provider>
|
|
)
|
|
}
|
|
|
|
export const setLocation = (path) => {
|
|
window.history.replaceState(null, '', path)
|
|
}
|
|
|
|
export const getSearchParameters = ({ request }) => {
|
|
const searchParams = new URL(request.url).searchParams
|
|
const result = {}
|
|
for (const [key, value] of searchParams.entries()) {
|
|
result[key] = value
|
|
}
|
|
return result
|
|
}
|
|
|
|
export const mockPosthog = () => {
|
|
cy.stub(posthog)
|
|
posthog.people = { set: () => {} }
|
|
posthog.onFeatureFlags = (callback) => {
|
|
callback(given.featureFlags || [])
|
|
}
|
|
}
|