Skip to content

Commit

Permalink
Atualização do repositório
Browse files Browse the repository at this point in the history
  • Loading branch information
wasilva committed Dec 7, 2023
1 parent 1c8ec0d commit c685ed3
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 33 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
node_modules
package-lock.json
*.log
*.log
cypress.env.json
screenshots
videos
5 changes: 5 additions & 0 deletions cypress.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,9 @@ module.exports = defineConfig({
// implement node event listeners here
},
},
screenshotOnRunFailure: true,
screenshotsFolder: 'cypress/screenshots',
video: true,
videoCompression: false,
videosFolder: 'cypress/videos'
});
33 changes: 33 additions & 0 deletions cypress/e2e/login.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/// <reference types="cypress" />
const element = require("../fixtures/login.json")

beforeEach(() => {
cy.visit('https://automacao.qacoders-academy.com.br/login');
});

afterEach(() => {
cy.screenshot();
})

describe('Login', () => {
it('Login com sucesso', () => {
const email = Cypress.env('EMAIL');
const password = Cypress.env('PASSOWORD');
cy.Login(email, password);
});

it('Login com e-mail válido e a senha inválida', () => {
cy.get(element.input_email).type(Cypress.env('EMAIL'));
cy.get(element.input_password).type(Cypress.env('PASSOWORD_INVALIDO'));
cy.get(element.btn_login).click();
cy.MsgLoginFalho()
});

it('Login com e-mail inválido e a senha válida', () => {
cy.get(element.input_email).type(Cypress.env('EMAIL_INVALIDO'));
cy.get(element.input_password).type(Cypress.env('PASSOWORD'));
cy.get(element.btn_login).click();
cy.MsgLoginFalho()
});

});
6 changes: 0 additions & 6 deletions cypress/e2e/spec.cy.js

This file was deleted.

6 changes: 6 additions & 0 deletions cypress/fixtures/login.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"input_email": "#email",
"input_password": "#password",
"btn_login": "#login",
"msg_alert": "[class='MuiAlert-message css-1xsto0d']"
}
44 changes: 19 additions & 25 deletions cypress/support/commands.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,19 @@
// ***********************************************
// This example commands.js shows you how to
// create various custom commands and overwrite
// existing commands.
//
// For more comprehensive examples of custom
// commands please read more here:
// https://on.cypress.io/custom-commands
// ***********************************************
//
//
// -- This is a parent command --
// Cypress.Commands.add('login', (email, password) => { ... })
//
//
// -- This is a child command --
// Cypress.Commands.add('drag', { prevSubject: 'element'}, (subject, options) => { ... })
//
//
// -- This is a dual command --
// Cypress.Commands.add('dismiss', { prevSubject: 'optional'}, (subject, options) => { ... })
//
//
// -- This will overwrite an existing command --
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })
/// <reference types="cypress" />

Cypress.Commands.add('Login', (email, password ) => {
cy.get('#email').type(email);
cy.get('#password').type(password);
cy.get('#login').click();

cy.location().should((loc) => {
expect(loc.pathname).to.eq('/login');
})

cy.get('body > nav >button').should('be.visible');
});

Cypress.Commands.add('MsgLoginFalho', () => {
cy.get('[class="MuiAlert-message css-1xsto0d"]').should('be.visible');
cy.get('[class="MuiAlert-message css-1xsto0d"]').should('have.text','E-mail e/ou senha inválidos');
});

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"cypress": "^13.6.0"
},
"scripts": {
"cypress:open": "cypress open"
"cypress:open": "cypress open",
"cypress:run" : "cypress run"
}
}

0 comments on commit c685ed3

Please sign in to comment.