Skip to content

Tests: Add E2E tests for Permalink Settings - #16449

Open
shail-mehta wants to merge 6 commits into
WordPress:trunkfrom
shail-mehta:tests/52895-permalink-settings-e2e
Open

shail-mehta wants to merge 6 commits into
WordPress:trunkfrom
shail-mehta:tests/52895-permalink-settings-e2e

Conversation

@shail-mehta

Copy link
Copy Markdown
Member

Trac ticket: #52895

What?

Adds Playwright E2E tests for the Settings → Permalinks (options-permalink.php) admin screen.

Why?

As part of expanding admin E2E test coverage #52895, General, Reading, Privacy, and Writing Settings already have coverage. Adding Permalink Settings verifies that custom category/tag bases persist and are used for category archive URLs.

How?

  • Added a PERMALINK_SETTINGS lock in tests/e2e/utils/locks.js.
  • Added tests/e2e/specs/permalink-settings.test.js with two tests:
    • Saving non-default category_base and tag_base values persists them and shows Permalink structure updated.
    • Setting a custom category base and opening a category archive verifies the URL uses that base.
  • Restores original permalink options and flushes rewrite rules after each test.

Testing Instructions

  1. Run:
    npm run test:e2e -- tests/e2e/specs/permalink-settings.test.js
  2. Confirm both tests pass and permalink options are restored afterward.

Use of AI tools

  • Assisted by Cursor.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

The tests leave permalink options inconsistent with restored rewrite rules, and the empty-category heading assertion times out and would still fail with posts because of its prefix.

2 open issues
What changed in this PR

Expands WordPress admin end-to-end coverage with Playwright tests for Settings → Permalinks, supporting #52895.

Changes:

  • Tests custom category/tag base persistence and category archive routing.
  • Adds a permalink-settings lock.
  • Adds cleanup intended to restore options and flush rewrite rules.
File Description
tests/​e2e/​utils/​locks.js Adds the permalink-settings lock constant.
tests/​e2e/​specs/​permalink-settings.test.js Adds two permalink tests and cleanup logic.

Review effort: Balanced

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

The tests incorrectly expect leading slashes in normalized input values, and failed category deletion can skip cleanup, leaving rewrite rules that affect subsequent tests.

2 open issues
2 resolved since last review

Review effort: Balanced

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔵 Needs a closer look

The permalink-only lock leaves settings saves able to overlap with other suites, risking lost notices and intermittent failures unless serialization or a shared lock covers the saves and redirected page loads.

No open issues 🎉

1 previously missed issue

In code that hasn't changed since last review

Medium severity Serialize settings specs that share the settings_errors transient

tests/​e2e/​specs/​permalink-settings.test.js:27

This permalink-only lock allows saves to overlap with the General and Reading settings tests in the parallel project. These forms write the same settings_errors transient, which the redirected page consumes and deletes, so overlapping saves can replace or remove the expected notice and cause intermittent failures. Add this spec to SERIAL_SPECS in tests/e2e/playwright.config.js, or coordinate the settings suites with a shared lock covering each save and redirected page load.

2 resolved since last review

Review effort: Balanced

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues were identified for the added permalink-settings E2E coverage.

No open issues 🎉

Review effort: Balanced

@shail-mehta
shail-mehta marked this pull request as ready for review December 3, 2026 13:09
@github-actions

github-actions Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs.

Core Committers: Use this line as a base for the props when committing in SVN:

Props shailu25, lancewillett.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.


Props Bot commands

You can trigger Props Bot actions by commenting on this PR:

  • @propsbot add <username> to give props to a GitHub or WordPress.org user. Requires write access.
  • @propsbot remove <username> to leave a user out of the props. Requires write access.
  • @propsbot refresh to refresh this list. Adding the props-bot label works too.

@lancewillett lancewillett left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Could you cover this in one trip through Settings → Permalinks? Both tests set the same category base, submit the same form, and check the same notice and saved category value. Set both bases in that submission, check the persisted tag and category values after the redirect, then visit the category archive. That keeps the distinct checks and removes one settings save and restore per run.

You can also use the values returned by siteOptions.remember() as the snapshot for cleanup. The current beforeEach remembers all three options and each test immediately reads them again. Keep the rewrite flush after restoration and keep the lock. With the lock, 10 repeated cases passed. Removing it reproduced a lost tag-base value and a restore mismatch.

AI review · gpt-6.2-astra

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Approval recommended

There are no active review issues for the added permalink-settings end-to-end coverage.

No open issues 🎉

Review effort: Balanced

@lancewillett lancewillett left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for consolidating this. One form submission now checks that both bases persist and that the custom category URL serves the right archive. The revised test passed five repeats with four workers, and all ten adjacent taxonomy cases passed. I also checked that the options, rewrite rules and category list returned to their starting values.

AI review · gpt-6.2-astra

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

Labels

None yet

Projects

Status: In review

Development

Successfully merging this pull request may close these issues.

3 participants