Skip to content

Tests: Add E2E tests for Writing Settings - #16376

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

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

Conversation

@shail-mehta

Copy link
Copy Markdown
Member

Trac ticket: #52895

What?

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

Why?

As part of expanding admin E2E test coverage (#52895), general-settings.test.js and reading-settings.test.js already cover Settings screens. Adding coverage for Writing Settings verifies saving core writing options and that the default post category is applied to newly created posts.

How?

  • Added a WRITING_SETTINGS lock in tests/e2e/utils/locks.js so Writing Settings tests do not race with other tests.
  • Added tests/e2e/specs/writing-settings.test.js with two tests using siteOptions.remember() to restore modified options after each test:
    • Saving default_post_format, mailserver_url, mailserver_port, and mailserver_login persists the updated values and displays the Settings saved. notice.
    • Setting default_category in the UI and creating a post verifies the new post inherits that category.
  • Extended numeric option normalization in tests/e2e/fixtures/site.js for default_category and mailserver_port.

Testing Instructions

  1. Run the E2E suite for the new spec:
    npm run test:e2e -- tests/e2e/specs/writing-settings.test.js
  2. Confirm both tests pass and all modified Writing 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 delete the active default category during cleanup, lack coordination with parallel taxonomy tests, and use installation defaults that cannot reliably verify persistence.

3 open issues
What changed in this PR

Adds Playwright coverage for Settings → Writing, extending the existing admin settings tests.

Changes:

  • Tests saving writing options and applying the default category to new posts.
  • Adds a Writing Settings lock.
  • Extends numeric option normalization for fixture restoration checks.
File Description
tests/​e2e/​utils/​locks.js Defines the Writing Settings lock.
tests/​e2e/​specs/​writing-settings.test.js Adds option-saving and default-category tests.
tests/​e2e/​fixtures/​site.js Normalizes numeric Writing options for comparison.

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 writing-settings tests can race with the parallel taxonomy test and fail to restore default_link_category, risking intermittent CI failures and test-state leakage.

No open issues 🎉

1 previously missed issue

In code that hasn't changed since last review

Medium severity Restore default_link_category after the test

tests/​e2e/​specs/​writing-settings.test.js:16

Please also remember and restore default_link_category. options.php always updates this Writing option, but options-writing.php omits its input when the link manager is disabled (the default). Saving either test's form therefore changes the installed value from 2 to 0, and the current teardown leaves that change behind. Add it here and to numeric option normalization so restoration comparisons remain reliable.

3 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

Incomplete locking permits parallel-test races that can erase saved update-service URLs and cause intermittent category-management test failures.

No open issues 🎉

1 previously missed issue

In code that hasn't changed since last review

High severity Acquire the Reading lock to prevent losing ping_sites

tests/​e2e/​specs/​writing-settings.test.js:12

Please also acquire READING_SETTINGS to prevent this spec from overlapping with Reading's blog_public changes. If Writing loads while the site is private but submits after Reading restores public visibility, options.php clears the omitted ping_sites field, and neither spec restores it. Holding both locks prevents this interleaving and the lasting loss of update-service URLs.

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 writing-settings test changes the default category without coordinating with the parallel taxonomy bulk-delete test, creating a race that can intermittently fail its checkbox assertion.

1 open issue

Review effort: Balanced

@shail-mehta
shail-mehta marked this pull request as ready for review December 2, 2026 14:39
@github-actions

github-actions Bot commented Dec 2, 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.

Please have the category bulk-delete test in taxonomies.test.js take the same WRITING_SETTINGS lock. Both specs run in the parallel project. While this test makes its temporary category the default, the Uncategorized row gains a checkbox, and the taxonomy test expects it to have none. The restore in finally runs after that window. Sharing the lock for just the affected test would keep the rest of the taxonomy suite parallel.

AI review · gpt-6.2-astra

Add Playwright E2E coverage for Settings -> Writing (options-writing.php), including saving writing options and verifying the default post category. Uses siteOptions.remember() and a WRITING_SETTINGS lock for isolation.

See #52895.
Restore the original default category before deleting the temporary term, and use non-default mail server values so save assertions verify persistence.

See #52895.
options.php always updates default_link_category on Writing saves, but options-writing.php omits the field when the link manager is disabled, so remember and restore it to avoid leaving 0 behind.

See #52895.
Prevent a parallel Reading test from flipping blog_public while Writing saves, which can clear ping_sites when that option becomes allowed without a form field.
@shail-mehta
shail-mehta force-pushed the tests/52895-writing-settings-e2e branch from 3b63719 to 77e57f1 Compare December 3, 2026 11:02
@shail-mehta
shail-mehta force-pushed the tests/52895-writing-settings-e2e branch from 77e57f1 to 7912f20 Compare December 3, 2026 11:04
@shail-mehta
shail-mehta requested a balanced review from Copilot December 3, 2026 11:05

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 writing-settings tests use CSS ID locators instead of the required getByLabel(), bypassing checks for broken label associations.

2 open issues

Review effort: Balanced

@shail-mehta

Copy link
Copy Markdown
Member Author

Thanks for the review. Addressed in the latest push - the category bulk-delete test in taxonomies.test.js now takes the WRITING_SETTINGS lock, so it won’t overlap with the Writing Settings default-category change. The rest of the taxonomy suite stays unlocked/parallel.

@shail-mehta shail-mehta self-assigned this Dec 3, 2026

@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.

The shared lock addresses my earlier request. One change remains before landing. Please use getByLabel() for the five Writing Settings controls with explicit labels, as the E2E locator guide asks. For example, page.getByLabel( 'Default Post Category', { exact: true } ) exercises the label association when selecting the category. The other labels are Default Post Format, Mail Server, Port and Login Name.

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

No active review issues were identified in the Writing settings E2E coverage and supporting test changes.

No open issues 🎉

2 resolved since last review

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.

The five form controls now use their visible labels. The Writing, Reading and taxonomy specs passed together in 42 single-worker cases and 84 parallel cases. The shared lock also addresses the default-category race we reproduced during the earlier review. Thanks for following through on both changes.

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