Repository navigation
Conversation
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
2b61ca8 to
b7e4305
Compare
Sinon 22 includes `@sinonjs/fake-timers` 15, which fakes the global `Intl` object when a clock is installed. The faked object cannot be stubbed because `Intl.hasOwnProperty` is overwritten with a boolean, which breaks the `communityEvents.getTimeZone` tests that stub `Intl.DateTimeFormat.prototype.resolvedOptions()`. Since `sinon-test` installs fake timers for every QUnit test, `Intl` is now excluded from faking through `toNotFake`.
`sinon-test` was only used to wrap every QUnit test in a sandbox with fake timers. Sinon 20 removed the fake server that `sinon-test` also enabled by default, and since Sinon 21.1 `sinon-test` 3.x leaves injected properties on the test context after restoring. The same behavior is now provided through QUnit's global `beforeEach` and `afterEach` hooks, which install sinon's fake timers as `this.clock` before each test and restore them, along with any stubs and spies, afterward.
b7e4305 to
beb3ada
Compare
|
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: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. Props Bot commandsYou can trigger Props Bot actions by commenting on this PR:
|
lancewillett
left a comment
There was a problem hiding this comment.
The dependency update preserves the existing assertions, but removing fake XHR also removes isolation from the plugin/theme update tests.
I compared the same 13 existing tests in a reduced browser runner with a local HTTP server:
- Base: 38 assertions passed, 10 fake XHRs, zero HTTP POSTs.
- This head: 38 assertions passed, 10 native HTTP POSTs.
- This head with a module-scoped Ajax stub: 38 assertions passed, zero POSTs.
With controlled 503 responses, all 10 completion callbacks ran after QUnit finished; nine error paths called addAdminNotice. I did not observe cross-test failures or changed lock/queue values, so this is evidence of lost transport isolation and late callbacks, not a demonstrated intermittent test failure.
Please replace the jQuery.ajax call-through spies in the plugin and theme module setups with stubs returning a fresh pending jQuery.Deferred().promise( { abort: jQuery.noop } ). This preserves their URL/action/slug assertions and the old unanswered-fake-XHR behavior. Keep teardown restoring the stub, then run both full QUnit pages on the final patch. My comparison was a reduced runner, not a full-suite validation.
AI review · gpt-6
This updates
sinonfrom 16.1.3 to 22.1.0 and removes thesinon-testdependency.Update
sinonto 22.1.0Sinon 22 ships
@sinonjs/fake-timers15, which fakes the globalIntlobject when a clock is installed. The faked object cannot be stubbed (Intl.hasOwnPropertyis overwritten with a boolean), which breaks thecommunityEvents.getTimeZonetests that stubIntl.DateTimeFormat.prototype.resolvedOptions().Intlis now excluded from faking withtoNotFake: [ 'Intl' ].The upgrade also drops
niseand its dependencies (just-extend,path-to-regexp,lodash.get,@sinonjs/text-encoding) from the lockfile.Remove
sinon-testsinon-testwas only used to wrap every QUnit test in a sandbox with fake timers. Sinon 20 removed the fake server thatsinon-test3.x enabled by default, and since Sinon 21.1,sinon-test3.x leaves injected properties such asthis.clockon the test context after restoring. Instead of updating tosinon-test4.0.0, the same behavior is now provided by QUnit's global hooks intests/qunit/index.html:Behavior changes to be aware of
sinon-testfakedXMLHttpRequestfor every test. Sinon 20 removed the fake server, so that no longer happens with eithersinon-testversion. Thewp.updatestests spy onjQuery.ajaxwithout stubbing it, so those requests are now real.sinon-testonly faked timers while the test callback ran (or until a returned promise settled). Forassert.async()tests, timers became real again as soon as the callback returned. The global hooks keep timers faked from before a module'sbeforeEachuntil after itsafterEach, including the asynchronous part ofassert.async()tests.sinon.restore(), even when a test forgets to restore them.this.stub(),this.spy(),this.mock(), etc. are no longer injected into the test context, and mock expectations are no longer verified automatically. None of the current tests use these.Testing
npm run grunt qunit:compiledpasses locally (713/713 assertions for bothindex.htmlandcompiled.html) with QUnit 3.0.0.Trac ticket: https://core.trac.wordpress.org/ticket/64228
Use of AI Tools
AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Opus 5.5
Used for: Investigating the Sinon 22 test failures, rebasing, removing
sinon-test, running the QUnit suite, and drafting this description. All changes were reviewed by me.This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.
🤖 Generated with Claude Code