From 6dff0614e36df3c43b0e03cb69cc7b52d35b2aab Mon Sep 17 00:00:00 2001 From: David Stone Date: Tue, 26 May 2026 19:25:15 -0600 Subject: [PATCH] fix(e2e): fall back to API login when login form is unavailable --- tests/e2e/cypress/support/commands/login.js | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/tests/e2e/cypress/support/commands/login.js b/tests/e2e/cypress/support/commands/login.js index c49e7c97..ff6ced5a 100644 --- a/tests/e2e/cypress/support/commands/login.js +++ b/tests/e2e/cypress/support/commands/login.js @@ -43,15 +43,22 @@ Cypress.Commands.add("loginByForm", (username, password) => { } cy.get("body").then(($body) => { + if (!$body.find("#user_login").length) { + cy.loginByApi(username, password); + cy.visit("/wp-admin/"); + return; + } + if ($body.find("#rememberme").length) { cy.get("#rememberme").should("be.visible").and("not.be.checked").click(); } + + cy.get("#user_login").should("be.visible").setValue(username); + cy.get("#user_pass") + .should("be.visible") + .setValue(password) + .type("{enter}"); }); - cy.get("#user_login").should("be.visible").setValue(username); - cy.get("#user_pass") - .should("be.visible") - .setValue(password) - .type("{enter}"); }); cy.location("pathname") .should("not.contain", "/wp-login.php")