Make WordPress Core

Changeset 65347


Ignore:
Timestamp:
11/09/2026 02:22:32 PM (less than one hour ago)
Author:
lancewillett
Message:

Build/Test Tools: Stop the General Settings E2E specs from running together.

Both General Settings specs save the whole form, which writes every field on the page. When they ran at the same time in the parallel project, one spec's save could undo the other's change. Give both specs the same Playwright test lock, so they never overlap but stay in parallel.

Add a "Parallel safety" section to the E2E README: scope the test data, else lock every spec that writes the shared data, else move the spec to serial.

Developed in: ​https://github.com/WordPress/wordpress-develop/pull/15846

Props adrianmoldovanwp.
See #66392.

Location:
trunk/tests/e2e
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/e2e/README.md

    r65312 r65347  
    5151CI runs `parallel` and `serial` in separate jobs.
    5252
    53 New specs go in `parallel` by default. Add a spec to `SERIAL_SPECS` only if it makes the site unusable for other tests, or if it changes content or settings that other tests use, for example with `requestUtils.deleteAllPosts()`.
     53New specs go in `parallel` by default. Add a spec to `SERIAL_SPECS` if it makes the site unusable for other tests. If it changes content or settings that other tests use, for example with `requestUtils.deleteAllPosts()`, follow [Parallel safety](#parallel-safety).
    5454
    5555Before you open a pull request with a new spec, run its project a few times with `--shuffle`. Playwright then runs the spec files in a random order, so a spec that needs another spec to run first, or that breaks a spec that runs after it, fails:
    … …  
    6060
    6161Playwright prints the seed of each run, for example `shuffle seed 317753389`. To run the same order again, give the seed: `--shuffle 317753389`.
     62
     63## Parallel safety
     64
     65Specs in `parallel` share one site. A test that changes shared data can break a test in another file that runs at the same time. To make a spec safe, use the first of these that works:
     66
     671. Scope the data. Let the test create its own data, for example a post with a unique title, and read only that data.
     682. If the test must change shared data, such as a site setting, give it a lock. Do this only if every spec that writes the same data holds the same lock.
     693. If you cannot lock every spec that writes the data, add the spec to `SERIAL_SPECS`.
     70
     71A lock is a name. Playwright never runs two tests that hold the same lock name at the same time. A lock only schedules tests. It does not isolate data: a test without the lock can still change the data while a locked test runs.
     72
     73The lock names are in `utils/locks.js`. Import the constant, so that all specs use the same name. Playwright gives no error for a lock name that no other test uses, or for an import name that is not in `utils/locks.js`:
     74
     75```
     76import { GENERAL_SETTINGS } from '../utils/locks';
     77
     78test.describe( 'Settings -> General', { lock: GENERAL_SETTINGS }, () => {} );
     79```
     80
     81A form save writes every field on the page, not only the field that the test changed. A spec that saves the General Settings form (`options-general.php`) must hold `GENERAL_SETTINGS`. A spec in `parallel` that changes a General Settings option in a different way, for example with `siteSettings` or `siteOptions`, must also hold it.
    6282
    6383## Logged-out pages
  • trunk/tests/e2e/specs/general-settings-invalid-timezone.test.js

    r65312 r65347  
    11import { test, expect } from '../fixtures';
     2import { GENERAL_SETTINGS } from '../utils/locks';
    23
    3 test.describe( 'Settings -> General', () => {
     4test.describe( 'Settings -> General', { lock: GENERAL_SETTINGS }, () => {
    45        const invalidTimezones = [ '', '0', 'Barry/Gary' ];
    56
  • trunk/tests/e2e/specs/general-settings.test.js

    r65242 r65347  
    11import { test, expect } from '@wordpress/e2e-test-utils-playwright';
     2import { GENERAL_SETTINGS } from '../utils/locks';
    23
    3 test.describe( 'Settings -> General', () => {
     4test.describe( 'Settings -> General', { lock: GENERAL_SETTINGS }, () => {
    45        test( 'Saving General Settings preserves the active theme options', async ( {
    56                admin,
Note: See TracChangeset for help on using the changeset viewer.