Skip to content

test: add regression tests for issue #279 (facet_wrap spacing with custom height) - #288

Open
ANAMASGARD wants to merge 18 commits into
masterfrom
fix-issue-279-facet-height-spacing
Open

test: add regression tests for issue #279 (facet_wrap spacing with custom height)#288
ANAMASGARD wants to merge 18 commits into
masterfrom
fix-issue-279-facet-height-spacing

Conversation

@ANAMASGARD

@ANAMASGARD ANAMASGARD commented Jan 4, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds comprehensive regression tests for issue #279 to prevent reoccurrence of excessive spacing below facet_wrap plots when using custom height parameters.

Background

Issue #279 reported that when using facet_wrap() with a custom height parameter (different from the default 400px), excessive vertical spacing appeared below the faceted plots. The spacing did not scale proportionally with the custom height.

After thorough investigation and testing with version 2025.12.4, this issue appears to be resolved. These tests ensure it doesn't regress in future updates.

Changes

  • Added test-issue-279-facet-wrap-custom-height-spacing.R
  • 3 comprehensive test cases with 16 assertions
  • Tests cover:
    • Vertical facet layout (ncol=1) with 2x and 3x custom heights (800, 1200)
    • Grid layout (2×2, ncol=2) with 1.5x custom height (600)
    • Multiple height values (400, 600, 800, 1000, 1200) to verify proportionality

What the Tests Verify

The key verification is that height_proportion values remain identical across all custom heights:

  1. Custom height parameters are correctly stored in plot.json
  2. Panel layout structure (ROW/COL) remains consistent
  3. height_proportion values are identical regardless of custom height
    • These values control relative spacing between facets
    • If excessive spacing existed, these would differ with custom heights
    • Consistent proportions = correct proportional scaling ✓

Testing

  • All tests pass on current main branch :-
new-279

   Adds comprehensive test cases to verify that facet_wrap spacing
   scales proportionally with custom height parameter.

   Tests cover:
   - Vertical facet layout (ncol=1) with 2x and 3x custom heights
   - 2x2 grid layout with 1.5x custom height
   - Multiple height values to verify proportionality

   This ensures issue #279 (excessive spacing below facets) does not regress.

   All tests pass (16 assertions).

   Refs #279
@codecov

codecov Bot commented Jan 4, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 73.03%. Comparing base (426295c) to head (0d1a83d).

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #288   +/-   ##
=======================================
  Coverage   73.03%   73.03%           
=======================================
  Files         164      164           
  Lines        8840     8841    +1     
=======================================
+ Hits         6456     6457    +1     
  Misses       2384     2384           
Flag Coverage Δ
javascript 81.26% <100.00%> (+<0.01%) ⬆️
r 69.14% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@tdhock

tdhock commented Feb 27, 2026

Copy link
Copy Markdown
Collaborator

can you please post a screenshot of the proposed test?

ANAMASGARD and others added 2 commits March 10, 2026 15:50
…facets; replace JSON-only test with browser-based regression test

- Add .style("display","block") to SVG creation in animint.js so browsers
  do not add text-descender whitespace below inline SVG elements (fixes
  visible gap below facet_wrap/facet_grid at any custom height).
- Replace the three animint2dir+JSON tests with a single animint2HTML test
  that renders in a real browser and asserts SVG height stays proportional
  (not height*num_facets) when using theme_animint(height=600) on a
  facet_grid(task_id ~ .) plot with sonar/spam/vowel/waveform/zip data,
  matching the ch20 examples that originally exposed the bug.
@ANAMASGARD

ANAMASGARD commented Mar 10, 2026

Copy link
Copy Markdown
Contributor Author
localhost_8788_issue279-facet-height-600_index html(Surface Pro 7)

@tdhock

tdhock commented Mar 10, 2026

Copy link
Copy Markdown
Collaborator

please fix CI

ANAMASGARD and others added 2 commits March 11, 2026 05:48
The display:block style added to SVGs causes sapply(svg.list, xmlAttrs)
to return a list instead of a matrix when SVGs have inconsistent
attribute counts. Use lapply/sapply with a function to extract id
attributes safely regardless of attribute structure.
@ANAMASGARD
ANAMASGARD requested a review from tdhock March 19, 2026 04:03
acontext("Issue #279: facet_grid spacing with custom height")

