Last active
December 28, 2022 11:46
-
-
Save matefs/1b1bc013fc2c7885157558fdf7250f73 to your computer and use it in GitHub Desktop.
Validacoes de username cypress alurapic
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe('Login e registro de usuário usando o alura-pic', () => { | |
beforeEach(() => { | |
cy.visit('http://alura-fotos.herokuapp.com') | |
}) | |
it('verifica mensagens validacao ', () => { | |
cy.contains('a','Register now').click(); | |
cy.wait(1000) | |
cy.contains('button','Register').click(); | |
cy.contains('ap-vmessage','Email is required').should('be.visible') | |
cy.contains('button','Register').click(); | |
cy.contains('ap-vmessage','Full name is required!').should('be.visible') | |
cy.contains('ap-vmessage','User name is required!').should('be.visible') | |
cy.contains('ap-vmessage','Password is required!').should('be.visible') | |
}) | |
it('Verifica mensagem de email invalido',()=> { | |
cy.contains('a','Register now').click(); | |
cy.contains('button','Register').click(); | |
cy.get('input[formcontrolname="email"]').type('Mateus'); | |
cy.contains('button','Register').click(); | |
cy.contains('ap-vmessage','Invalid e-mail').should('be.visible') | |
}) | |
it('Verifica mensagem de senha maior que 8 dígitos',() => { | |
cy.contains('a','Register now').click(); | |
cy.contains('button','Register').click(); | |
cy.get('input[formcontrolname="password"]').type('123'); | |
cy.contains('button','Register').click(); | |
cy.contains('ap-vmessage','Mininum length is 8').should('be.visible') | |
}) | |
it.only('Fazer login de usuário válido ', () => { | |
cy.login(Cypress.env('userName'),Cypress.env('password')) | |
cy.get('button[type=submit]').click(); | |
cy.contains('a','(Logout)').should('be.visible'); | |
}) | |
it('Fazer login de usuário inválido ', () => { | |
cy.login('Mateus',1234) | |
cy.contains('ap-vmessage','User name is required!').should('be.visible') | |
cy.contains('ap-vmessage','Password is required!').should('be.visible') | |
}) | |
const usuarios = require('../../fixtures/usuarios.json') | |
usuarios.forEach( usuario => { | |
it(`Registrar usuário ${usuario.fullName}`,() => { | |
cy.registrar(usuario.email,usuario.fullName,usuario.userName,usuario.password) | |
}) | |
}) | |
}) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe('Buscar fotos e dados ', () => { | |
// Abaixo um código que deve ser evitado, utilizando tempo. | |
//const tempoEsperado = Math.random() * 7000; | |
it.only('buscar fotos do flavio',() => { | |
cy.request({ | |
method: "GET", | |
url:'https://apialurapic.herokuapp.com/flavio/photos' | |
}).then(res => { | |
expect(res.status).to.be.equal(200) | |
expect(res.body).is.not.empty | |
expect(res.body[0]).to.have.property('description') | |
expect(res.body[0].description).to.be.equal('Farol iluminado'); | |
expect(res.duration).to.be.lte(tempoEsperado) | |
}) | |
}) | |
it('fazer login do flavio',() => { | |
cy.request({ | |
method: "POST", | |
url:'https://apialurapic.herokuapp.com/user/login', | |
body: Cypress.env() | |
}).then(res => { | |
expect(res.status).to.be.equal(200) | |
expect(res.body).is.not.empty | |
expect(res.body).to.have.property('id') | |
expect(res.body.id).to.be.equal(1); | |
expect(res.body).to.have.property('email') | |
expect(res.body.email).to.be.equal('flavio@alurapic.com.br'); | |
}) | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment