Skip to content

fix(e2e): stabilize Cypress login on custom login pages#1282

Merged
superdav42 merged 2 commits into
mainfrom
fix/e2e-login-password-reset-ci
May 27, 2026
Merged

fix(e2e): stabilize Cypress login on custom login pages#1282
superdav42 merged 2 commits into
mainfrom
fix/e2e-login-password-reset-ci

Conversation

@superdav42
Copy link
Copy Markdown
Collaborator

@superdav42 superdav42 commented May 27, 2026

Summary

Follow-up for #1281 after the original PR merged while Cypress was still running.

Verification

  • node --check tests/e2e/cypress/support/commands/login.js — passed.
  • php -l tests/e2e/cypress/fixtures/setup-password-reset-subsite.php — passed.
  • vendor/bin/phpcs tests/e2e/cypress/fixtures/setup-password-reset-subsite.php — passed.
  • wp eval-file tests/e2e/cypress/fixtures/setup-password-reset-subsite.php — returned filter_ran: true, non-wp-login.php rewritten URL, and preserved wp_lang.
  • npx cypress run -b chrome --config-file cypress.config.test.js --spec 'tests/e2e/cypress/integration/011-password-reset-subsite-domain.spec.js,tests/e2e/cypress/integration/030-modal-form-error-handling.spec.js' — local environment blocked because http://localhost:8889 was not running; CI is authoritative for the wp-env Cypress target.

For #1281

Summary by CodeRabbit

  • Tests
    • Improved login test reliability to handle optional form elements and flexible page path matching.

Review Change Stack

@superdav42
Copy link
Copy Markdown
Collaborator Author

superdav42 commented May 27, 2026

MERGE_SUMMARY

Summary

  • Stabilized Cypress login setup for custom login pages that do not render a #rememberme checkbox.
  • Relaxed post-login path assertions to accept network-admin redirects under /wp-admin.
  • Switched the modal-form error-handling spec to API login so its target assertions are not blocked by UI-login page shape.

Verification

  • node --check tests/e2e/cypress/support/commands/login.js — passed.
  • node --check tests/e2e/cypress/integration/030-modal-form-error-handling.spec.js — passed.
  • php -l tests/e2e/cypress/fixtures/setup-password-reset-subsite.php — passed.
  • vendor/bin/phpcs tests/e2e/cypress/fixtures/setup-password-reset-subsite.php — passed.
  • wp eval-file tests/e2e/cypress/fixtures/setup-password-reset-subsite.php — returned the expected rewritten reset URL data.
  • Local Cypress run could not start because http://localhost:8889 was unavailable; GitHub Actions Cypress checks are authoritative.

Commit: 1827b0d

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 27, 2026

📝 Walkthrough

Walkthrough

The Cypress login command is made more resilient to varying page structures. The loginByForm helper conditionally clicks the remember-me checkbox only when it exists on the page, and the post-login assertion checks for the /wp-admin path substring instead of requiring an exact match.

Changes

Login form robustness improvements

Layer / File(s) Summary
Conditional remember-me handling and flexible pathname assertion
tests/e2e/cypress/support/commands/login.js
loginByForm checks for #rememberme element presence before clicking, and pathname validation switches from exact "/wp-admin/" match to substring inclusion of "/wp-admin" to tolerate URL variations.

Possibly related PRs

Poem

🐰 A form that doubts before it clicks,
checks for the box with cautious tricks,
and paths that flow from /wp-admin's glow—
resilience grows where tests now know. ✨

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~5 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: fixing Cypress login stability on custom login pages, which directly corresponds to the PR's primary objective of making login tests tolerant of custom login pages.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/e2e-login-password-reset-ci

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link
Copy Markdown

🔨 Build Complete - Ready for Testing!

📦 Download Build Artifact (Recommended)

Download the zip build, upload to WordPress and test:

🌐 Test in WordPress Playground (Very Experimental)

Click the link below to instantly test this PR in your browser - no installation needed!
Playground support for multisite is very limitied, hopefully it will get better in the future.

🚀 Launch in Playground

Login credentials: admin / password

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@tests/e2e/cypress/support/commands/login.js`:
- Around line 45-49: The indentation in the added block using
cy.get("body").then(...) uses spaces; update the indentation to use tabs
consistent with the project's JS coding guidelines. Locate the block containing
cy.get("body").then(($body) => { ... }) and replace the leading spaces on each
line inside that function (including the if ($body.find("`#rememberme`")...) line
and the cy.get("`#rememberme`")... line) with tabs so the file uses tabs for
indentation throughout.
- Line 59: Update the assertion that currently reads `.and("include",
"/wp-admin")` to use an anchored regex match so the pathname must start with
`/wp-admin` (e.g., change to a `.and("match", /^\/wp-admin/)` style check) and
convert the indentation on that line (and its surrounding lines if affected)
from spaces to a single tab to comply with the project JS indentation rule; look
for the assertion chain involving `.and("include", "/wp-admin")` in the login
command and replace it with the anchored regex match and tab-indented line.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: f8836d2f-1d5f-4a48-885c-f29abd1c72d0

📥 Commits

Reviewing files that changed from the base of the PR and between eb80084 and e143da7.

📒 Files selected for processing (1)
  • tests/e2e/cypress/support/commands/login.js

