Repository navigation
test: route charts/vega into the ui vitest project and cover the untested viz packages and hooks (#4295) - #4377
Conversation
packages/charts and packages/vega had no functional tests at all, and packages/lab's chart primitives (Chart*, Radial*, ThreeD*, Sankey*, SVGIcon) rendered nothing under test. Add colocated tests for each, plus renderHook tests for the three useCalendar* hooks, useCollapsible and useTableFilterState. Harness: charts and vega were falling through to the `node` vitest project, which has no jsdom, no StyleX transform and no jest-dom, so their tests could never have run there. Move both into the `ui` project and give vega the test scripts the other packages already have. 53 test files, 307 tests. Verified: full suite 7943 pass / 430 files, still green with packages/core/dist absent (the cold-CI path, which charts needs because it imports core by bare name for values); 8 sampled mutations across all four packages, each killed by exactly the new test. Refs meta#4295
Finishes the functional-coverage sweep started in 64d9ea3. Adds renderHook tests for useScrollLock, useLightbox, useChatPasteAsToken, useImperativeAlertDialog, useTranslator and useTooltip, plus colocated tests for the components that had none: CommandPaletteEmpty, InputClearButton, TypeaheadItem, ChatSendButton, PowerSearchToken, PowerSearchFilterEditor and TableHeaderCell. Two of the issue's nine "zero-test" components already had tests (ChatComposerDrawer, MobileNavToggle, from meta#3996 and meta#3721), so the inventory is smaller than the issue states. Extracts the StyleX declaration read-back helper that three of these files each needed into __tests__/stylexDeclarations.ts rather than landing a third copy. Two branches are deliberately left uncovered, with the reason recorded next to them: the ignored-onOpenChange(true) guards in useLightbox and useImperativeAlertDialog are unreachable through the public surface, and reaching into element props to force them both breaks the repo's no-react-introspection lint rule and asserts a value that is already settled. useTooltip's focus paths are also omitted -- jsdom resolves :focus-visible as :focus, so those tests would pass with the gate deleted. Verified: 8101 tests / 443 files green, eslint and prettier clean, core typecheck clean; three sampled mutations (the send-button variant ternary, CommandPaletteEmpty's xstyle merge, useTooltip's touch suppression) each killed by exactly one new test. Refs meta#4295
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
PR Analysis Report📚 Storybook PreviewView Storybook for this PR 🧪 Sandbox PreviewView Sandbox for this PR Modified ComponentsAlertDialog (@astryxdesign/core) · View in Storybook
Calendar (@astryxdesign/core) · View in Storybook
Chat (@astryxdesign/core) · View in Storybook
Collapsible (@astryxdesign/core) · View in Storybook
CommandPalette (@astryxdesign/core) · View in Storybook
Field (@astryxdesign/core) · View in Storybook
Lightbox (@astryxdesign/core) · View in Storybook
PowerSearch (@astryxdesign/core) · View in Storybook
Table (@astryxdesign/core) · View in Storybook
Tooltip (@astryxdesign/core) · View in Storybook
Typeahead (@astryxdesign/core) · View in Storybook
Chart (@astryxdesign/lab) · View in Storybook
Radial (@astryxdesign/lab) · View in Storybook
SVGIcon (@astryxdesign/lab) · View in Storybook
Sankey (@astryxdesign/lab) · View in Storybook
ThreeD (@astryxdesign/lab) · View in Storybook
Bundle Size Summary
Accessibility AuditStatus: 1 accessibility violation(s) found — 1 serious. PowerSearch - 1 issue(s)
Visual RegressionStatus: Skipped — Broad stable scope is deferred to the daily release gate. It covers 1964 trusted baseline shots instead of recapturing them for this PR. View the report Generated by PR Enrichment workflow | Storybook | Sandbox | View full report |
|
Thanks for this — the Vega coverage is still wanted, but I can't refresh this branch mechanically now. Main has independently added eight of these test files and the charts test routing, so resolving the add/add conflicts requires choosing which assertions to keep rather than just taking both sides. Could you update onto current main and narrow the config change to the still-missing Vega route? Once that is current, we can review the remaining tests against today's behavior. [Reviewed by Robohands] |
Add/add conflicts on eight test files that main added independently (charts Chart, core InputClearButton/TypeaheadItem/useScrollLock, lab Chart/RadialChart/SVGIcon/ThreeDChart) resolve to main's version; the non-overlapping assertions from this branch are ported in a follow-up. vitest.config.ts narrows to the still-missing vega route: main already routes charts (and richtext) into the ui project.
The eight add/add conflicts resolved to main's files in the merge; this ports back only the assertions main does not cover and that still hold today (render gates and sizing, layer groups and masks, style restore, registry glyph, xstyle forwarding, context guards). Duplicates of main's coverage are dropped rather than kept twice. Four files went stale over the 815-commit gap and follow today's behavior: the hidden data-table fallback (meta#4382) means chart label and tooltip queries scope to the svg; useTooltip's touch guard is per pointer type (meta#5248) and a controlled tooltip reports Escape through onHide (meta#4881); TableHeaderCell dividers are logical inline-end properties (meta#4434).
|
Updated onto current main ( The eight add/add files keep main's version, and Four files had gone stale and now follow today's behavior: chart label and tooltip queries scope to the svg because of the hidden data-table fallback (#4382), useTooltip's touch guard is per pointer type (#5248) and a controlled tooltip reports Escape through Locally: 66 files / 509 tests green, eslint and prettier clean, typecheck clean for core, lab, charts and vega. |
CI's lint job fails on the one raw Intl call left in these tests: main's no-raw-intl-locale rule keeps its test-oracle allowlist inside the rule, and this file is not on it. The oracle was also the wrong side: with no InternationalizationProvider mounted, useLocale() resolves to 'en', so the hook's labels never followed the machine locale that Intl.DateTimeFormat(undefined) reads. Literal 'April 2026' style assertions match Calendar.test.tsx and drop the Intl dependency.
cixzhang
left a comment
There was a problem hiding this comment.
🟢 No review blockers found — Vega’s 30 tests route exclusively through the UI project, and the focused chart/Vega suites pass at this head.
[Reviewed by Robohands]
Resolved conflicts: - packages/vega/src/VegaChart.tsx: kept upstream's value-compared View latch (meta#6051) and fed the PR's themed compile options into it as `compileOptions`, replacing the PR's effect dependency list. - packages/vega/README.md: merged the file manifest (upstream's viewInputs.ts row plus the PR's tsconfig.build.json and vegaLiteConfig.ts rows). - packages/vega/src/vegaLiteConfig.test.ts (add/add): kept upstream's suite and added the PR's shared-palette and withAstryxConfig tests. - vitest.global-setup.node.mjs: took upstream's version. Vega tests now run in the `ui` project (meta#4377), so the node global setup no longer needs to build charts. Merge fallout: - packages/cli/clients/cli/commands/ensure-core-built.mjs: took upstream's version, dropping the PR's ensureBuilt/ensureChartsBuilt generalization, which nothing uses any more. - vitest.config.ts: resolve the bare @astryxdesign/charts specifier to source, as core already is, so the `ui` project does not need a built charts dist. - packages/vega/src/VegaChart.test.tsx: the vega mock now keeps the real module (vegaLiteConfig needs mergeConfig), and the compileOptions test expects the caller's config merged over the default theme config. - packages/vega/src/VegaChart.doc.mjs: compileOptions notes that its config is merged over the Astryx theme config.
The bug underneath the coverage gap
packages/vegahas no route into the vitestuiproject, so its component tests fall through to thenodeproject: no jsdom, no StyleX transform, no jest-dom. Main has since fixed the same problem forcharts(routing plus a bare@astryxdesign/corealias); this PR adds the still-missingvegainclude and exclude (3 lines invitest.config.ts) and vega'stestscripts.What this adds
Following #4295, in its order:
renderHooktests for the threeuseCalendar*hooks,useCollapsible,useTableFilterState,useScrollLock,useLightbox,useChatPasteAsToken,useImperativeAlertDialog,useTranslator,useTooltip.charts(every primitive, the marks, the tooltip's pointer seam),vega(VegaChart's full lifecycle against a mocked vega/vega-lite boundary), andlab'sChart*,Radial*,ThreeD*,Sankey*andSVGIconfamilies.CommandPaletteEmpty,InputClearButton,TypeaheadItem,ChatSendButton,PowerSearchToken,PowerSearchFilterEditor,TableHeaderCell.66 test files, 509 tests. No source file is changed. The only non-test edits are the vega route, vega's test scripts, and a shared StyleX read-back helper (
packages/core/src/__tests__/stylexDeclarations.ts).Eight of these files were also added on main while this branch was open (
charts/Chart,InputClearButton,TypeaheadItem,useScrollLock,lab/Chart,RadialChart,SVGIcon,ThreeDChart). Those keep main's version;ea311aae4ports back only the assertions main does not cover and drops the duplicates. One of main's assertions is tightened along the way:InputClearButton'sonClickevent check (toBeInstanceOf(Object)passes for any object) now pinstype: 'click'.One correction to the issue:
ChatComposerDrawer(#3996) andMobileNavToggle(#3721) already had tests.How it was checked
typecheckclean for core, lab, charts and vega (test files included).CommandPaletteEmpty'sxstylemerge, and deletinguseTooltip's touch guard each fail exactly one test.Deliberately left uncovered
useTooltip's focus paths. jsdom resolves:focus-visibleas plain:focus, so a test of that gate would pass identically with the gate deleted.onOpenChange(true)guards inuseLightboxanduseImperativeAlertDialog. Nothing emitstruethrough the public surface, and forcing it via element props tripsno-react-introspection.Source observations, not fixed here
lab/SVGIcon.tsx:131-153spreads{...attrs, key}into each shape, so React 19 logs a key-in-spread warning per shape (pre-existing on main).lab/Chart.tsx:333emits a hard-codedclipPath id="astryx-chart-plot"that nothing references;charts/Chart.tsxalready usesuseIdfor the same thing.TypeaheadItem.tsx:142-144dropsref,className,xstyle,styleand the pass-through props whenitem.elementis set, and thegroupprop is documented but unused.Refs #4295