chore: remove jest -> cypress for unit tests
This commit is contained in:
39
cypress/e2e/pages/authentication/forgot-password.cy.ts
Normal file
39
cypress/e2e/pages/authentication/forgot-password.cy.ts
Normal file
@ -0,0 +1,39 @@
|
||||
import { postUsersResetPasswordHandler } from '../../../fixtures/users/reset-password/post'
|
||||
import { userExample } from '../../../fixtures/users/user'
|
||||
|
||||
describe('Pages > /authentication/forgot-password', () => {
|
||||
beforeEach(() => {
|
||||
cy.task('stopMockServer')
|
||||
cy.visit('/authentication/forgot-password')
|
||||
})
|
||||
|
||||
it('should succeeds and sends a password-reset request', () => {
|
||||
cy.task('startMockServer', [postUsersResetPasswordHandler])
|
||||
cy.get('#message').should('not.exist')
|
||||
cy.get('[data-cy=input-email]').type(userExample.email)
|
||||
cy.get('[data-cy=submit]').click()
|
||||
cy.get('#message').should(
|
||||
'have.text',
|
||||
'Success: Password-reset request successful, please check your emails!'
|
||||
)
|
||||
})
|
||||
|
||||
it('should fails with unreachable api server', () => {
|
||||
cy.get('#message').should('not.exist')
|
||||
cy.get('[data-cy=input-email]').type(userExample.email)
|
||||
cy.get('[data-cy=submit]').click()
|
||||
cy.get('#message').should('have.text', 'Error: Internal Server Error.')
|
||||
})
|
||||
|
||||
it('should fails with wrong email format', () => {
|
||||
cy.get('#message').should('not.exist')
|
||||
cy.get('[data-cy=input-email]').type('test')
|
||||
cy.get('[data-cy=submit]').click()
|
||||
cy.get('#message').should(
|
||||
'have.text',
|
||||
'Error: Mmm… It seems that this email is not valid 🤔.'
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
export {}
|
50
cypress/e2e/pages/authentication/reset-password.cy.ts
Normal file
50
cypress/e2e/pages/authentication/reset-password.cy.ts
Normal file
@ -0,0 +1,50 @@
|
||||
import {
|
||||
putUsersResetPasswordHandler,
|
||||
putUsersResetPasswordInvalidTemporaryTokenHandler
|
||||
} from '../../../fixtures/users/reset-password/put'
|
||||
|
||||
describe('Pages > /authentication/reset-password', () => {
|
||||
beforeEach(() => {
|
||||
cy.task('stopMockServer')
|
||||
})
|
||||
|
||||
it('should succeeds and redirect user to sign in page', () => {
|
||||
cy.task('startMockServer', [putUsersResetPasswordHandler])
|
||||
cy.visit('/authentication/reset-password?temporaryToken=abcdefg')
|
||||
cy.get('#message').should('not.exist')
|
||||
cy.get('[data-cy=input-password]').type('somepassword')
|
||||
cy.get('[data-cy=submit]').click()
|
||||
cy.location('pathname').should('eq', '/authentication/signin')
|
||||
})
|
||||
|
||||
it('should fails with invalid `temporaryToken`', () => {
|
||||
cy.task('startMockServer', [
|
||||
putUsersResetPasswordInvalidTemporaryTokenHandler
|
||||
])
|
||||
cy.visit('/authentication/reset-password')
|
||||
cy.get('#message').should('not.exist')
|
||||
cy.get('[data-cy=input-password]').type('somepassword')
|
||||
cy.get('[data-cy=submit]').click()
|
||||
cy.get('#message').should('have.text', 'Error: Invalid value.')
|
||||
})
|
||||
|
||||
it('should fails with unreachable api server', () => {
|
||||
cy.visit('/authentication/reset-password')
|
||||
cy.get('#message').should('not.exist')
|
||||
cy.get('[data-cy=input-password]').type('randompassword')
|
||||
cy.get('[data-cy=submit]').click()
|
||||
cy.get('#message').should('have.text', 'Error: Internal Server Error.')
|
||||
})
|
||||
|
||||
it('should fails with empty password value', () => {
|
||||
cy.visit('/authentication/reset-password')
|
||||
cy.get('#message').should('not.exist')
|
||||
cy.get('[data-cy=submit]').click()
|
||||
cy.get('#message').should(
|
||||
'have.text',
|
||||
'Error: Oops, this field is required 🙈.'
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
export {}
|
57
cypress/e2e/pages/authentication/signin.cy.ts
Normal file
57
cypress/e2e/pages/authentication/signin.cy.ts
Normal file
@ -0,0 +1,57 @@
|
||||
import { authenticationHandlers } from '../../../fixtures/handler'
|
||||
import {
|
||||
postUsersSigninHandler,
|
||||
postUsersSigninInvalidCredentialsHandler
|
||||
} from '../../../fixtures/users/signin/post'
|
||||
import { userExample } from '../../../fixtures/users/user'
|
||||
|
||||
describe('Pages > /authentication/signin', () => {
|
||||
beforeEach(() => {
|
||||
cy.task('stopMockServer')
|
||||
cy.visit('/authentication/signin')
|
||||
})
|
||||
|
||||
it('should succeeds and sign in the user', () => {
|
||||
cy.task('startMockServer', [
|
||||
...authenticationHandlers,
|
||||
postUsersSigninHandler
|
||||
])
|
||||
cy.get('#error-email').should('not.exist')
|
||||
cy.get('#error-password').should('not.exist')
|
||||
cy.get('[data-cy=input-email]').type(userExample.email)
|
||||
cy.get('[data-cy=input-password]').type('randompassword')
|
||||
cy.get('[data-cy=submit]').click()
|
||||
cy.location('pathname').should('eq', '/application')
|
||||
})
|
||||
|
||||
it('should fails with unreachable api server', () => {
|
||||
cy.get('#error-email').should('not.exist')
|
||||
cy.get('#error-password').should('not.exist')
|
||||
cy.get('[data-cy=input-email]').type(userExample.email)
|
||||
cy.get('[data-cy=input-password]').type('randompassword')
|
||||
cy.get('[data-cy=submit]').click()
|
||||
cy.get('#message').should('have.text', 'Error: Internal Server Error.')
|
||||
cy.get('#error-email').should('not.exist')
|
||||
cy.get('#error-password').should('not.exist')
|
||||
})
|
||||
|
||||
it('should fails with invalid credentials', () => {
|
||||
cy.task('startMockServer', [
|
||||
...authenticationHandlers,
|
||||
postUsersSigninInvalidCredentialsHandler
|
||||
])
|
||||
cy.get('#error-email').should('not.exist')
|
||||
cy.get('#error-password').should('not.exist')
|
||||
cy.get('[data-cy=input-email]').type(userExample.email)
|
||||
cy.get('[data-cy=input-password]').type('randompassword')
|
||||
cy.get('[data-cy=submit]').click()
|
||||
cy.get('#message').should(
|
||||
'have.text',
|
||||
'Error: Invalid credentials. Please try again.'
|
||||
)
|
||||
cy.get('#error-email').should('not.exist')
|
||||
cy.get('#error-password').should('not.exist')
|
||||
})
|
||||
})
|
||||
|
||||
export {}
|
87
cypress/e2e/pages/authentication/signup.cy.ts
Normal file
87
cypress/e2e/pages/authentication/signup.cy.ts
Normal file
@ -0,0 +1,87 @@
|
||||
import { userExample } from '../../../fixtures/users/user'
|
||||
import {
|
||||
postUsersSignupHandler,
|
||||
postUsersSignupAlreadyUsedHandler
|
||||
} from '../../../fixtures/users/signup/post'
|
||||
|
||||
describe('Pages > /authentication/signup', () => {
|
||||
beforeEach(() => {
|
||||
cy.task('stopMockServer')
|
||||
cy.visit('/authentication/signup')
|
||||
})
|
||||
|
||||
it('should succeeds and sign up the user', () => {
|
||||
cy.task('startMockServer', [postUsersSignupHandler])
|
||||
cy.get('#error-name').should('not.exist')
|
||||
cy.get('#error-email').should('not.exist')
|
||||
cy.get('#error-password').should('not.exist')
|
||||
cy.get('[data-cy=input-name]').type(userExample.name)
|
||||
cy.get('[data-cy=input-email]').type(userExample.email)
|
||||
cy.get('[data-cy=input-password]').type('randompassword')
|
||||
cy.get('[data-cy=submit]').click()
|
||||
cy.get('#message').should(
|
||||
'have.text',
|
||||
"Success: You're almost there, please check your emails to confirm registration."
|
||||
)
|
||||
})
|
||||
|
||||
it('should fails with name or email already used', () => {
|
||||
cy.task('startMockServer', [postUsersSignupAlreadyUsedHandler])
|
||||
cy.get('#error-name').should('not.exist')
|
||||
cy.get('#error-email').should('not.exist')
|
||||
cy.get('#error-password').should('not.exist')
|
||||
cy.get('[data-cy=input-name]').type(userExample.name)
|
||||
cy.get('[data-cy=input-email]').type(userExample.email)
|
||||
cy.get('[data-cy=input-password]').type('randompassword')
|
||||
cy.get('[data-cy=submit]').click()
|
||||
cy.get('#message').should('have.text', 'Error: Name or Email already used.')
|
||||
cy.get('#error-name').should('not.exist')
|
||||
cy.get('#error-email').should('not.exist')
|
||||
cy.get('#error-password').should('not.exist')
|
||||
})
|
||||
|
||||
it('should fails with unreachable api server', () => {
|
||||
cy.get('#error-name').should('not.exist')
|
||||
cy.get('#error-email').should('not.exist')
|
||||
cy.get('#error-password').should('not.exist')
|
||||
cy.get('[data-cy=input-name]').type(userExample.name)
|
||||
cy.get('[data-cy=input-email]').type(userExample.email)
|
||||
cy.get('[data-cy=input-password]').type('randompassword')
|
||||
cy.get('[data-cy=submit]').click()
|
||||
cy.get('#message').should('have.text', 'Error: Internal Server Error.')
|
||||
cy.get('#error-name').should('not.exist')
|
||||
cy.get('#error-email').should('not.exist')
|
||||
cy.get('#error-password').should('not.exist')
|
||||
})
|
||||
|
||||
it('should fails with all inputs as required with error messages and update error messages when updating language (translation)', () => {
|
||||
const requiredErrorMessage = {
|
||||
en: 'Error: Oops, this field is required 🙈.',
|
||||
fr: 'Erreur: Oups, ce champ est obligatoire 🙈.'
|
||||
}
|
||||
cy.get('#error-name').should('not.exist')
|
||||
cy.get('#error-email').should('not.exist')
|
||||
cy.get('#error-password').should('not.exist')
|
||||
cy.get('[data-cy=submit]').click()
|
||||
cy.get('#error-name').should('have.text', requiredErrorMessage.en)
|
||||
cy.get('#error-email').should('have.text', requiredErrorMessage.en)
|
||||
cy.get('#error-password').should('have.text', requiredErrorMessage.en)
|
||||
cy.get('[data-cy=language-click]').click()
|
||||
cy.get('[data-cy=languages-list] > li:first-child').contains('FR').click()
|
||||
cy.get('#error-name').should('have.text', requiredErrorMessage.fr)
|
||||
cy.get('#error-email').should('have.text', requiredErrorMessage.fr)
|
||||
cy.get('#error-password').should('have.text', requiredErrorMessage.fr)
|
||||
})
|
||||
|
||||
it('should fails with wrong email format', () => {
|
||||
cy.get('#error-email').should('not.exist')
|
||||
cy.get('[data-cy=input-email]').type('test')
|
||||
cy.get('[data-cy=submit]').click()
|
||||
cy.get('#error-email').should(
|
||||
'have.text',
|
||||
'Error: Mmm… It seems that this email is not valid 🤔.'
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
export {}
|
Reference in New Issue
Block a user