Fix unit tests in WP 7.0-alpha after Script Loader updated to use HTML API to generate SCRIPT tags#2353
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## trunk #2353 +/- ##
=======================================
Coverage 69.17% 69.17%
=======================================
Files 90 90
Lines 7708 7708
=======================================
Hits 5332 5332
Misses 2376 2376
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Sorry 😁 Things are working as expected, right? It's a shame |
|
It's all good. This is to be expected. I'm hoping to start leveraging |
|
An alternative is to copy this function and this method for the interim. If you put it in a trait, you can use it only in the classes that require it and cleanup should be simple. |
There was a problem hiding this comment.
Pull request overview
This PR fixes unit test failures caused by WordPress 7.0-alpha's Script Loader update that now uses the HTML API to generate SCRIPT tags. The HTML API produces script tags with attributes in a different order than the previous implementation, requiring test expectations to be updated.
Changes:
- Updated expected HTML strings in web-worker-offloading tests to match new attribute ordering
- Added attribute normalization logic in test assertions to handle ordering differences
- Updated optimization-detective regex pattern to accommodate both attribute orderings
- Refactored embed-optimizer tests to use WP_HTML_Tag_Processor for more robust assertions
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| plugins/web-worker-offloading/tests/test-web-worker-offloading.php | Updated expected script tag strings and added normalization functions to sort attributes before comparison |
| plugins/optimization-detective/tests/class-optimization-detective-test-helpers.php | Modified regex pattern to match both possible attribute orderings for script tags |
| plugins/embed-optimizer/tests/test-hooks.php | Replaced string-based assertions with WP_HTML_Tag_Processor for parsing script attributes |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
See Core-64500 and r61485 (WordPress/wordpress-develop@37bee55)
cc @sirreal