describe('Alura pick use case', () => {
before(() => {
cy.visit('https://alura-fotos.herokuapp.com')
})
it('Verify validation message', () => {
cy.get('a').contains(/register now/gi).click()
cy.get('button').contains(/register/gi).click()
cy.contains('ap-vmessage', 'Email is required').should('be.visible')
cy.get('button').contains(/register/gi).click()
cy.contains('ap-vmessage', 'User name is required').should('be.visible')
cy.contains('ap-vmessage', 'Password is required').should('be.visible')
cy.contains('ap-vmessage', 'Full name is required').should('be.visible')
})
it('Verify invalid email message', () => {
cy.get('input[formcontrolname="email"]').type('test')
cy.get('button').contains(/register/gi).click()
cy.contains('ap-vmessage', 'Invalid e-mail').should('be.visible')
})
it('Verify invalid username message', () => {
cy.get('input[formcontrolname="userName"]').type('Test')
cy.get('button').contains(/register/gi).click()
cy.contains('ap-vmessage', 'Must be lower case').should('be.visible')
})
it('Verify invalid password message', () => {
cy.get('input[formcontrolname="password"]').type('123')
cy.get('button').contains(/register/gi).click()
cy.contains('ap-vmessage', 'Mininum length is 8').should('be.visible')
})
it("shoul be able to create an user", () => {
cy.get('input[formcontrolname="email"]').clear().type('teste@test.com')
cy.get('input[formcontrolname="fullName"]').clear().type('test')
cy.get('input[formcontrolname="userName"]').clear().type('test')
cy.get('input[formcontrolname="password"]').clear().type('123456789')
cy.get('button').contains(/register/gi).click()
// it checks if everything is ok
cy.contains('ap-vmessage').should('not.exist')
})
})