Skip to content

Commit

Permalink
Cypress config.
Browse files Browse the repository at this point in the history
  • Loading branch information
SebastRivera committed Aug 17, 2023
1 parent 44df498 commit 4e88d25
Show file tree
Hide file tree
Showing 4 changed files with 692 additions and 14 deletions.
33 changes: 22 additions & 11 deletions cypress/integration/login.spec.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,28 @@
describe('Login and Sign Up', () => {
it('Allows a user to log in', () => {
cy.visit('/login'); // Asegúrate de ajustar la ruta si es necesario
describe('Login and API Requests', () => {
it('Allows a user to log in and access protected API routes', () => {
cy.visit('/login');

// Simular el login exitoso
cy.get('[name="email"]').type('[email protected]');
cy.get('[name="password"]').type('abc123');
cy.get('.MuiButton-containedPrimary') // Selecciona el botón por la clase 'MuiButton-containedPrimary'
.should('have.text', 'Login in') // Verifica el texto del botón si es necesario
.click();
cy.contains('Login Exitoso'); // Verifica que se muestre el mensaje de éxito
cy.intercept('GET', '**/*', (req) => {
req.continue(); // Continuar con la solicitud sin mostrarla en la consola
cy.get('.MuiButton-containedPrimary').click();
//cy.contains('Login Exitoso');
cy.wait(3000)
// Obtener el token de la respuesta del login
cy.getCookie('tokenDentelX').then((tokenCookie) => {
const token = tokenCookie.value;

// Realizar solicitudes a la API con el token
cy.request({
method: 'GET',
url: 'https://dtxbackend.onrender.com/api/patients/649be3a8684dc54c7b7ba6db?searchQuery=',
headers: {
Authorization: `Bearer ${token}` // Incluir el token en las cabeceras
}
}).then((response) => {
// Aquí puedes realizar verificaciones en la respuesta de la API
// ...
});
});
});


});
10 changes: 10 additions & 0 deletions cypress/plugins/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const { initPlugin } = require('cypress-plugin-snapshots/plugin');

module.exports = (on, config) => {
initPlugin(on, config);

// Agrega Mochawesome a la configuración
on('after:run', (results) => {
require('mochawesome/generate')(results);
});
};
Loading

0 comments on commit 4e88d25

Please sign in to comment.