Comment on lines +45 to +49
cy.get("body").then(($body) => {
if ($body.find("#rememberme").length) {
cy.get("#rememberme").should("be.visible").and("not.be.checked").click();
}
});
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical | ⚡ Quick win

Use tabs for indentation per coding guidelines.

The added lines use spaces for indentation, but the coding guidelines require tabs for all *.js files. As per coding guidelines, "indentation must be tabs".

🛠️ Proposed fix to convert spaces to tabs
-      cy.get("body").then(($body) => {
-        if ($body.find("`#rememberme`").length) {
-          cy.get("`#rememberme`").should("be.visible").and("not.be.checked").click();
-        }
-      });
+		cy.get("body").then(($body) => {
+			if ($body.find("`#rememberme`").length) {
+				cy.get("`#rememberme`").should("be.visible").and("not.be.checked").click();
+			}
+		});
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
cy.get("body").then(($body) => {
if ($body.find("#rememberme").length) {
cy.get("#rememberme").should("be.visible").and("not.be.checked").click();
}
});
cy.get("body").then(($body) => {
if ($body.find("`#rememberme`").length) {
cy.get("`#rememberme`").should("be.visible").and("not.be.checked").click();
}
});
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/e2e/cypress/support/commands/login.js` around lines 45 - 49, The
indentation in the added block using cy.get("body").then(...) uses spaces;
update the indentation to use tabs consistent with the project's JS coding
guidelines. Locate the block containing cy.get("body").then(($body) => { ... })
and replace the leading spaces on each line inside that function (including the
if ($body.find("`#rememberme`")...) line and the cy.get("`#rememberme`")... line)
with tabs so the file uses tabs for indentation throughout.

.should("not.contain", "/wp-login.php")
.and("not.contain", "/login")
.and("equal", "/wp-admin/");
.and("include", "/wp-admin");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical | ⚡ Quick win

Use tabs for indentation and tighten the pathname assertion.

Two concerns:

  1. The line uses spaces for indentation, but the coding guidelines require tabs for all *.js files.
  2. Using .include("/wp-admin") is overly permissive and would match unintended paths like /some-path/wp-admin or /not-wp-admin. To ensure the pathname starts with /wp-admin, use an anchored regex instead.

As per coding guidelines, "indentation must be tabs".

🛠️ Proposed fix
-      .and("include", "/wp-admin");
+		.and("match", /^\/wp-admin/);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
.and("include", "/wp-admin");
.and("match", /^\/wp-admin/);
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/e2e/cypress/support/commands/login.js` at line 59, Update the assertion
that currently reads `.and("include", "/wp-admin")` to use an anchored regex
match so the pathname must start with `/wp-admin` (e.g., change to a
`.and("match", /^\/wp-admin/)` style check) and convert the indentation on that
line (and its surrounding lines if affected) from spaces to a single tab to
comply with the project JS indentation rule; look for the assertion chain
involving `.and("include", "/wp-admin")` in the login command and replace it
with the anchored regex match and tab-indented line.

@superdav42 superdav42 merged commit 90cf9cd into main May 27, 2026
9 of 11 checks passed
@superdav42
Copy link
Copy Markdown
Collaborator Author

Summary

Follow-up for #1281 after the original PR merged while Cypress was still running.

Verification

  • node --check tests/e2e/cypress/support/commands/login.js — passed.
  • php -l tests/e2e/cypress/fixtures/setup-password-reset-subsite.php — passed.
  • vendor/bin/phpcs tests/e2e/cypress/fixtures/setup-password-reset-subsite.php — passed.
  • wp eval-file tests/e2e/cypress/fixtures/setup-password-reset-subsite.php — returned filter_ran: true, non-wp-login.php rewritten URL, and preserved wp_lang.
  • npx cypress run -b chrome --config-file cypress.config.test.js --spec 'tests/e2e/cypress/integration/011-password-reset-subsite-domain.spec.js,tests/e2e/cypress/integration/030-modal-form-error-handling.spec.js' — local environment blocked because http://localhost:8889 was not running; CI is authoritative for the wp-env Cypress target.
    For fix(tours): mark one-shot tours as finished on render to stop them repeating on every page load #1281

Merged via PR #1282 to main.
Merged by deterministic merge pass (pulse-wrapper.sh).


aidevops.sh v3.19.5 spent 37s on this as a headless bash routine.

@github-actions
Copy link
Copy Markdown

Performance Test Results

Performance test results for 98d7902 are in 🛎️!

Note: the numbers in parentheses show the difference to the previous (baseline) test run. Differences below 2% or 0.5 in absolute values are not shown.

URL: /

Run DB Queries Memory Before Template Template WP Total LCP TTFB LCP - TTFB
0 41 37.80 MB 868.00 ms (+23.50 ms / +3% ) 157.00 ms (+12.50 ms / +8% ) 1078.00 ms 2018.00 ms (+50.00 ms / +2% ) 1931.70 ms (+42.30 ms / +2% ) 75.85 ms (-4.85 ms / -6% )
1 56 49.13 MB 952.00 ms 142.50 ms 1093.50 ms 2076.00 ms 2002.15 ms 70.60 ms

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

review-feedback-scanned Merged PR already scanned for quality feedback

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant