0
0
mirror of https://github.com/PostHog/posthog.git synced 2024-11-28 18:26:15 +01:00
posthog/cypress/support/index.js
Yakko Majuri 4cb64d0c74
Fix Cypress tests (#1635)
* added timeouts and waits to ensure flow of cypress tests

* removed unused test

* fixed trends elements tests

* testing a longer wait time - temp

* fix trends sessions and retetion filtering tests

* fix events filtering test

* removed wait

* trends sessions fix

* minor update

* fix live actions & sessions

* improve timeouts

* more timouts

* removed some waits

* added timeouts to trends tests

* modify config

* remove test on bug

* removed timeout from events table

* remove dashboards timeout

* change selector for sessions tab

* use data-attr
2020-09-18 09:26:12 -04:00

64 lines
1.9 KiB
JavaScript

import './commands'
// eslint-disable-next-line @typescript-eslint/no-var-requires
require('cypress-terminal-report/src/installLogsCollector')()
beforeEach(() => {
cy.visit('/')
cy.url().then((url) => {
if (url.includes('preflight')) {
cy.get('.text-center > .ant-btn-default').click()
cy.get('[style="margin-bottom: 64px;"] > .ant-btn').click()
cy.wait(200)
signUp()
} else if (url.includes('signup')) {
signUp()
} else if (url.includes('login')) {
logIn()
}
cy.wait(200)
cy.get('body').then(($body) => {
if ($body.find('[data-attr=select-platform-Web]').length) {
cy.get('[data-attr=select-platform-Web]').click()
cy.get('[data-attr=wizard-step-counter]').should('contain', 'Step 2')
cy.get('[data-attr=wizard-continue-button]').click()
cy.get('[data-attr=wizard-complete-button]').should('exist')
cy.get('[data-attr=wizard-complete-button]').click()
}
})
})
})
const signUp = () => {
cy.get('#signupCompanyName').type('Hedgehogs, Inc.').should('have.value', 'Hedgehogs, Inc.')
cy.get('#signupFirstName').type('name').should('have.value', 'name')
cy.get('#signupEmail').type('fake@posthog.com').should('have.value', 'fake@posthog.com')
cy.get('#signupPassword').type('Test1234').should('have.value', 'Test1234')
cy.get('button[data-attr="signup"]').click()
cy.wait(3000)
cy.visit('/demo')
cy.wait(1000)
cy.visit('/')
}
const logIn = () => {
cy.get('#inputEmail').type('fake@posthog.com').should('have.value', 'fake@posthog.com')
cy.get('#inputPassword').type('Test1234').should('have.value', 'Test1234')
cy.get('.btn').click()
}
Cypress.on('uncaught:exception', () => {
return false
})