Skip to content

test: add unit tests for HTMLTooltip mark (#164)#499

Merged
gka merged 4 commits into
mainfrom
test/htmltooltip-164
Mar 2, 2026
Merged

test: add unit tests for HTMLTooltip mark (#164)#499
gka merged 4 commits into
mainfrom
test/htmltooltip-164

Conversation

@ljodea

@ljodea ljodea commented Feb 27, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Add 8 unit tests for the HTMLTooltip mark covering tooltip visibility, datum selection, positioning, pointer events, and edge cases
  • Add guard against crash when data is empty (missing quadtree at facet index)
  • Fix event listener cleanup bug (mouseleavepointerleave)
  • Closes Add unit test for HTMLTooltip mark #164

Test cases

# Test Assertion
1 Initially hidden .svelteplot-tooltip has hide class, no content
2 Shows on pointer near point hide removed, content rendered
3 Hides on pointerleave hide restored, content gone
4 Passes nearest datum to children Correct data-label attribute
5 No show beyond 25px radius Stays hidden
6 Updates when moving to different point Label changes
7 Positions at projected coordinates style.left/style.top correct
8 Handles empty data No crash, stays hidden

Bug fixes

  • Added a guard in HTMLTooltip.svelte:57 for when trees[facetIndex] is undefined (empty data case). Without this, dispatching a pointermove event with empty tooltip data causes a TypeError: Cannot read properties of undefined (reading 'find').
  • Fixed event listener cleanup bug at HTMLTooltip.svelte:76: was removing 'mouseleave' but should remove 'pointerleave' (matching what was added on line 72). This caused a listener leak on component teardown.

Test plan

  • All 8 new tests pass
  • Full suite (685 tests) passes with no regressions
  • Lint clean
  • Type check clean

🤖 Generated with Claude Code

Add 8 tests covering tooltip visibility, datum selection, positioning,
pointer events, and edge cases. Guard against missing quadtree when
data is empty. Fix event listener cleanup (mouseleave → pointerleave).

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@netlify

netlify Bot commented Feb 27, 2026

Copy link
Copy Markdown

Deploy Preview for svelteplot ready!

Name Link
🔨 Latest commit b343a7a
🔍 Latest deploy log https://app.netlify.com/projects/svelteplot/deploys/69a1cceebcca3800085c42c5
😎 Deploy Preview https://deploy-preview-499--svelteplot.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

ljodea and others added 3 commits February 27, 2026 17:06
- Type the datum generic via ComponentProps<typeof HTMLTooltip<Datum>>
  to fix "Property 'label' does not exist on type '{}'" errors
- Remove unused @ts-expect-error directive on test import
- Include oxlint auto-fixes in vector example files

Co-Authored-By: Claude Opus 4.6 <[email protected]>
tsc reports "no default export" for .svelte imports while svelte-check
resolves them fine. Use @ts-ignore (accepted by both) instead of
@ts-expect-error (rejected by svelte-check as unused).

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Map.get() returns T | undefined, which svelte-check rejects for spread.
Using `as object` avoids oxlint's no-useless-fallback-in-spread rule
(which strips `?? {}` via --fix) while satisfying the type constraint.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@ljodea ljodea requested a review from gka March 2, 2026 14:16

@gka gka left a comment

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.

thanks

@gka gka merged commit 04dc695 into main Mar 2, 2026
9 checks passed
@gka gka deleted the test/htmltooltip-164 branch March 2, 2026 18:49
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.

Add unit test for HTMLTooltip mark

2 participants