Make WordPress Core

Opened 3 hours ago

Last modified 3 hours ago

#66324 new defect (bug)

The wp.updates QUnit tests have never run

Reported by: dlocc Owned by:
Priority: normal Milestone: Awaiting Review
Component: Build/Test Tools Version: 4.6
Severity: normal Keywords: has-patch has-unit-tests
Cc: Focuses: javascript

Description

tests/qunit/wp-admin/js/updates.js and tests/qunit/fixtures/updates.js were added with Shiny Updates in [37714], along with the update count markup in tests/qunit/index.html. But index.html never loads the fixture, updates.js, or the tests, so none of the wp.updates tests have ever run.

Loading them shows one more problem. The fixture sets totals: {}, so wp.updates.decrementCount() throws on settings.totals.counts. Because that error escapes the test, QUnit also reports it as a "Script error." on an unrelated wpapi test.

With the three script tags added and the fixture's totals filled in to match its markup, the full suite passes: 704 of 704 assertions, including the 38 wp.updates ones, on both index.html and the minified compiled.html (npm run grunt qunit:compiled).

#59644 plans to move these tests off QUnit. Getting them running first means they come along when that happens.

I found this while working on #66315, where a tester suggested adding assertions to this file. I have a patch ready and will link the PR here.

Change History (1)

This ticket was mentioned in ​PR #14319 on ​WordPress/wordpress-develop by ​@dlocc.


3 hours ago
#1

  • Keywords has-patch has-unit-tests added

The QUnit tests and fixture for wp.updates were added with Shiny Updates in [37714] (WordPress 4.6), but tests/qunit/index.html never loaded them, or updates.js itself, so they have never run.

This PR:

  • Loads tests/qunit/fixtures/updates.js, build/wp-admin/js/updates.js, and tests/qunit/wp-admin/js/updates.js in tests/qunit/index.html.
  • Fills in the update totals in the fixture to match its markup (2 plugin updates). With totals: {}, wp.updates.decrementCount() throws on settings.totals.counts. Because that error escapes the test, QUnit also reports it as a "Script error." on an unrelated wpapi test.

#59644 plans to move these tests off QUnit. Getting them running first means they come along when that happens.

Testing Instructions

  1. Run npm run grunt qunit:compiled, which is what CI runs.
  2. Before (trunk): 666 assertions pass, and none of them are from wp.updates.
  3. After: 704 of 704 pass on both index.html and the minified compiled.html, including the 38 wp.updates assertions.

Use of AI Tools

AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Opus 5.5
Used for: Finding that the suite never ran, writing the patch, and running the QUnit suite before and after. I reviewed the code and the test results before submitting.

Note: See TracTickets for help on using tickets.