-
Notifications
You must be signed in to change notification settings - Fork 0
add tests #92
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add tests #92
Conversation
|
currently hitting 80.43% coverage. I've not added tests for the fct_plots/fct_table files, largely because testing plots is tricky at best (you can try snapshots, but they will vary on OS so can be hard to build snapshots and have them run in actions reliably). I have refactored some of the code to make it easier to test, such as adding new helper functions, or refactoring existing functions. I have tested the app locally and functionality appears to be identical. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This pull request adds comprehensive unit tests to the tpma.explorer R package, along with several code refactorings and bug fixes to improve testability and maintainability.
Changes:
- Added comprehensive test suite covering utility functions, Shiny modules, and app components using testthat and mockery
- Refactored
fetch_strategy_textto use httr2 instead of utils::download.file for better testability - Fixed bug in
prepare_diagnoses_databy changing frominner_jointoleft_jointo preserve unknown diagnosis codes - Refactored several functions to improve separation of concerns and testability (e.g., extracting
get_rates_data,get_rates_trend_data,get_peers_lookup) - Simplified
make_strategy_group_lookupto return a named list instead of a tibble - Updated configuration files (.lintr, air.toml) for code quality
Reviewed changes
Copilot reviewed 61 out of 61 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/testthat/*.R | Comprehensive unit tests for all utility functions and Shiny modules |
| tests/testthat/_snaps/*.md | Snapshot tests for UI components |
| tests/testthat.R, setup.R | Standard testthat configuration |
| R/utils_table.R | Bug fix: changed inner_join to left_join in prepare_diagnoses_data |
| R/utils_show_strategy_text.R | Refactored to use httr2 for HTTP requests; removed convert_md_to_html |
| R/utils_server.R | Moved get_container function from R/fct_azure.R |
| R/utils_plot_rates.R | New utility functions extracted for better testability |
| R/utils_plot.R | Updated generate_rates_baseline_data signature |
| R/utils_data.R | Added md_string_to_html; refactored make_strategy_group_lookup |
| R/mod_*.R | Various refactorings to improve testability |
| DESCRIPTION | Added testthat and httr2 dependencies |
| NAMESPACE | Updated exports to reflect function changes |
| man/*.Rd | Updated documentation for refactored functions |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
all of the setup functions, and sample data, now exist in helper scripts. this is useful as these helper scripts are loaded with pkgload::load_all, so you can run individual tests. if you don't use helpers, trying to run a test in isolation can fail as it fails to source the entire test script and load in the setup functions
matt-dray
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Tom, you talked me through the code changes and the tests themselves. I'm grateful for this ahead of the app's release into the wider world.
One (!) snapshot test errored for me locally: ui in test-app_ui.R. It's related to the feedback form URL, which is obfuscated as an env var. Can you adjust the ui test to use the approach I used in nhp_outputs?
@matt-dray resolved in d3f55b7 |
matt-dray
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cracking, all pass.
adds unit tests to the package