2023-08-23 21:40:15 +02:00
|
|
|
import { decideResponse } from '../fixtures/api/decide'
|
|
|
|
|
2021-03-25 15:40:20 +01:00
|
|
|
describe('Signup', () => {
|
|
|
|
beforeEach(() => {
|
2021-11-11 21:20:01 +01:00
|
|
|
cy.get('[data-attr=top-menu-toggle]').click()
|
2021-03-25 15:40:20 +01:00
|
|
|
cy.get('[data-attr=top-menu-item-logout]').click()
|
|
|
|
cy.location('pathname').should('include', '/login')
|
|
|
|
cy.visit('/signup')
|
|
|
|
})
|
|
|
|
|
|
|
|
it('Cannot create acount with existing email', () => {
|
|
|
|
cy.get('[data-attr=signup-email]').type('test@posthog.com').should('have.value', 'test@posthog.com')
|
|
|
|
cy.get('[data-attr=password]').type('12345678').should('have.value', '12345678')
|
2022-11-28 21:51:21 +01:00
|
|
|
cy.get('[data-attr=signup-start]').click()
|
2021-03-25 15:40:20 +01:00
|
|
|
cy.get('[data-attr=signup-first-name]').type('Jane').should('have.value', 'Jane')
|
|
|
|
cy.get('[data-attr=signup-organization-name]').type('Hogflix Movies').should('have.value', 'Hogflix Movies')
|
2022-11-16 22:35:17 +01:00
|
|
|
cy.get('[data-attr=signup-role-at-organization]').click()
|
2023-04-24 15:08:51 +02:00
|
|
|
cy.get('.Popover li:first-child').click()
|
2022-11-16 22:35:17 +01:00
|
|
|
cy.get('[data-attr=signup-role-at-organization]').contains('Engineering')
|
2021-03-25 15:40:20 +01:00
|
|
|
cy.get('[data-attr=signup-submit]').click()
|
|
|
|
|
2023-04-14 11:03:33 +02:00
|
|
|
cy.get('.LemonBanner').should('contain', 'There is already an account with this email address.')
|
2021-03-25 15:40:20 +01:00
|
|
|
})
|
|
|
|
|
2021-10-01 08:26:19 +02:00
|
|
|
it('Cannot signup without required attributes', () => {
|
2022-11-28 21:51:21 +01:00
|
|
|
cy.get('[data-attr=signup-start]').click()
|
2022-08-25 16:07:44 +02:00
|
|
|
cy.get('.text-danger').should('contain', 'Please enter your email to continue')
|
2022-11-28 21:51:21 +01:00
|
|
|
cy.get('.text-danger').should('contain', 'Please enter your password to continue')
|
2021-10-01 08:26:19 +02:00
|
|
|
})
|
2021-03-25 15:40:20 +01:00
|
|
|
|
2021-10-01 08:26:19 +02:00
|
|
|
it('Cannot signup with invalid attributes', () => {
|
|
|
|
cy.get('[data-attr=password]').type('123').should('have.value', '123')
|
2022-08-25 16:07:44 +02:00
|
|
|
cy.get('.text-danger').should('not.exist') // Validation errors not shown until first submission
|
2022-11-28 21:51:21 +01:00
|
|
|
cy.get('[data-attr=signup-start]').click()
|
2022-08-25 16:07:44 +02:00
|
|
|
cy.get('.text-danger').should('contain', 'Please enter your email to continue')
|
|
|
|
cy.get('.text-danger').should('contain', 'Password must be at least 8 characters')
|
2021-03-25 15:40:20 +01:00
|
|
|
|
2021-10-01 08:26:19 +02:00
|
|
|
cy.get('[data-attr=password]').type('45678901')
|
2022-08-25 16:07:44 +02:00
|
|
|
cy.get('.text-danger').should('not.contain', 'Password must be at least 8 characters') // Validation error removed on keystroke
|
2021-03-25 15:40:20 +01:00
|
|
|
})
|
|
|
|
|
|
|
|
it('Can create user account', () => {
|
|
|
|
const email = `new_user+${Math.floor(Math.random() * 10000)}@posthog.com`
|
|
|
|
cy.get('[data-attr=signup-email]').type(email).should('have.value', email)
|
|
|
|
cy.get('[data-attr=password]').type('12345678').should('have.value', '12345678')
|
2022-11-28 21:51:21 +01:00
|
|
|
cy.get('[data-attr=signup-start]').click()
|
2021-03-25 15:40:20 +01:00
|
|
|
cy.get('[data-attr=signup-first-name]').type('Alice').should('have.value', 'Alice')
|
|
|
|
cy.get('[data-attr=signup-organization-name]').type('Hogflix SpinOff').should('have.value', 'Hogflix SpinOff')
|
2022-11-16 22:35:17 +01:00
|
|
|
cy.get('[data-attr=signup-role-at-organization]').click()
|
2023-04-24 15:08:51 +02:00
|
|
|
cy.get('.Popover li:first-child').click()
|
2022-11-16 22:35:17 +01:00
|
|
|
cy.get('[data-attr=signup-role-at-organization]').contains('Engineering')
|
2021-03-25 15:40:20 +01:00
|
|
|
cy.get('[data-attr=signup-submit]').click()
|
|
|
|
|
2023-06-07 02:57:22 +02:00
|
|
|
// lazy regex for a guid
|
|
|
|
cy.location('pathname').should('match', /\/verify_email\/[a-zA-Z0-9_.-]*/)
|
2021-03-25 15:40:20 +01:00
|
|
|
})
|
2022-11-22 17:41:17 +01:00
|
|
|
|
|
|
|
it('Can fill out all the fields on social login', () => {
|
|
|
|
// We can't actually test the social login feature.
|
|
|
|
// But, we can make sure the form exists as it should, and that upon submit
|
|
|
|
// we get the expected error that no social session exists.
|
|
|
|
cy.visit('/logout')
|
|
|
|
cy.location('pathname').should('include', '/login')
|
|
|
|
cy.visit('/organization/confirm-creation?organization_name=&first_name=Test&email=test%40posthog.com')
|
|
|
|
|
|
|
|
cy.get('[name=email]').should('have.value', 'test@posthog.com')
|
|
|
|
cy.get('[name=first_name]').should('have.value', 'Test')
|
|
|
|
cy.get('[name=organization_name]').type('Hogflix SpinOff').should('have.value', 'Hogflix SpinOff')
|
|
|
|
cy.get('[data-attr=signup-role-at-organization]').click()
|
2023-04-24 15:08:51 +02:00
|
|
|
cy.get('.Popover li:first-child').click()
|
2022-11-22 17:41:17 +01:00
|
|
|
cy.get('[data-attr=signup-role-at-organization]').contains('Engineering')
|
|
|
|
cy.get('[type=submit]').click()
|
|
|
|
// if there are other form issues, we'll get errors on the form, not this toast
|
|
|
|
cy.get('.Toastify [data-attr="error-toast"]').contains('Inactive social login session.')
|
|
|
|
})
|
2023-08-23 21:40:15 +02:00
|
|
|
|
|
|
|
it('Shows redirect notice if redirecting for maintenance', () => {
|
|
|
|
cy.visit('/logout')
|
|
|
|
cy.location('pathname').should('include', '/login')
|
|
|
|
cy.intercept('https://app.posthog.com/decide/*', (req) =>
|
|
|
|
req.reply(
|
|
|
|
decideResponse({
|
|
|
|
'redirect-signups-to-instance': 'us',
|
|
|
|
})
|
|
|
|
)
|
|
|
|
)
|
|
|
|
cy.visit('/signup?maintenanceRedirect=true')
|
|
|
|
cy.get('.Toastify__toast-body').should(
|
|
|
|
'contain',
|
|
|
|
`You have been redirected to signup on our US instance while we perform maintenance on our other instance.`
|
|
|
|
)
|
|
|
|
})
|
2021-03-25 15:40:20 +01:00
|
|
|
})
|