test frontend signup flow
This commit is contained in:
parent
3dc9204979
commit
e47535f91c
3 changed files with 145 additions and 15 deletions
77
frontend/website/cypress/e2e/confirm-email.cy.ts
Normal file
77
frontend/website/cypress/e2e/confirm-email.cy.ts
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
const authenticatedUser = {
|
||||
id: 7,
|
||||
email: 'user@example.com',
|
||||
}
|
||||
|
||||
describe('email confirmation', () => {
|
||||
beforeEach(() => {
|
||||
cy.intercept('GET', '**/api/me', {
|
||||
statusCode: 401,
|
||||
body: { error: 'unauthenticated' },
|
||||
}).as('me')
|
||||
})
|
||||
|
||||
it('chooses a password, confirms the account, and opens the dashboard', () => {
|
||||
cy.intercept('POST', '**/api/confirm-email', (request) => {
|
||||
expect(request.headers.accept).to.equal('application/json')
|
||||
expect(request.body).to.deep.equal({
|
||||
token: 'confirmation-token',
|
||||
password: 'password123',
|
||||
})
|
||||
request.reply({
|
||||
statusCode: 200,
|
||||
body: { user: authenticatedUser },
|
||||
})
|
||||
}).as('confirmEmail')
|
||||
|
||||
cy.visit('/confirm-email?token=confirmation-token')
|
||||
cy.get('#confirm-email-password').type('password123')
|
||||
cy.get('#confirm-email-password-confirmation').type('password123')
|
||||
cy.get('form').submit()
|
||||
cy.wait('@confirmEmail')
|
||||
|
||||
cy.location('pathname').should('equal', '/dashboard')
|
||||
cy.get('h1').should('have.text', 'Your next step starts here.')
|
||||
})
|
||||
|
||||
it('validates password length and confirmation before submitting', () => {
|
||||
cy.intercept('POST', '**/api/confirm-email').as('confirmEmail')
|
||||
|
||||
cy.visit('/confirm-email?token=confirmation-token')
|
||||
cy.get('#confirm-email-password').type('short')
|
||||
cy.get('#confirm-email-password-confirmation').type('different')
|
||||
cy.get('form').submit()
|
||||
|
||||
cy.get('#confirm-email-password-error')
|
||||
.should('have.text', 'Password must be at least 8 characters.')
|
||||
.and('be.visible')
|
||||
cy.get('#confirm-email-password-confirmation-error')
|
||||
.should('have.text', 'Passwords do not match.')
|
||||
.and('be.visible')
|
||||
cy.get('@confirmEmail.all').should('have.length', 0)
|
||||
})
|
||||
|
||||
it('shows confirmation errors from the backend', () => {
|
||||
cy.intercept('POST', '**/api/confirm-email', {
|
||||
statusCode: 409,
|
||||
body: { error: 'token expired' },
|
||||
}).as('confirmEmail')
|
||||
|
||||
cy.visit('/confirm-email?token=expired-token')
|
||||
cy.get('#confirm-email-password').type('password123')
|
||||
cy.get('#confirm-email-password-confirmation').type('password123')
|
||||
cy.get('form').submit()
|
||||
cy.wait('@confirmEmail')
|
||||
|
||||
cy.get('[role="alert"]')
|
||||
.should('have.text', 'token expired')
|
||||
.and('be.visible')
|
||||
cy.location('pathname').should('equal', '/confirm-email')
|
||||
})
|
||||
|
||||
it('redirects a confirmation route without a token to signup', () => {
|
||||
cy.visit('/confirm-email')
|
||||
|
||||
cy.location('pathname').should('equal', '/signup')
|
||||
})
|
||||
})
|
||||
Loading…
Add table
Add a link
Reference in a new issue