Skip to content

Add tests trying to reproduce 7362#7379

Merged
PavelVanecek merged 1 commit into
mainfrom
yaxis-null-data-ticks
May 28, 2026
Merged

Add tests trying to reproduce 7362#7379
PavelVanecek merged 1 commit into
mainfrom
yaxis-null-data-ticks

Conversation

@PavelVanecek

@PavelVanecek PavelVanecek commented May 28, 2026

Copy link
Copy Markdown
Collaborator

Tests only. Tried to reproduce #7362 but couldn't.

Summary by CodeRabbit

  • Documentation

    • Updated VR test skill documentation with Playwright component testing requirements and Docker dependency information.
  • Tests

    • Added visual regression tests for YAxis issue 7362.
    • Added unit tests for YAxis issue 7362 with multiple configuration scenarios.

Review Change Stack

@coderabbitai

coderabbitai Bot commented May 28, 2026

Copy link
Copy Markdown
Contributor

Walkthrough

This PR adds comprehensive test coverage for Recharts YAxis issue #7362, addressing YAxis behavior with null data and explicit tick configurations. It introduces updated VR test documentation, a shared test helper component, visual regression tests using Playwright, and unit tests using Vitest.

Changes

YAxis Issue #7362 Test Coverage

Layer / File(s) Summary
VR Test Documentation
.github/skills/vr-test/SKILL.md
Adds Playwright component testing constraint (components must be in separate files) and Docker dependency note for screenshot generation.
Test Helper Component
test-vr/tests/Issue7362Chart.tsx
Defines Datum type and Issue7362Chart component wrapping recharts LineChart with configurable Y-axis domain, ticks, and tickCount.
Visual Regression Tests
test-vr/tests/YAxis.7362.spec-vr.tsx
Four Playwright component test scenarios with screenshot assertions covering explicit ticks, tickCount, empty data, and numeric data cases.
Unit Test Suite
test/cartesian/YAxis/YAxis.7362.spec.tsx
Vitest suite with four test cases validating YAxis tick-domain behavior, axis domain values, and rendered tick elements across null, empty, and numeric data configurations.

🎯 2 (Simple) | ⏱️ ~12 minutes

Suggested reviewers

  • ckifer
🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The pull request description is incomplete. It lacks most required sections including Related Issue, Motivation and Context, How Has This Been Tested, and Checklist items. Complete the description by adding the related issue link (#7362), explaining the motivation, detailing how the tests were run, and filling out the appropriate checklist items.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Add tests trying to reproduce 7362' clearly summarizes the main change—adding tests to reproduce a specific issue (#7362).
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch yaxis-null-data-ticks

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov

codecov Bot commented May 28, 2026

Copy link
Copy Markdown

Bundle Report

Bundle size has no change ✅

@coderabbitai coderabbitai 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.

🧹 Nitpick comments (2)
test/cartesian/YAxis/YAxis.7362.spec.tsx (2)

44-57: 💤 Low value

Consider advancing timers after rendering.

As per coding guidelines for test files, vi.runOnlyPendingTimers() should be called after renders when not using the createSelectorTestCase helper to account for Redux autoBatchEnhancer delays. While the tests currently pass (animations are disabled), adding timer advancement would align with best practices and make the tests more robust.

⏱️ Suggested pattern
 const renderResult = render(
   <LineChart width={500} height={300} data={data}>
     <XAxis dataKey="name" />
     <YAxis
       type="number"
       domain={explicitDomain}
       allowDataOverflow
       {...(ticks != null ? { ticks } : {})}
       {...(tickCount != null ? { tickCount } : {})}
     />
     <Line type="monotone" dataKey="value" stroke="`#8884d8`" isAnimationActive={false} connectNulls />
     <ExpectAxisDomain assert={axisDomainSpy} axisType="yAxis" />
   </LineChart>,
 );
+vi.runOnlyPendingTimers();

 return {

As per coding guidelines: "Call vi.runOnlyPendingTimers() to advance timers after renders when not using createSelectorTestCase helper."

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@test/cartesian/YAxis/YAxis.7362.spec.tsx` around lines 44 - 57, After the
LineChart render in the test (the render(...) call that assigns renderResult),
advance fake timers by calling vi.runOnlyPendingTimers() immediately after
rendering to account for Redux autoBatchEnhancer delays; locate the render
invocation in YAxis.7362.spec.tsx (the block creating LineChart with
XAxis/YAxis/Line/ExpectAxisDomain) and insert a vi.runOnlyPendingTimers() call
right after it.

11-31: 💤 Low value

Minor code duplication across test suites.

The Datum type, explicitDomain, explicitTicks, and test data constants are duplicated between this unit test file and the VR test suite. While the duplication is minor and the tests serve different purposes, consider whether the shared Datum type from Issue7362Chart.tsx could be imported here to reduce maintenance burden.

♻️ Optional: import shared type
+import type { Datum } from '../../test-vr/tests/Issue7362Chart';
 import { ExpectAxisDomain, expectYAxisTicks } from '../../helper/expectAxisTicks';
 import { expectLastCalledWith } from '../../helper/expectLastCalledWith';

-type Datum = {
-  name: string;
-  value: number | null;
-};
-
 const explicitDomain = [0, 100] as const;

Note: The data constants and render helper likely need to remain separate due to the ExpectAxisDomain spy requirement in unit tests.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@test/cartesian/YAxis/YAxis.7362.spec.tsx` around lines 11 - 31, Replace the
duplicated Datum type by importing the shared Datum type from Issue7362Chart.tsx
and remove the local Datum declaration; keep the existing explicitDomain,
explicitTicks, allNullData, and partlyNumericData constants in this test file
(they must remain local for the ExpectAxisDomain spy), but update their type
annotations to use the imported Datum type so you avoid duplication while
preserving test-local data and helpers.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@test/cartesian/YAxis/YAxis.7362.spec.tsx`:
- Around line 44-57: After the LineChart render in the test (the render(...)
call that assigns renderResult), advance fake timers by calling
vi.runOnlyPendingTimers() immediately after rendering to account for Redux
autoBatchEnhancer delays; locate the render invocation in YAxis.7362.spec.tsx
(the block creating LineChart with XAxis/YAxis/Line/ExpectAxisDomain) and insert
a vi.runOnlyPendingTimers() call right after it.
- Around line 11-31: Replace the duplicated Datum type by importing the shared
Datum type from Issue7362Chart.tsx and remove the local Datum declaration; keep
the existing explicitDomain, explicitTicks, allNullData, and partlyNumericData
constants in this test file (they must remain local for the ExpectAxisDomain
spy), but update their type annotations to use the imported Datum type so you
avoid duplication while preserving test-local data and helpers.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 149022b7-4997-4296-901c-3ab9cce0f123

📥 Commits

Reviewing files that changed from the base of the PR and between 8eefd79 and 6c4ce06.

⛔ Files ignored due to path filters (12)
  • test-vr/__snapshots__/tests/YAxis.7362.spec-vr.tsx-snapshots/YAxis-issue-7362---explicit-ticks-with-all-null-series-data-1-chromium-linux.png is excluded by !**/*.png
  • test-vr/__snapshots__/tests/YAxis.7362.spec-vr.tsx-snapshots/YAxis-issue-7362---explicit-ticks-with-all-null-series-data-1-firefox-linux.png is excluded by !**/*.png
  • test-vr/__snapshots__/tests/YAxis.7362.spec-vr.tsx-snapshots/YAxis-issue-7362---explicit-ticks-with-all-null-series-data-1-webkit-linux.png is excluded by !**/*.png
  • test-vr/__snapshots__/tests/YAxis.7362.spec-vr.tsx-snapshots/YAxis-issue-7362---explicit-ticks-with-empty-data-1-chromium-linux.png is excluded by !**/*.png
  • test-vr/__snapshots__/tests/YAxis.7362.spec-vr.tsx-snapshots/YAxis-issue-7362---explicit-ticks-with-empty-data-1-firefox-linux.png is excluded by !**/*.png
  • test-vr/__snapshots__/tests/YAxis.7362.spec-vr.tsx-snapshots/YAxis-issue-7362---explicit-ticks-with-empty-data-1-webkit-linux.png is excluded by !**/*.png
  • test-vr/__snapshots__/tests/YAxis.7362.spec-vr.tsx-snapshots/YAxis-issue-7362---explicit-ticks-with-some-numeric-values-1-chromium-linux.png is excluded by !**/*.png
  • test-vr/__snapshots__/tests/YAxis.7362.spec-vr.tsx-snapshots/YAxis-issue-7362---explicit-ticks-with-some-numeric-values-1-firefox-linux.png is excluded by !**/*.png
  • test-vr/__snapshots__/tests/YAxis.7362.spec-vr.tsx-snapshots/YAxis-issue-7362---explicit-ticks-with-some-numeric-values-1-webkit-linux.png is excluded by !**/*.png
  • test-vr/__snapshots__/tests/YAxis.7362.spec-vr.tsx-snapshots/YAxis-issue-7362---tickCount-with-all-null-series-data-1-chromium-linux.png is excluded by !**/*.png
  • test-vr/__snapshots__/tests/YAxis.7362.spec-vr.tsx-snapshots/YAxis-issue-7362---tickCount-with-all-null-series-data-1-firefox-linux.png is excluded by !**/*.png
  • test-vr/__snapshots__/tests/YAxis.7362.spec-vr.tsx-snapshots/YAxis-issue-7362---tickCount-with-all-null-series-data-1-webkit-linux.png is excluded by !**/*.png
📒 Files selected for processing (4)
  • .github/skills/vr-test/SKILL.md
  • test-vr/tests/Issue7362Chart.tsx
  • test-vr/tests/YAxis.7362.spec-vr.tsx
  • test/cartesian/YAxis/YAxis.7362.spec.tsx

@chromatic-com

chromatic-com Bot commented May 28, 2026

Copy link
Copy Markdown

Tip

All tests passed and all changes approved!

🟢 UI Tests: 193 tests unchanged
🟢 UI Review: 193 stories published -- no changes
Storybook icon Storybook Publish: 193 stories published

@codecov

codecov Bot commented May 28, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.05%. Comparing base (007a85c) to head (6c4ce06).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #7379   +/-   ##
=======================================
  Coverage   89.05%   89.05%           
=======================================
  Files         548      548           
  Lines       40575    40575           
  Branches     5581     5581           
=======================================
  Hits        36134    36134           
  Misses       4432     4432           
  Partials        9        9           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions

Copy link
Copy Markdown
Contributor

Staging Deployment Details

These deployments will remain available for 30 days.

To update snapshots: Comment /update-snapshots on this PR to automatically update the baseline screenshots.

@PavelVanecek
PavelVanecek merged commit 344d3cb into main May 28, 2026
62 checks passed
@PavelVanecek
PavelVanecek deleted the yaxis-null-data-ticks branch May 29, 2026 15:10
nlenepveu added a commit to blackfuel-ai/recharts that referenced this pull request May 29, 2026
TDD red test documenting the unresolved half of recharts#7362. PR recharts#7379 showed a LITERAL
domain ([0,100]) + ticks + allowDataOverflow already renders the ladder on empty/
all-null data. This spec covers a FUNCTION domain (e.g. [0, (dataMax) => finite
fallback], or a whole-domain function), which recharts skips when there is no data
domain — so the ladder does not render.

Uses it.fails: the assertions express the desired behavior and currently throw, so
the suite stays green while documenting the gap; they flip to FAILING once recharts
invokes a function domain without data, signalling it's time to drop .fails.

Refs recharts#7362.

Signed-off-by: Nicolas <[email protected]>
PavelVanecek pushed a commit that referenced this pull request May 30, 2026
… ticks on empty/all-null data (#7384)

## What

A single, TDD-style **red** spec —
`test/cartesian/YAxis/YAxis.7362.derivedDomain.spec.tsx` — documenting
the unresolved half of #7362. **Tests only; no `src/` changes** and no
behavior/contract change.

## Context

PR #7379 (`YAxis.7362.spec.tsx`) showed the **literal** case already
works: `type="number"` + `domain={[0, 100]}` + `ticks` (or `tickCount`)
+ `allowDataOverflow` renders the `0/25/50/75/100` ladder even when
every series value is `null` (or `data={[]}`).

This spec covers the case that does **not** work yet: a **function**
`domain`. A function bound already decides its own value — e.g. `[0,
(dataMax) => (Number.isFinite(dataMax) && dataMax > 0 ? dataMax : 100)]`
returns a finite `100` when there is no data. The desired behavior is
that recharts invokes that function even when the data domain is empty,
so the returned finite bounds resolve the scale and the explicit `ticks`
render — exactly like the literal case.

## Current behavior (the gap)

recharts skips function domains when there is no data domain:
- `numericalDomainSpecifiedWithoutRequiringData` returns `undefined` for
any function, and
- `parseNumericalUserDomain` only calls the function when `dataDomain !=
null`

(`src/util/isDomainSpecifiedByUser.ts`). With empty/all-null data the
data domain is `null`, so the function is never called and the axis
renders **0 ticks**.

## Why `it.fails`

The three specs assert the **desired** behavior (the ladder renders),
which currently throws — so `it.fails` passes and the suite stays green
while documenting the gap. They flip to **FAILING** the moment recharts
resolves a function domain without data, signalling it's time to drop
`.fails` and lock the behavior in.

Cases covered:
- function upper bound `[0, (dataMax) => …]`, all-null data
- function upper bound, empty `data={[]}`
- whole-domain function `() => [0, 100]`, all-null data

## Running

```
npm ci
npx vitest run --config vitest.config.mts test/cartesian/YAxis/YAxis.7362.derivedDomain.spec.tsx
```

Refs #7362. Related: #7379, #4433, #4426.

Signed-off-by: Nicolas <[email protected]>
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