From 741c8c1b5668f94fac6487b2873b7d2fbbe2b701 Mon Sep 17 00:00:00 2001 From: David Stone Date: Wed, 10 Jun 2026 07:37:26 -0600 Subject: [PATCH] wip: harden cypress passwordless login helper --- tests/e2e/cypress/support/commands/login.js | 22 ++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/tests/e2e/cypress/support/commands/login.js b/tests/e2e/cypress/support/commands/login.js index 7ddf05f4..2aa10605 100644 --- a/tests/e2e/cypress/support/commands/login.js +++ b/tests/e2e/cypress/support/commands/login.js @@ -43,15 +43,19 @@ Cypress.Commands.add("loginByForm", (username, password) => { } cy.get("body").then(($body) => { - if ($body.find(".wu-passwordless-auth").length) { - cy.get(".wu-passwordless-auth").should("be.visible"); - cy.get(".wu-passwordless-email").should("be.visible"); - if ($body.find("#user_pass").length) { - cy.get("#user_pass").should("not.be.visible"); - } else { - cy.get("#user_pass").should("not.exist"); - } - cy.loginByApi(username, password); + if ($body.find(".wu-passwordless-auth").length) { + const has_password_field = Boolean($body.find("#user_pass").length); + + cy.get(".wu-passwordless-auth").should("be.visible"); + cy.get(".wu-passwordless-email").should("be.visible"); + + if (has_password_field) { + cy.get("#user_pass").should("not.be.visible"); + } else { + cy.get("#user_pass").should("not.exist"); + } + + cy.loginByApi(username, password); cy.visit("/wp-admin/"); return; }