Skip to content

test(charts): assert the Tooltip Default story's hover tooltip in the story play guard - #12548

Merged
marie-lucas merged 1 commit into
mainfrom
charts/tooltip-default-play
Nov 18, 2026
Merged

marie-lucas merged 1 commit into
mainfrom
charts/tooltip-default-play

Conversation

@marie-lucas

@marie-lucas marie-lucas commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Maintainer impact

Nothing in CI asserts the main Charts tooltip story. Charts/Chrome/Tooltip/Default has no play function, so a regression where the grouped chart tooltip stops opening on hover, shows the wrong row, never closes, or loses the pointer to an overlay leaves every check green. The only chart tooltip play that CI runs today is Modal Layering, which covers top-layer stacking inside a modal, not the plain hover path.

The existing jsdom ChartTooltip tests cannot cover this path. jsdom has no layout (so no geometry-to-index mapping), no hit testing (elementFromPoint), and no native popover top layer.

Intended invariant

No product behavior changes. The guard pins the behavior the story shows today: hovering a month opens the grouped tooltip with that month's heading and every series value, a pointer at that point keeps reaching the chart's pointer layer while the tooltip is open, and leaving the plot closes it.

Authority gap: ChartTooltip's record is draft; this guards current observed behavior and settles nothing. The asserted text matches the spec's default for unformatted values (AST-115 FR9): a series without formatValue and a chart without formatXValue render String(value) for present values, and this story declares no format.

Change

  • apps/storybook/stories/charts/Tooltip.stories.tsx: Default gets a play function. The export name, story id (charts-chrome-tooltip--default) and render are unchanged.
    1. Pins the fixture row: monthlyData April must equal {month: 'Apr', revenue: 61, costs: 38, trend: 48}. April is used because its three values differ from every other month.
    2. Waits for the plot, the rendered "Apr" tick of the bottom axis and the tooltip host. The host renders only after the tooltip subscribes to the chart's pointer events, so a hover sent earlier is lost.
    3. Takes the hover point at the centre of the "Apr" tick, at mid-plot height. Asserts the tooltip is closed and that elementFromPoint at that point is the chart's pointer layer.
    4. Sends a pointermove there on the pointer layer. Waits for the tooltip's Layer host to match :popover-open and for its text, in order, to equal ['Apr', 'Revenue', '61', 'Costs', '38', 'Trend', '48']. Then asserts elementFromPoint still hits the pointer layer, which catches a hover highlight, dot or crosshair that takes the pointer.
    5. Sends pointerout to the document body. Waits for the host to close and the text to empty.
  • .github/scripts/story-play-guard.js: adds charts-chrome-tooltip--default to TARGETS, next to the existing Modal Layering entry.

This is maintenance because it only adds a test of existing behavior; no package source changes.

Evidence

