This repository has been archived on 2024-10-29. You can view files and clone it, but cannot push or open issues or pull requests.
website/cypress/integration/pages/authentication/signin.spec.ts

56 lines
2.0 KiB
TypeScript
Raw Normal View History

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')
})
})