From aae7350e9ca797fc237f9f01bb66088bfd67658b Mon Sep 17 00:00:00 2001 From: Joe Rafaniello Date: Fri, 13 Jun 2025 18:24:22 -0400 Subject: [PATCH] Cache login across specs Seems to be cached for each spec in a file. The next file will reset the local storage and cookies so it appears to need to be done once per file. Add validation to something that responds quickly..., /api Previously, we'd land on /dashboard/show after login, now, visit a faster page, /utilization after establishing or restoring session. --- cypress/support/commands/login.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/cypress/support/commands/login.js b/cypress/support/commands/login.js index 4ef4c82e802..a7e8043f573 100644 --- a/cypress/support/commands/login.js +++ b/cypress/support/commands/login.js @@ -3,10 +3,18 @@ // user: String of username to log in with, default is admin. // password: String of password to log in with, default is smartvm. Cypress.Commands.add('login', (user = 'admin', password = 'smartvm') => { - cy.visit('/'); + cy.session([user, password], () => { + cy.visit('/dashboard/login'); + cy.get('#user_name').type(user); + cy.get('#user_password').type(password); + cy.get('#login').click(); - cy.get('#user_name').type(user); - cy.get('#user_password').type(password); - return cy.get('#login').click(); + }, { + validate() { + cy.request('/api').its('status').should('eq', 200) + }, + cacheAcrossSpecs: true + }) + cy.visit('/utilization') });