Skip to content

Add regression tests for Wicket.Palette and Wicket.trapFocus focus handling - #1621

Open
reiern70 wants to merge 2 commits into
masterfrom
reiern70/issue-1618-master-palette-trapfocus-tests
Open

reiern70 wants to merge 2 commits into
masterfrom
reiern70/issue-1618-master-palette-trapfocus-tests

Conversation

@reiern70

@reiern70 reiern70 commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

Summary

wicket-10.x (10.9.0+) had two TypeError bugs caused by the jQuery 4.0.0 migration mechanically rewriting .focus() calls as .trigger('focus') without checking whether the receiver was a jQuery object:

master was never affected by either — it had already dropped jQuery from both palette.js and trap-focus.js and calls .focus() directly on native DOM elements. But master had no test coverage that would have caught this class of regression if it were reintroduced, and wicket-extensions' client-side JavaScript had no QUnit harness at all (only wicket-core's was wired into the grunt/-Pjs-test build).

Changes

Two commits, mirroring the wicket-10.x fix PR (#1619):

  1. Adds a QUnit harness for wicket-extensions (wicket-extensions/src/test/js/), wired into the grunt/-Pjs-test build via a second connect server target (port 38888), and a regression test for Wicket.Palette.moveUp/moveDown.
  2. A regression test for Wicket.trapFocus's Tab/Shift+Tab boundary wrapping.

Both tests run against master's dual client-side engines — the jQuery-based wicket-ajax-jquery.js and the jQuery-free wicket-ajax.js — matching how wicket-core's own tests already run (qunit:all vs qunit:vanilla).

Test plan

  • grunt jshint connect qunit:all qunit:vanilla in testing/wicket-js-tests — all green in both engines.
  • ApacheLicenceHeaderTest passes for the new .html/.js files.

wicket-10.x (10.9.0 through 10.11.0) had a bug where
Wicket.Palette.moveUpHelper called box.trigger('focus') on a plain
DOM <select> element, throwing a TypeError and silently discarding
the reorder before the hidden recorder input was updated. See GitHub
issue #1618, fixed on wicket-10.x in commit 432a7fe.

master was never affected - it dropped jQuery from palette.js and
calls box.focus() directly - but had no test coverage of its own
that would have caught the same class of regression. Adds a QUnit
harness for wicket-extensions' client-side JavaScript (none existed;
only wicket-core's was wired into the grunt/js-test build) and a
regression test asserting that moveUp/moveDown reorder the selection
and update the recorder without throwing, run against both the
JQuery-based and the JQuery-free wicket-ajax engine.
wicket-10.x had a bug where the keydown handler in trap-focus.js
called .trigger('focus') on plain DOM elements returned by
$focusable.get(...), throwing a TypeError instead of wrapping focus
around the trap's boundary. See GitHub issue #1620, fixed on
wicket-10.x in commit cc29182.

master was never affected - it dropped jQuery from this file and
calls .focus() directly on native DOM elements - but had no test
coverage of its own that would have caught the same class of
regression. Adds a QUnit regression test asserting that Tab/Shift+Tab
at the trap's boundaries move focus to the other end without
throwing, run against both the JQuery-based and the JQuery-free
wicket-ajax engine.
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 61.89%. Comparing base (6550afd) to head (79c5857).

Additional details and impacted files
@@            Coverage Diff            @@
##             master    #1621   +/-   ##
=========================================
  Coverage     61.89%   61.89%           
- Complexity    11242    11244    +2     
=========================================
  Files          1247     1247           
  Lines         48367    48367           
  Branches       6788     6788           
=========================================
+ Hits          29935    29936    +1     
  Misses        15725    15725           
+ Partials       2707     2706    -1     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

urls: [
'http://localhost:38887/test/js/all.html?4.0.0'
'http://localhost:38887/test/js/all.html?4.0.0',
'http://localhost:38888/wicket-extensions/src/test/js/palette.html?4.0.0',

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these versions need to be manually maintained?
Can it be automated somehow? :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants