Skip to content

test(charts): real Legends overflow coverage - #36490

Draft
AKnassa wants to merge 1 commit into
microsoft:masterfrom
AKnassa:ak-issue-32121-legends-overflow-tests
Draft

test(charts): real Legends overflow coverage#36490
AKnassa wants to merge 1 commit into
microsoft:masterfrom
AKnassa:ak-issue-32121-legends-overflow-tests

Conversation

@AKnassa

@AKnassa AKnassa commented Aug 1, 2026

Copy link
Copy Markdown

Previous Behavior

A charting maintainer asked for a test covering the "legends with overflow" scenario (legend items collapsing into an "N Overflow Items" button). The existing tests looked like coverage but weren't: they asserted that a DOM query result "is defined" — which is always true — against a CSS class that could never match anyway. Overflow could break entirely and no test would notice.

New Behavior

Real coverage in both charting packages. The tests drive the actual overflow machinery with controlled measurements to a deterministic split and then check what users see: the overflow button with its exact count, which legends stay inline, what opens when you click it, and the right accessibility attributes.

What changed

  • v8 (react-charting): pure tests for the overflow reducers (including a round-trip identity check) plus rendered tests pinning a 4-inline / 13-overflowed split, the "13 Overflow Items" button, and the hover-card contents.
  • v9 (react-charts): tests pinning a 3-visible / 14-overflowed split, the "+14 Overflow Items" menu and its items, and the no-overflow case.
  • The old vacuous assertions upgraded in place; arithmetic guards (inline + overflowed = total) keep the tests durable if styling ever shifts the split.
  • Release-notes change files (type "none" — tests only).

Meaningfulness was proven the honest way: temporarily breaking the overflow logic in each package made the new tests fail, and restoring it made them pass. Full suites green / baseline-exact. Small note for reviewers: opening the v9 overflow menu logs a pre-existing dev warning from the Menu internals — observed, not caused, by these tests.

Related Issue(s)

The Legends overflow scenario had only vacuous coverage: both
packages asserted querySelectorAll(...).toBeDefined(), which always
passes, against a selector that could never match.

Replace it with meaningful tests. v8: pure-function coverage of the
ResizeGroup reducers (_onReduceData/_onGrowData, including
round-trip identity) plus rendered-overflow tests that drive the
real ResizeGroup pipeline with mocked measurements to a
deterministic 4-inline/13-overflow split, assert the '13 Overflow
Items' indicator, aria state, and the HoverCard contents. v9:
overflow-manager tests pinning a 3-visible/14-overflowed split, the
'+14 Overflow Items' menu with menuitemcheckbox entries, and the
no-overflow case. Inline+overflow arithmetic guards keep the tests
durable if styling shifts the split.

Non-vacuousness proven by mutating the overflow logic in each
package and watching the new tests fail, then restoring. Full
react-charting suite green (967); react-charts matches baseline
(only the 6 pre-existing HeatMapChart snapshot failures).

Closes microsoft#32121
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 test for legends overflow scenario

1 participant