0
0
mirror of https://github.com/PostHog/posthog.git synced 2024-12-01 12:21:02 +01:00
posthog/cypress/support/commands.js
Tim Glaser 5f242b2bed
Solve ospath issue (#5014)
* Solve ospath issue

* try separate cypress cache

* Separate install

* ls

* try

* Try to put everything in same cache

* Remove cypress plugin snapshot

* fix cohorts and funnels
2021-07-07 14:04:39 +02:00

31 lines
960 B
JavaScript

const patternHandler = {}
Cypress.Commands.add('interceptLazy', (pattern, handler) => {
patternHandler[pattern] = handler
return cy.intercept(pattern, (req) => {
req.reply(patternHandler[pattern]())
})
})
Cypress.Commands.add('overrideInterceptLazy', (pattern, handler) => {
patternHandler[pattern] = handler
})
Cypress.Commands.add('map', { prevSubject: true }, (subject, method) => {
return method(subject)
})
Cypress.Commands.add('login', () => {
cy.get('[data-attr=login-email]').type('test@posthog.com').should('have.value', 'test@posthog.com')
cy.get('[data-attr=password]').type('12345678').should('have.value', '12345678')
cy.get('[type=submit]').click()
cy.location('pathname').should('not.eq', '/login') // Wait until login request fully completes
})
Cypress.Commands.add('clickNavMenu', (name) => {
cy.get(`[data-attr="menu-item-${name}"]`).click().should('have.class', 'menu-item-active')
})