test: add regression tests for issue #279 (facet_wrap spacing with custom height) - #288
test: add regression tests for issue #279 (facet_wrap spacing with custom height)#288ANAMASGARD wants to merge 18 commits into
Conversation
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 Report✅ All modified and coverable lines are covered by tests. 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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
can you please post a screenshot of the proposed test? |
…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.
|
please fix CI |
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.
| 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() |
There was a problem hiding this comment.
please remove, not necessary
- 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
|
Sir @tdhock, I've addressed all four review comments:
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() |
|
Sir @tdhock can you please review and give your feedback I have removed the as you said . |
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().
| 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; })()") |
There was a problem hiding this comment.
can you please use existing R helper functions instead of runtime evaluate with custom js code?
There was a problem hiding this comment.
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 .
Replace custom runtime_evaluate JS with existing R helpers per review. Assert display:block and bottom_gap for both default and custom heights.

Summary
Adds comprehensive regression tests for issue #279 to prevent reoccurrence of excessive spacing below
facet_wrapplots when using custom height parameters.Background
Issue #279 reported that when using
facet_wrap()with a customheightparameter (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
test-issue-279-facet-wrap-custom-height-spacing.Rncol=1) with 2x and 3x custom heights (800, 1200)ncol=2) with 1.5x custom height (600)What the Tests Verify
The key verification is that
height_proportionvalues remain identical across all custom heights:plot.jsonheight_proportionvalues are identical regardless of custom heightTesting