Skip to content

Tests: Group tests that depend on Core assets - #13522

Open
lancewillett wants to merge 2 commits into
WordPress:trunkfrom
lancewillett:tests/65889-asset-dependent-group
Open

lancewillett wants to merge 2 commits into
WordPress:trunkfrom
lancewillett:tests/65889-asset-dependent-group

Conversation

@lancewillett

@lancewillett lancewillett commented Sep 14, 2026

Copy link
Copy Markdown
Member

Some PHPUnit tests depend on Core JavaScript and CSS files, so they must remain covered when testing is narrowed for frontend-only changes.

Add an assets group to 17 existing test methods covering shortcode regex parity, oEmbed rendering, CSS inlining and hoisting, admin view-transition CSS, and generated script-module files. The annotations allow --group assets selection while keeping every test in its normal suite.

The selection includes the methods identified by the empty-assets experiment in Trac comment 4, plus nearby tests that read assets or require them to exist. Emptying a file does not necessarily fail tests whose expectations are derived from that file.

This PR adds test annotations only. Workflow routing is proposed separately in PR #13523, which depends on this group landing first. Bundled-theme metadata, test fixtures, and build tooling still need normal testing; this group does not establish that every .js or .css change can use reduced coverage.

Trac ticket: https://core.trac.wordpress.org/ticket/65889

Testing notes

Validation with PHP 8.3.32, MySQL 9.7.2, and PHPUnit 9.6.36:

  • --group assets: 33 tests / 301 assertions passed on both single site and multisite.
  • Generated script-module file check explicitly executed: 1 test / 59 assertions passed.
  • PHPCS passed all six modified files.
  • Assets built with npm run build:dev in Node 24 Docker.

An earlier isolated experiment emptied 1,295 source and generated .js/.css files under src/js/, src/wp-admin/css/, src/wp-admin/js/, src/wp-includes/css/, src/wp-includes/js/, and src/wp-includes/build/ after building. Bundled themes and test fixtures were kept intact.

  • Full single-site run: 26,234 tests; full multisite run: 27,074 tests.
  • Both runs reproduced the same 10 failures covered by this group: shortcode regex parity, eight late-style-hoisting datasets, and admin view-transition CSS.
  • Both also hit Tests_Image_Functions::test_wp_crop_image_with_url. That test still failed alone after restoring assets (error_loading_image: File does not exist? for the remote image), so it was not attributed to asset truncation.
  • All 1,295 assets were restored and verified against their original SHA-256 hashes. The restored assets group passed again: 23 tests / 253 assertions.

The full runs were not green: each reported 11 failures and 86 warnings, with 44 single-site skips and 46 multisite skips. The result supports the group for the tested asset paths; it is not a claim of exhaustive coverage for every frontend file.

Review follow-up

Added the ten methods identified in Adrian’s review: eight oEmbed output tests, test_get_post_embed_html(), and test_wp_enqueue_view_transitions_admin_css().

Missing-file checks complement the earlier file-truncation experiment:

  • Temporarily removing wp-embed-template.css or wp-embed-template.js caused the newly selected oEmbed output test to error.
  • Temporarily removing wp-embed.js caused the newly selected test_get_post_embed_html() to error.
  • Removing view-transitions.css emitted a warning, but the enqueue-only test still passed. Its group annotation includes the asset read in reduced runs; the existing test_inline_css_included() supplies the content assertion.
  • All four files were restored and verified against their original SHA-256 hashes.

The neighboring tests in these two files were checked for the same dependency; no additional annotations were identified there.

Use of AI tools

AI assistance: Yes.
Tool: Codex.
Model: GPT-6.
Used for: Auditing asset-dependent tests, adding group annotations, and local validation.

@github-actions

github-actions Bot commented Sep 14, 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. You can also manually ask me to refresh this list by adding the props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props lancewillett, adrianmoldovanwp.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

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

The following tests also read Core assets but have no @group assets. A missing file fails them in the full suite, but the reduced job in #13523 never runs them.

@lancewillett

Copy link
Copy Markdown
Member Author

Thanks, Adrian. Added all ten annotations in d566a19.

The expanded assets group passes 33 tests / 301 assertions in both single-site and multisite. PHPCS passes all six PR files.

Missing-file probes now complement the earlier truncation experiment: removing either embed template asset or wp-embed.js causes a newly selected test to error. One nuance: the view-transition enqueue test emits a missing-file warning but still passes; the existing inline-CSS test supplies the content assertion. All moved files were restored and hash-verified.

These paths already select the assets job in #13523. Both PR descriptions now include the updated validation; #13522 still needs to land first. CI is running on the new commit.


Adversarial review · gpt-6

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.

2 participants