2020-12-10 14:52:35 +01:00
|
|
|
// This test assumes no mailer is set up and all users are activated immediately.
|
|
|
|
|
|
|
|
import {UserFactory} from '../../factories/user'
|
|
|
|
|
|
|
|
context('Registration', () => {
|
|
|
|
beforeEach(() => {
|
|
|
|
UserFactory.create(1, {
|
|
|
|
username: 'test',
|
|
|
|
})
|
|
|
|
cy.visit('/', {
|
|
|
|
onBeforeLoad(win) {
|
|
|
|
win.localStorage.removeItem('token')
|
|
|
|
},
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
it('Should work without issues', () => {
|
|
|
|
const fixture = {
|
|
|
|
username: 'testuser',
|
|
|
|
password: '123456',
|
|
|
|
email: 'testuser@example.com',
|
|
|
|
}
|
|
|
|
|
|
|
|
cy.visit('/register')
|
|
|
|
cy.get('#username').type(fixture.username)
|
|
|
|
cy.get('#email').type(fixture.email)
|
2021-11-14 21:57:36 +01:00
|
|
|
cy.get('#password').type(fixture.password)
|
|
|
|
cy.get('#passwordValidation').type(fixture.password)
|
2021-01-17 18:57:57 +01:00
|
|
|
cy.get('#register-submit').click()
|
2020-12-10 14:52:35 +01:00
|
|
|
cy.url().should('include', '/')
|
2021-07-07 10:19:37 +02:00
|
|
|
cy.clock(1625656161057) // 13:00
|
2020-12-10 14:52:35 +01:00
|
|
|
cy.get('h2').should('contain', `Hi ${fixture.username}!`)
|
|
|
|
})
|
|
|
|
|
2021-11-28 15:18:27 +01:00
|
|
|
it.only('Should fail', () => {
|
2020-12-10 14:52:35 +01:00
|
|
|
const fixture = {
|
|
|
|
username: 'test',
|
|
|
|
password: '123456',
|
|
|
|
email: 'testuser@example.com',
|
|
|
|
}
|
|
|
|
|
|
|
|
cy.visit('/register')
|
|
|
|
cy.get('#username').type(fixture.username)
|
|
|
|
cy.get('#email').type(fixture.email)
|
2021-11-14 21:57:36 +01:00
|
|
|
cy.get('#password').type(fixture.password)
|
|
|
|
cy.get('#passwordValidation').type(fixture.password)
|
2021-01-17 18:57:57 +01:00
|
|
|
cy.get('#register-submit').click()
|
2021-11-28 15:18:27 +01:00
|
|
|
cy.get('div.message.danger').contains('A user with this username already exists.')
|
2020-12-10 14:52:35 +01:00
|
|
|
})
|
|
|
|
})
|