add cypress login commands

This commit is contained in:
Yisroel Baum 2026-04-24 16:07:07 +03:00
parent 95f7f1cb78
commit 49c5ed49b0
Signed by: yisroelbaum
GPG key ID: 0FA60884F75520A9

View file

@ -1,25 +1,15 @@
// ***********************************************
// 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) => { ... })
Cypress.Commands.add('login', (email, password) => {
cy.request({
method: 'POST',
url: '/api/auth/login',
body: { email, password },
})
})
Cypress.Commands.add('loginAsAdmin', () => {
cy.login('admin@example.com', 'admin1234')
})
Cypress.Commands.add('loginAsUser', () => {
cy.login('user@example.com', 'password1')
})