Skip to content

Add focused test coverage for utils_plot helper functions#308

Open
Schiano-NOAA with Copilot wants to merge 3 commits into
mainfrom
copilot/add-tests-for-figure-utility-functions
Open

Add focused test coverage for utils_plot helper functions#308
Schiano-NOAA with Copilot wants to merge 3 commits into
mainfrom
copilot/add-tests-for-figure-utility-functions

Conversation

Copilot AI commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

This PR adds direct testthat coverage for the plotting utility helpers in R/utils_plot.R, which previously lacked dedicated tests. It targets both plot-construction behavior and utility/data-shaping edge cases for the listed helper functions.

  • Coverage added for all requested utilities

    • New test file: tests/testthat/test-utils_plot.R
    • Adds assertions for:
      • plot_timeseries(), plot_error(), plot_aa()
      • average_age_line(), cohort_line(), reference_line()
      • axis_breaks(), cap_first_letter(), filter_data()
      • get_id(), calculate_reference_point(), label_magnitude(), check_grouping()
  • Plot behavior checks

    • Verifies returned object class (gg) for plotting helpers.
    • Verifies conditional layer behavior (e.g., horizontal line present/absent in plot_error() based on hline).
    • Verifies expected faceting/legend behavior in representative cases.
  • Data-path and scalar helper checks

    • Exercises filter_data() with both data-frame and multi-model list inputs.
    • Validates reference-point extraction (including lbs conversion and missing-reference behavior).
    • Validates string/ID/magnitude/group-detection helpers across nominal and edge inputs.

Example test pattern introduced:

error_plot_hline <- plot_error(dat, hline = TRUE)
error_plot_no_hline <- plot_error(dat, hline = FALSE)

has_hline <- function(p) {
  any(vapply(p$layers, function(layer) inherits(layer$geom, "GeomHline"), logical(1)))
}

expect_true(has_hline(error_plot_hline))
expect_false(has_hline(error_plot_no_hline))

Copilot AI linked an issue Jul 21, 2026 that may be closed by this pull request
13 tasks
Copilot AI changed the title [WIP] Add tests for figure utility functions in utils_plot.R Add focused test coverage for utils_plot helper functions Jul 21, 2026
Copilot AI requested a review from Schiano-NOAA July 21, 2026 19:45
@Schiano-NOAA
Schiano-NOAA marked this pull request as ready for review July 22, 2026 20:40
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.

Add tests for figure utility functions

2 participants