From 49c5ed49b0749ccac65a63d2830f1f05dde3bea2 Mon Sep 17 00:00:00 2001 From: Yisroel Baum Date: Fri, 24 Apr 2026 16:07:07 +0300 Subject: [PATCH] add cypress login commands --- cypress/support/commands.js | 40 ++++++++++++++----------------------- 1 file changed, 15 insertions(+), 25 deletions(-) diff --git a/cypress/support/commands.js b/cypress/support/commands.js index 66ea16e..61e6549 100644 --- a/cypress/support/commands.js +++ b/cypress/support/commands.js @@ -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) => { ... }) \ No newline at end of file +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') +})