Repository navigation
Fix media suggestion order and run the QUnit tests in CI - #53
Draft
JeroenDeDauw wants to merge 3 commits into
Draft
JeroenDeDauw wants to merge 3 commits into
JeroenDeDauw wants to merge 3 commits into
Conversation
Both jobs have failed at their Composer install step since 2026-08-24. mediawiki/mediawiki-codesniffer ^46.0.0 resolves only to 46.0.0, which pins squizlabs/php_codesniffer 3.11.3, and Composer blocks that version under security advisory PKSA-rdkp-vv9z-mjkg. Codesniffer 52 pins the fixed 3.13.6. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
JeroenDeDauw
force-pushed
the
fix/mediasuggester-follow-up
branch
2 times, most recently
from
November 11, 2026 21:27
93acdbd to
bbecd5d
Compare
Before #52, a response without a search list, such as an API error, left the search pending, so the input kept its loading state. The test pins that search() now resolves with no suggestions. 'search integration' now reads the requested term from the request, not from a property set on the result array. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The comparator that puts files starting with the search term first returned -1 whenever its first file matched, also when both files did, which breaks the sort contract. V8 then reversed the matching files: for the term Foo and the search results Foo 1, Bar foo, Foo 2, Foo 3, Baz foo, Chrome and Edge listed Foo 3, Foo 2, Foo 1, Bar foo, Baz foo. Firefox happened to keep the intended order. The comparator now returns 0 within a group, so the stable sort keeps the API's relevance order in both: Foo 1, Foo 2, Foo 3, Bar foo, Baz foo. The new test replaces the three-hit ordering test, whose single match it covers. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
JeroenDeDauw
force-pushed
the
fix/mediasuggester-follow-up
branch
from
November 11, 2026 22:50
bbecd5d to
e6a5e34
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follows-up to #52
In Chrome and Edge, media suggestions starting with the typed term came out in reverse search order. For the term
Fooand the search results Foo 1, Bar Foo, Foo 2, Foo 3, Baz foo, the suggester gave Foo 3, Foo 2, Foo 1, Bar Foo, Baz foo; it now gives Foo 1, Foo 2, Foo 3, Bar Foo, Baz foo. This PR also tests the API error response that #52 fixed, and repairs the PHPStan and Code style jobs, which had failed at Composer install since 2026-08-24.Pending: a CI job for the QUnit tests, which CI never ran. Pushing it needs the
workflowscope on this branch's token; nothing else here depends on it.Human input
Goal and shape: goal from @JeroenDeDauw, shape Claude's.
Outcome: not reviewed by a human yet. Left for you: the order in Chrome on a wiki (matching is case-sensitive), and the QUnit job once it is in.
Claude's calls
Array.prototype.sortbeing stable, as it is in every browser MediaWiki supports.^52, as in Bump mediawiki-codesniffer to ^52 to unblock Composer Maps#938; you now need PHP 8.3 to install the dev tools locally.npm run qunit, because in Firefox the order test passes even with the old comparator. It installs Wikibase from git, because the dist archive lacks the submodules the suggester needs.Changes
resources/jquery.ui.mediasuggester.js: the comparator returned -1 whenever its first argument matched, also when both did; it now returns 0 within a group. The doc comment now states the prefix rule.tests/js/jquery.ui.mediasuggester.tests.js: the error-response test, and the order test, which replaces 'put matching file name on top of result list'. 'search integration' no longer depends on getting the API's own array back.composer.json: codesniffer 46.0.0 pinssquizlabs/php_codesniffer3.11.3, which Composer blocks under advisory PKSA-rdkp-vv9z-mjkg; 52 pins the fixed 3.13.6.Verification evidence
CI on e6a5e34: https://github.com/ProfessionalWiki/WikibaseLocalMedia/actions/runs/43115093969, 10 of 10 jobs green. Code style ran codesniffer 52.0.1 over 14 files with no findings, PHPStan 2.3.5 reported nothing, and PHPUnit passed on REL1_40 to REL1_46 and master.
QUnit in V8 (Node 24, jsdom, jQuery 3.7.1, jQuery UI and Wikibase's suggester from a MediaWiki 1.43 tree):
AI review (pr-review with code-review, security-review, review-tests and a design pass): goal sound, design good-enough, no blocking findings. Its test findings are applied.