test_that("facet_grid SVG height is proportional to theme_animint height, no excess space (#279)", {
skip_on_cran()

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please remove, not necessary

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please remove

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please remove skip

Comment thread tests/testthat/test-issue-279-facet-wrap-custom-height-spacing.R Outdated
Comment thread tests/testthat/test-issue-279-facet-wrap-custom-height-spacing.R Outdated
Comment thread tests/testthat/test-issue-279-facet-wrap-custom-height-spacing.R Outdated
Comment thread tests/testthat/test-issue-279-facet-wrap-custom-height-spacing.R Outdated
ANAMASGARD and others added 2 commits May 26, 2026 14:00
- use facet_wrap instead of facet_grid (matches original bug report)
- remove acontext() call as requested
- remove empty lines inside test_that block
- introduce n_facets variable and use 400*n_facets / 600*n_facets
  bounds to make the regression guard self-explanatory
- refactor with viz_list + lapply to eliminate code duplication
@ANAMASGARD
ANAMASGARD requested a review from tdhock May 26, 2026 10:54
@ANAMASGARD

ANAMASGARD commented May 26, 2026

Copy link
Copy Markdown
Contributor Author

Sir @tdhock, I've addressed all four review comments:

  • Removed the acontext() call
  • Removed empty lines inside the test_that block
  • Switched from facet_grid to facet_wrap to match the original bug report in issue too much space below facet wrap #279
  • Introduced n_facets and updated bounds to 400 * n_facets / 600 * n_facets to make the regression guard self-explanatory
  • Refactored using viz_list + lapply to eliminate duplicated code

All 5 assertions pass locally (PASS 5). But when i pushed the commit I first had to rebase it so I rebased this branch then when I pushed the github CI , should run automatically but it is not working ??

acontext("Issue #279: facet_grid spacing with custom height")

test_that("facet_grid SVG height is proportional to theme_animint height, no excess space (#279)", {
skip_on_cran()

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please remove

@ANAMASGARD
ANAMASGARD requested a review from tdhock May 29, 2026 09:21
@ANAMASGARD

Copy link
Copy Markdown
Contributor Author

Sir @tdhock can you please review and give your feedback I have removed the

acontext("Issue #279: facet_grid spacing with custom height")

as you said .

Comment thread tests/testthat/test-renderer3-knit-print.R Outdated
ANAMASGARD and others added 3 commits June 29, 2026 20:34
Restore test-renderer3-knit-print.R to master, remove skip_on_cran(),
and assert plot SVG uses display:block via getComputedStyle.
sapply(xmlAttrs) no longer simplifies to a matrix when plot SVGs have
style attributes from the issue #279 fix. Use getPropertyValue().
@ANAMASGARD
ANAMASGARD requested a review from tdhock July 29, 2026 04:49
Comment on lines +24 to +37
display = runtime_evaluate(sprintf(
"window.getComputedStyle(document.getElementById('%s')).display", svg_id))
)
})
expect_equal(results$default$display, "block",
label = "plot SVG should use display:block to prevent whitespace below it")
expect_equal(results$custom$display, "block",
label = "plot SVG should use display:block to prevent whitespace below it")
h_list <- lapply(results, `[[`, "height")
expect_lt(h_list$default, 400 * n_facets)
expect_lt(h_list$custom, 600 * n_facets,
label = "SVG height should not be 600*num_facets — regression from issue #279")
expect_gt(h_list$custom, h_list$default)
bottom_gap <- runtime_evaluate("(() => { const svg = document.querySelector(\"svg[id*='plot_plot']\"); const parent = svg.parentElement; return parent.getBoundingClientRect().bottom - svg.getBoundingClientRect().bottom; })()")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you please use existing R helper functions instead of runtime evaluate with custom js code?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sir @tdhock I have removed all custom runtime_evaluate JS from test file
The test now uses getStyleValue() for inline display:block and get_element_bbox() for the parent–SVG gap check (both default and custom height).
Passes locally (9/9). Please re-review when you have time thanks .

ANAMASGARD and others added 2 commits July 30, 2026 07:12
Replace custom runtime_evaluate JS with existing R helpers per review.
Assert display:block and bottom_gap for both default and custom heights.
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.

2 participants