2021-10-24 06:09:43 +02:00
|
|
|
import { authenticationHandlers } from '../../../fixtures/handler'
|
|
|
|
import {
|
|
|
|
postUsersSigninHandler,
|
|
|
|
postUsersSigninInvalidCredentialsHandler
|
2022-01-07 21:21:38 +01:00
|
|
|
} from '../../../fixtures/users/signin/post'
|
2022-01-01 20:42:25 +01:00
|
|
|
import { userExample } from '../../../fixtures/users/user'
|
2021-10-24 06:09:43 +02:00
|
|
|
|
|
|
|
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')
|
2022-01-01 20:42:25 +01:00
|
|
|
cy.get('[data-cy=input-email]').type(userExample.email)
|
2021-10-24 06:09:43 +02:00
|
|
|
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')
|
2022-01-01 20:42:25 +01:00
|
|
|
cy.get('[data-cy=input-email]').type(userExample.email)
|
2021-10-24 06:09:43 +02:00
|
|
|
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')
|
2022-01-01 20:42:25 +01:00
|
|
|
cy.get('[data-cy=input-email]').type(userExample.email)
|
2021-10-24 06:09:43 +02:00
|
|
|
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')
|
|
|
|
})
|
|
|
|
})
|
2022-08-23 21:51:20 +02:00
|
|
|
|
|
|
|
export {}
|