a0fa66e8f5
Co-authored-by: Walid <87608619+WalidKorchi@users.noreply.github.com>
56 lines
1.9 KiB
TypeScript
56 lines
1.9 KiB
TypeScript
import { authenticationHandlers } from '../../../fixtures/handler'
|
|
import {
|
|
postUsersSigninHandler,
|
|
postUsersSigninInvalidCredentialsHandler
|
|
} from 'cypress/fixtures/users/signin/post'
|
|
import { user } 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(user.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(user.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(user.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')
|
|
})
|
|
})
|