Changeset 65347
- Timestamp:
- 11/09/2026 02:22:32 PM (less than one hour ago)
- Location:
- trunk/tests/e2e
- Files:
-
- 1 added
- 3 edited
-
README.md (modified) (2 diffs)
-
specs/general-settings-invalid-timezone.test.js (modified) (1 diff)
-
specs/general-settings.test.js (modified) (1 diff)
-
utils/locks.js (added)
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/e2e/README.md
r65312 r65347 51 51 CI runs `parallel` and `serial` in separate jobs. 52 52 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()`.53 New 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). 54 54 55 55 Before 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: … … 60 60 61 61 Playwright 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 65 Specs 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 67 1. Scope the data. Let the test create its own data, for example a post with a unique title, and read only that data. 68 2. 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. 69 3. If you cannot lock every spec that writes the data, add the spec to `SERIAL_SPECS`. 70 71 A 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 73 The 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 ``` 76 import { GENERAL_SETTINGS } from '../utils/locks'; 77 78 test.describe( 'Settings -> General', { lock: GENERAL_SETTINGS }, () => {} ); 79 ``` 80 81 A 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. 62 82 63 83 ## Logged-out pages -
trunk/tests/e2e/specs/general-settings-invalid-timezone.test.js
r65312 r65347 1 1 import { test, expect } from '../fixtures'; 2 import { GENERAL_SETTINGS } from '../utils/locks'; 2 3 3 test.describe( 'Settings -> General', () => {4 test.describe( 'Settings -> General', { lock: GENERAL_SETTINGS }, () => { 4 5 const invalidTimezones = [ '', '0', 'Barry/Gary' ]; 5 6 -
trunk/tests/e2e/specs/general-settings.test.js
r65242 r65347 1 1 import { test, expect } from '@wordpress/e2e-test-utils-playwright'; 2 import { GENERAL_SETTINGS } from '../utils/locks'; 2 3 3 test.describe( 'Settings -> General', () => {4 test.describe( 'Settings -> General', { lock: GENERAL_SETTINGS }, () => { 4 5 test( 'Saving General Settings preserves the active theme options', async ( { 5 6 admin,
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)