All runs use the unmodified guard script in headless Chrome (Chrome Headless Shell 149.0.7827.55, the Playwright 1.61.1 build) against a production Storybook build of f64e6fd (this branch's head). Each run covers all 82 guard targets.

  • Failure before the change: on main, Default has no assertion, so the guard never loads it. To show that the new assertion fails for real defects, each one-line mutation below was built and guarded, then reverted (none is in this PR):
    • Tooltip turned off on Default only (tooltip → tooltip={showLineDots}, so Modal Layering keeps its tooltip). The play fails at the readiness wait, because no tooltip host renders:
      ✗ ChartTooltip (charts-chrome-tooltip--default): playFunctionThrewException — AssertionError: expected null not to be null
    • The chart's pointer-leave handler no longer clears the hover (its dispatch(...) line removed). Fails on the close check:
      ✗ ChartTooltip (charts-chrome-tooltip--default): playFunctionThrewException — AssertionError: expected true to be false
    • The tooltip reads the next datum (data[hoveredIndex] → data[hoveredIndex + 1]). Fails on the content check (Modal Layering also fails, as expected for a shared defect):
      ✗ ChartTooltip (charts-chrome-tooltip--default): playFunctionThrewException — AssertionError: expected [ 'May', 'Revenue', '55', …(4) ] to deeply equal [ 'Apr', 'Revenue', '61', …(4) ]
    • pointerEvents="none" removed from the tooltip's column-highlight rect, so the highlight drawn under the cursor takes the pointer. Fails on the hit-test check after the tooltip opens:
      ✗ ChartTooltip (charts-chrome-tooltip--default): playFunctionThrewException — AssertionError: expected '<rect>' to be 'chart pointer layer'
  • Success after the change:
    • ✓ ChartTooltip (charts-chrome-tooltip--default): play passed — hovering a month through the chart pointer layer opens the grouped tooltip with that month's heading and every series value, and leaving the plot closes it
    • ✓ ChartTooltip (charts-chrome-tooltip--modal-layering): play passed, unchanged, and it also passes in the tooltip-off, leave-handler and highlight mutations.
    • Expected vs measured: hit target before and after open, expected "chart pointer layer", measured "chart pointer layer"; tooltip text, expected Apr · Revenue 61 · Costs 38 · Trend 48, measured the same; open state after hover true, after leaving false.
    • Two unrelated PowerSearch targets (core-powersearch--near-full-token-row and its RTL variant) fail locally with a font difference and pass on main's latest release-check (https://github.com/meta/astryx/actions/runs/44170982065). They fail the same way locally on a clean main build.
  • Product/runtime behavior verified unchanged: no package file changes. Real pointer moves in headless Chrome over the April column, at desktop 1280×900 and phone 390×844, light and dark, gave byte-identical Default screenshots between a main build and a build with this change, at rest and while hovered. (Those captures ran just before the rebase onto the current main; no chart or story file changed in between.) The hovered tooltip showed Apr, Revenue 61, Costs 38, Trend 48 in every case.
  • CI impact (for a change to workflows, actions or CI scripts): same job (pr-a11y (audit and guards), step "Run story play guard") and the same runner class. The guard loads one more story, 82 targets instead of 81. No workflow or action changes.

Scope

Components: ChartTooltip

  • No intended public API, product behavior, visual direction, or policy change.
  • Product changes discovered during the work were removed or split.
  • Public text and artifacts contain no internal Meta context.

Testing

  • node .github/scripts/story-play-guard.js --storybook-dir apps/storybook/dist against a production build of f64e6fd: the new target passes and Modal Layering passes. Each of the four mutations above was built and guarded, and each one makes the new target fail.
  • CI path: the guard runs in pr-a11y (audit and guards) only on a non-draft pull request labelled ci:run-a11y; without the label it first runs on main's release-check. This PR carries the label.
  • node .github/scripts/build-packages-and-storybook.mjs (packages and Storybook build)
  • pnpm exec vitest run --project node apps/storybook/.storybook/story-tree.test.ts: 5 passed, against the built index; both tooltip ids are present.
  • pnpm typecheck
  • pnpm exec prettier --check on both files, and pnpm exec eslint --max-warnings=0 on the story file (the guard script is outside the ESLint scope).
  • pnpm check:changesets: passes. No Changeset, because this changes a story and a CI script only.
  • pnpm specs:for --diff origin/main and pnpm review:pre --head HEAD: 0 findings, merges cleanly.

The Default story of Charts/Chrome/Tooltip now has a play function. It
hovers the April column through the chart's pointer layer and checks
that a pointer at that point reaches the layer before and after the
tooltip opens. It checks that the grouped tooltip opens with the April
heading and the Revenue, Costs and Trend values of the pinned April
fixture row. It then leaves the plot and checks that the tooltip closes.

The story is added to the story play guard targets, so a broken
assertion fails the story play guard in CI instead of passing silently.
@vercel

vercel Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
astryx Ready Ready Preview Nov 18, 2026 2:09am UTC

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Nov 18, 2026
@marie-lucas marie-lucas added the ci:run-a11y Run the accessibility suite on this PR; write access, next push (AST-030 FR12) label Nov 18, 2026
@astracat-bot

astracat-bot Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Nov 18, 2026, 3:59 AM UTC

@github-actions

github-actions Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

🔎 Preview · f64e6fd

Storybook · Sandbox · built from this PR's head

Not run on this PR: add ci:run-visual for Visual, ci:run-rtl for RTL.

CI impact: 0 job-min per update · pool 0% · standard runners · 1 CI action or script file changed (not measured)
Before After Change
Job-minutes per PR update 219 219 0
Runner pool, runner-minutes a day 71,349 71,349 0 (0%)
Average concurrent jobs 49.5 49.5 0
Time to green (median → this run) — 50.7 min —
Runs a day 326 326 0

Not measured (the jobs that use these keep their recent minutes above): .github/scripts/story-play-guard.js.

Assumptions: before is each job's average over the last 20 pull-request runs; after keeps that for unchanged jobs and uses this run's minutes for added or changed ones, weighted by how often each changed job ran in those runs; runs a day averages the seven whole days before today; time to green compares this run with the median of those runs that ran the same jobs.


Generated by PR Enrichment workflow | View full report

@astracat-bot astracat-bot Bot 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.

Changes requested: one sentence in the pull request description needs correcting. The new play function and its story play guard entry are sound, and the guard passes the new target on this head.

  • The description says the pinned tooltip text will change when spec:AST-115 is implemented, but its FR9 keeps String(value) for a series and chart that declare no format, as this story does, so please reword that sentence to say the asserted text matches the spec's default for unformatted values.
Claims and files checked

Review mode: full; reason: no-earlier-review

  • Claim: the Default story had no play function before this change: verified.
  • Claim: Modal Layering was the only chart tooltip play the guard ran: verified.
  • Claim: jsdom cannot observe the layout, hit testing or native top layer this path needs: verified.
  • Claim: no product behavior changes: verified; no package file changes and the story render is unchanged.
  • Claim: hovering April opens the grouped tooltip with April's heading and every series value, the pointer keeps reaching the chart while it is open, and leaving closes it: verified; the guard passes on this head and a real mouse shows the same rows and close.
  • Claim: the ChartTooltip record is draft: verified.
  • Claim: the pinned text will change when the chart value-format spec is implemented: false; that spec keeps the plain value text for series without a format.
  • Claim: the story name, id and render are unchanged: verified.
  • Claim: April's values are distinct within each series: verified.
  • Claim: the tooltip host appears only after the tooltip subscribes to pointer events: verified.
  • Claim: the play's hover, hit-test and leave steps work as described: verified.
  • Claim: the guard entry sits next to Modal Layering and raises the guard from 81 to 82 targets in the same job and step: verified.
  • Claim: each of the four described one-line mutations makes the new target fail: consistent with the code, not re-run.
  • Claim: the guard runs only on labelled, non-draft pull requests or main's release check, and this pull request has the label: verified.
  • Claim: the guard script is outside lint scope and no changeset is needed: verified.
  • File apps/storybook/stories/charts/Tooltip.stories.tsx: clear.
  • File .github/scripts/story-play-guard.js: clear.

Automated review (maintainer link)

@astracat-bot astracat-bot Bot 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.

Approved: the description now states the chart value-format spec's default for unformatted values correctly, and the new Default play function and its story play guard entry are sound. The guard passes the new target in pr-a11y (audit and guards) on this head, and a real mouse over April shows the same rows, hit target and close that the play asserts.

Claims and files checked

Review mode: same-head; reason: none

  • Changed rules (0): none.
  • Claim: the Default story had no play function, so no CI check asserted its hover tooltip: verified; on the base the story has only a render and the guard lists no Default entry.
  • Claim: the modal layering story was the only chart tooltip play the guard ran: verified.
  • Claim: jsdom cannot observe the layout, hit testing or native top layer this path needs: verified; the tooltip takes a reduced path without native popover support.
  • Claim: no product behavior changes: verified; no package file changes.
  • Claim: the chart tooltip record is draft and this change settles nothing: verified.
  • Claim: the asserted text is the value-format spec's default for unformatted values, and the story declares no format: verified.
  • Claim: the story's export name, id and render are unchanged: verified.
  • Claim: April's fixture row is pinned and each of its values differs from every other month: verified.
  • Claim: the tooltip host appears only after the tooltip subscribes to the chart's pointer events: verified.
  • Claim: the hover point is the centre of the April tick at mid-plot height, and the hit test reaches the chart's pointer layer before and after the tooltip opens: verified in CI and with a real mouse.
  • Claim: hovering opens the grouped tooltip with April's heading and every series value in order, and leaving the plot closes it and empties the text: verified.
  • Claim: the guard entry sits next to the modal layering entry and raises the guard from 81 to 82 targets in the same job and step, with no workflow change: verified.
  • Claim: each of the four one-line mutations makes the new target fail with the quoted message: consistent with the code, not re-run.
  • Claim: the modal layering play still passes: verified in CI.
  • Claim: two unrelated search-field targets fail only locally and pass in main's release check: consistent; both pass in CI on this head.
  • Claim: the story's screenshots are unchanged at rest and while hovered: not re-run; the render is unchanged, and the frame after the play matches the frame after leaving.
  • Claim: the guard runs only on non-draft pull requests with the accessibility label or in main's release check, and this pull request has the label: verified.
  • Claim: the guard script is outside lint scope and no changeset is needed: verified.
  • Claim: the build, story tree, typecheck, formatting, changeset and clean-merge checks pass: consistent; CI's build, typecheck, lint and node test jobs pass on this head, and it merges cleanly into the current main.
  • File apps/storybook/stories/charts/Tooltip.stories.tsx: clear.
  • File .github/scripts/story-play-guard.js: clear.

Automated review (maintainer link)

@marie-lucas
marie-lucas merged commit f4fa366 into main Nov 18, 2026
145 of 161 checks passed
@github-actions
github-actions Bot deleted the charts/tooltip-default-play branch November 19, 2026 06:05

This branch was successfully deployed

1 active deployment
Preview — f64e6fd5 Deployed Nov 18, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:run-a11y Run the accessibility suite on this PR; write access, next push (AST-030 FR12) CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant