Context
v1.1.0 shipped to CRAN with a critical rendering bug: the drawDetails.DiceGrob S3 method was never registered in NAMESPACE, so dice plots rendered as blank panels on all R versions. This went undetected because the package had no automated tests for visual output. See #9, #10.
Problem
The current test infrastructure has no coverage for:
- S3 method dispatch — the drawDetails.DiceGrob registration gap would have been caught by a test that simply renders a plot and checks the resulting grob tree for expected children (tiles + points).
- Visual output correctness — there are no tests verifying that pips actually appear, have non-NA colours, or are positioned within tile boundaries.
- ggplot2 version compatibility — the package declares ggplot2 (>= 3.4.0) but was never tested against ggplot2 4.x before the CRAN release.
Proposed improvements
- Basic rendering tests (testthat):
- Build a plot with geom_dice(), call ggplotGrob() / layer_grob(), and assert that the DiceGrob contains a non-zero number of point grobs.
- Test with fill mapped, fill unmapped, size mapped, and size unmapped to cover all draw paths.
- Test all ndots values (1–6).
- Aesthetic correctness tests:
- Assert that point_df$colour is never NA when the plot should show visible pips.
- Assert pip coordinates fall within tile boundaries.
- Assert pip count matches expected data (no silent row drops).
- CI matrix:
- Add GitHub Actions workflow testing against ggplot2 release, ggplot2 devel, and the minimum supported version (3.4.0).
- Test on R-release and R-oldrel at minimum.
- Snapshot tests (optional):
- Use vdiffr::expect_doppelganger() for key plot configurations to catch unexpected visual changes between releases.
Priority
High — the v1.2.0 fix was straightforward but the bug affected every user on ggplot2 >= 4.0. Even lightweight grob-inspection tests would have prevented this from reaching CRAN.
Context
v1.1.0 shipped to CRAN with a critical rendering bug: the drawDetails.DiceGrob S3 method was never registered in NAMESPACE, so dice plots rendered as blank panels on all R versions. This went undetected because the package had no automated tests for visual output. See #9, #10.
Problem
The current test infrastructure has no coverage for:
Proposed improvements
- Build a plot with geom_dice(), call ggplotGrob() / layer_grob(), and assert that the DiceGrob contains a non-zero number of point grobs.
- Test with fill mapped, fill unmapped, size mapped, and size unmapped to cover all draw paths.
- Test all ndots values (1–6).
- Assert that point_df$colour is never NA when the plot should show visible pips.
- Assert pip coordinates fall within tile boundaries.
- Assert pip count matches expected data (no silent row drops).
- Add GitHub Actions workflow testing against ggplot2 release, ggplot2 devel, and the minimum supported version (3.4.0).
- Test on R-release and R-oldrel at minimum.
- Use vdiffr::expect_doppelganger() for key plot configurations to catch unexpected visual changes between releases.
Priority
High — the v1.2.0 fix was straightforward but the bug affected every user on ggplot2 >= 4.0. Even lightweight grob-inspection tests would have prevented this from reaching CRAN.