mirror of
https://github.com/PostHog/posthog.git
synced 2024-11-28 09:16:49 +01:00
e612088c52
* initial commit * initial commit * fix up some types * Add team id * add client side filters * check live events in onboarding * add eventsource * clean up live table logic * add event source module * Delete eventsManagementDescribers.tsx * update event source usage * Update liveEventsTableLogic.ts * Update UI snapshots for `chromium` (2) * add team live events token * Delete liveEventsTableLogic.ts * Update types.ts * switch to use window event source * improvements / feature flags * cleanup * update the live event host * Update UI snapshots for `chromium` (2) * remove event source lib * fix up event source types * Clean up live events view * Delete eventsManagement.ts * Update SDKs.tsx * improve live event typing * add better loading for the table * update the live events table columns * add last batch timestamp check * add toast for error * rename events management to activity * Hookup proper team id * Update start * Fix types * Update some tests * Put SDKs back with no live event changes * Update verifiedDomainsLogic.test.ts.snap * Update verifiedDomainsLogic.test.ts.snap * Update UI snapshots for `chromium` (2) * Update query snapshots * Update query snapshots * Update UI snapshots for `chromium` (2) * Update UI snapshots for `chromium` (2) * Update query snapshots * Update UI snapshots for `chromium` (2) * Update query snapshots * Update UI snapshots for `chromium` (2) * Update query snapshots * Update UI snapshots for `chromium` (2) * Use `preserveParams()` in redirect from old URL * Clean up UI and refactor tabs * Update E2E tests * Update UI snapshots for `chromium` (2) * Don't hide "Reload" when live events available * Remove unused import * Update UI snapshots for `chromium` (2) * Improve local batching reliability * Make console error clearer * Clarify directory structure * Update UI snapshots for `chromium` (2) * Jot down source of `EventSource` type * Remove unused scene code * Update UI snapshots for `chromium` (2) * Update UI snapshots for `chromium` (2) * Update a11.cy.ts * Update UI snapshots for `chromium` (2) * Update UI snapshots for `chromium` (2) * Update UI snapshots for `chromium` (2) * Remove any effects for users with flag off * Update UI snapshots for `chromium` (1) * Update UI snapshots for `chromium` (1) * Update UI snapshots for `chromium` (2) --------- Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Michael Matloka <michal@matloka.com> Co-authored-by: Michael Matloka <dev@twixes.com>
99 lines
4.2 KiB
TypeScript
99 lines
4.2 KiB
TypeScript
describe('Auth', () => {
|
|
beforeEach(() => {
|
|
cy.get('[data-attr=menu-item-me]').click()
|
|
})
|
|
|
|
it('Logout', () => {
|
|
cy.get('[data-attr=top-menu-item-logout]').click()
|
|
cy.location('pathname').should('eq', '/login')
|
|
})
|
|
|
|
it('Logout and login', () => {
|
|
cy.get('[data-attr=top-menu-item-logout]').click()
|
|
|
|
cy.get('[data-attr=login-email]').type('test@posthog.com').should('have.value', 'test@posthog.com').blur()
|
|
cy.get('[data-attr=password]', { timeout: 5000 }).should('be.visible') // Wait for login precheck (note blur above)
|
|
|
|
cy.get('[data-attr=password]').type('12345678').should('have.value', '12345678')
|
|
|
|
cy.get('[type=submit]').click()
|
|
// Login should have succeeded
|
|
cy.location('pathname').should('eq', '/')
|
|
})
|
|
|
|
it('Logout and verify that Google login button has correct link', () => {
|
|
cy.get('[data-attr=top-menu-item-logout]').click()
|
|
|
|
cy.window().then((win) => {
|
|
win.POSTHOG_APP_CONTEXT.preflight.available_social_auth_providers = {
|
|
'google-oauth2': true,
|
|
}
|
|
})
|
|
|
|
cy.get('a[href="/login/google-oauth2/"').should('exist') // As of March 2023, the trailing slash really matters!
|
|
})
|
|
|
|
it('Try logging in improperly and then properly', () => {
|
|
cy.get('[data-attr=top-menu-item-logout]').click()
|
|
|
|
cy.get('[data-attr=login-email]').type('test@posthog.com').should('have.value', 'test@posthog.com').blur()
|
|
cy.get('[data-attr=password]', { timeout: 5000 }).should('be.visible') // Wait for login precheck (note blur above)
|
|
cy.get('[data-attr=password]').type('wrong password').should('have.value', 'wrong password')
|
|
cy.get('[type=submit]').click()
|
|
// There should be an error message now
|
|
cy.get('.LemonBanner').should('contain', 'Invalid email or password.')
|
|
// Now try with the right password
|
|
cy.get('[data-attr=password]').clear().type('12345678')
|
|
cy.get('[type=submit]').click()
|
|
// Login should have succeeded
|
|
cy.location('pathname').should('eq', '/')
|
|
})
|
|
|
|
it('Redirect to appropriate place after login', () => {
|
|
cy.visit('/logout')
|
|
cy.location('pathname').should('include', '/login')
|
|
|
|
cy.visit('/activity/explore')
|
|
cy.location('pathname').should('include', '/login') // Should be redirected to login because we're now logged out
|
|
|
|
cy.get('[data-attr=login-email]').type('test@posthog.com').blur()
|
|
cy.get('[data-attr=password]', { timeout: 5000 }).should('be.visible') // Wait for login precheck (note blur above)
|
|
cy.get('[data-attr=password]').type('12345678')
|
|
cy.get('[type=submit]').click()
|
|
|
|
cy.location('pathname').should('include', '/activity/explore')
|
|
})
|
|
|
|
it('Redirect to appropriate place after login with complex URL', () => {
|
|
cy.visit('/logout')
|
|
cy.location('pathname').should('include', '/login')
|
|
|
|
cy.visit('/insights?search=testString')
|
|
cy.location('pathname').should('include', '/login') // Should be redirected to login because we're now logged out
|
|
|
|
cy.get('[data-attr=login-email]').type('test@posthog.com').blur()
|
|
cy.get('[data-attr=password]', { timeout: 5000 }).should('be.visible') // Wait for login precheck (note blur above)
|
|
cy.get('[data-attr=password]').type('12345678')
|
|
cy.get('[type=submit]').click()
|
|
|
|
cy.location('search').should('include', 'testString')
|
|
cy.get('.saved-insight-empty-state').should('contain', 'testString') // Ensure the URL was properly parsed and components shown correctly
|
|
})
|
|
|
|
it('Cannot access signup page if authenticated', () => {
|
|
cy.visit('/signup')
|
|
cy.location('pathname').should('eq', '/project/1')
|
|
})
|
|
|
|
it('Logout in another tab results in logout in the current tab too', () => {
|
|
cy.window().then(async (win) => {
|
|
// Hit /logout *in the background* by using fetch()
|
|
await win.fetch('/logout')
|
|
})
|
|
|
|
cy.clickNavMenu('dashboards') // This should cause logout bacause of new data fetching being initiated
|
|
|
|
cy.location('pathname').should('eq', '/login') // We should be quickly redirected to the login page
|
|
})
|
|
})
|