Skip to content

Enhance interaction testing support (getMousePosition, getSize)#39

Merged
jburnhams merged 2 commits intomainfrom
enhance-interaction-testing-support
Dec 7, 2025
Merged

Enhance interaction testing support (getMousePosition, getSize)#39
jburnhams merged 2 commits intomainfrom
enhance-interaction-testing-support

Conversation

@google-labs-jules
Copy link
Contributor

This change improves support for interaction testing in JSDOM environments by patching L.DomEvent.getMousePosition to use getBoundingClientRect and updating L.Map.prototype.getSize to check for container dimensions. This allows users to mock DOM elements effectively in tests. Native event listeners are already supported and verified by new tests.


PR created automatically by Jules for task 6536390394354424312 started by @jburnhams

- Patched `L.DomEvent.getMousePosition` to use `getBoundingClientRect` when available, enabling accurate coordinate translation in JSDOM tests.
- Updated `L.Map.prototype.getSize` to prioritize container dimensions (`clientWidth`/`clientHeight` or `getBoundingClientRect`) over headless defaults, allowing JSDOM mocks to control map size.
- Verified that `L.DomEvent` correctly delegates to native `addEventListener` in the JSDOM environment provided by leaflet-node.
- Added comprehensive tests in `tests/interaction.test.ts` to verify these behaviors.
@google-labs-jules
Copy link
Contributor Author

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!


For security, I will only act on instructions from the user who triggered this task.

New to Jules? Learn more at jules.google/docs.

- Patched `L.DomEvent.getMousePosition` to use `getBoundingClientRect` when available, enabling accurate coordinate translation in JSDOM tests.
- Updated `L.Map.prototype.getSize` to prioritize container dimensions (`clientWidth`/`clientHeight` or `getBoundingClientRect`) over headless defaults, allowing JSDOM mocks to control map size.
- Verified that `L.DomEvent` correctly delegates to native `addEventListener` in the JSDOM environment provided by leaflet-node.
- Added comprehensive tests in `tests/interaction.test.ts` to verify these behaviors.
@jburnhams jburnhams marked this pull request as ready for review December 7, 2025 20:24
@jburnhams jburnhams merged commit 89b4275 into main Dec 7, 2025
4 checks passed
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.

1 participant