Skip to content

Testable Popup Tool - #4940

Open
azmy60 wants to merge 2 commits into
masterfrom
fix/testable-popupjs
Open

Testable Popup Tool#4940
azmy60 wants to merge 2 commits into
masterfrom
fix/testable-popupjs

Conversation

@azmy60

@azmy60 azmy60 commented Aug 6, 2026

Copy link
Copy Markdown
Collaborator

The main goal of this PR is to make src/js/core/tools/Popup.js to be more testable by introducing these:

  • Popup.offset
  • Popup.resolveCoordsByOrigin

The tests expose some bugs which might be related to #4285 and later might be fixed by #4918.

azmy60 and others added 2 commits August 6, 2026 16:17
Cover Popup.show() across all five anchor positions, mouse-event and
numeric origins, overflow rescues, and reversal state on reuse. Ten of
these fail against current behaviour and document real bugs: reversal
writes `right` instead of a normalised `left`, no left-edge clamp when
the popup is wider than the space beside its anchor, `reversedX` never
resetting for a reused popup, and the vertical bound widening to
scrollHeight once the page is scrolled.

Adds @babel/preset-typescript, typescript, and @types/jest so unit
specs can be written in TS, plus a `typecheck` script and tsconfig.
Upgrades jest to 30 for jsdom 26, which implements MouseEvent#pageX
(jsdom/jsdom#3484) so event origins no longer need hand-defined
properties.

Popup no longer takes a container constructor argument; the specs
exercise the document.body path via `popupContainer: false`.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@rathboma

Copy link
Copy Markdown
Collaborator

@azmy60 your tests fail, but this makes TOTAL SENSE. Please fix and merge. Possibly merge in the changes from #4918 if it makes the tests pass.

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.

2 participants