Skip to content
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 initial tests for the support_panel function #5

Closed
wants to merge 65 commits into from

Conversation

cjrace
Copy link
Contributor

@cjrace cjrace commented Nov 8, 2023

These are the first unit tests we've added so hopefully lay an example for how to add them.

Added basic validation (can be improved in future!) to the team_email argument in the support_panel() function.

I used usethis::use_test("support-panel") to set up the scripts for tests and then added a few simple test case emails in there for ones that should pass, and ones that should trigger the stop message.


Edit:

This adds R CMD Check as a way to run the tests and test the package more widely using github actions. This also adds a code coverage action using https://app.codecov.io/. That will likely only start running once this branch is merged into main

R/standard_panels.R Fixed Show resolved Hide resolved
@cjrace
Copy link
Contributor Author

cjrace commented Feb 13, 2024

Any reason for not setting up a workflow to run any tests on PRs?

The workflow I think we should set up is the general R CMD check, that runs the tests amongst other things rather than just having one for our automated tests.

Happy to add that here or in a separate branch with other workflows?

R/standard_panels.R Fixed Show fixed Hide fixed
R/standard_panels.R Fixed Show fixed Hide fixed
R/standard_panels.R Fixed Show fixed Hide fixed
R/standard_panels.R Fixed Show fixed Hide fixed
R/standard_panels.R Fixed Show fixed Hide fixed
R/standard_panels.R Fixed Show fixed Hide fixed
R/standard_panels.R Fixed Show fixed Hide fixed
R/standard_panels.R Fixed Show fixed Hide fixed
R/standard_panels.R Fixed Show fixed Hide fixed
R/standard_panels.R Fixed Show fixed Hide fixed
R/standard_panels.R Fixed Show fixed Hide fixed
R/standard_panels.R Fixed Show fixed Hide fixed
R/standard_panels.R Fixed Show fixed Hide fixed
R/standard_panels.R Fixed Show fixed Hide fixed
R/standard_panels.R Fixed Show fixed Hide fixed
Merge remote-tracking branch 'origin/cookie-module' into add-initial-tests

# Conflicts:
#	DESCRIPTION
#	R/standard_panels.R
#	README.md
#	man/support_panel.Rd
#' @param input_cookies The cookie input passed from cookies.js (should always
#' be reactive(input$cookies))
#' @param input_clear The state of the cookie reset button provided by
#' dfeshiny::support_panel(). Should always be set to reactive(input$cookie_consent_clear).

Check notice

Code scanning / lintr

Lines should not be more than 80 characters. This line is 91 characters. Note

Lines should not be more than 80 characters. This line is 91 characters.
@@ -0,0 +1,9 @@
server <- function(input, output, session) {
output$cookie_status <- cookie_banner_server(

Check warning

Code scanning / lintr

no visible global function definition for 'cookie_banner_server' Warning test

no visible global function definition for 'cookie_banner_server'
server <- function(input, output, session) {
output$cookie_status <- cookie_banner_server(
"cookies",
input_cookies = reactive(input$cookies),

Check warning

Code scanning / lintr

no visible global function definition for 'reactive' Warning test

no visible global function definition for 'reactive'
server <- function(input, output, session) {
output$cookie_status <- cookie_banner_server(
"cookies",
input_cookies = reactive(input$cookies),

Check warning

Code scanning / lintr

no visible global function definition for 'reactive' Warning test

no visible global function definition for 'reactive'
input_cookies = reactive(input$cookies),
input_clear = reactive(input$cookie_consent_clear),
parent_session = session,
google_analytics_key = google_analytics_key

Check warning

Code scanning / lintr

no visible binding for global variable 'google_analytics_key' Warning test

no visible binding for global variable 'google_analytics_key'
id = "navlistPanel",
widths = c(2, 8),
well = FALSE,
support_panel(

Check warning

Code scanning / lintr

no visible global function definition for 'support_panel' Warning test

no visible global function definition for 'support_panel'
#' @export
#'
#' @examples
#' # To use the banner, first copy the file cookie-consent.js from the js/ folder

Check notice

Code scanning / lintr

Lines should not be more than 80 characters. This line is 81 characters. Note

Lines should not be more than 80 characters. This line is 81 characters.
#' dfe_cookie_script()
#' cookie_banner_ui("cookies", name = "My DfE R-Shiny data dashboard")
#'
#' # And add the following in server.R (after updating the google analytics key):

Check notice

Code scanning / lintr

Lines should not be more than 80 characters. This line is 81 characters. Note

Lines should not be more than 80 characters. This line is 81 characters.
#' @export
#'
#' @examples
#' # To use the banner, first copy the file cookie-consent.js from the js/ folder

Check notice

Code scanning / lintr

Lines should not be more than 80 characters. This line is 81 characters. Note

Lines should not be more than 80 characters. This line is 81 characters.
#' dfe_cookie_script()
#' cookie_banner_ui("cookies", name = "My DfE R-Shiny data dashboard")
#'
#' # And add the following in server.R (after updating the google analytics key):

Check notice

Code scanning / lintr

Lines should not be more than 80 characters. This line is 81 characters. Note

Lines should not be more than 80 characters. This line is 81 characters.
@cjrace cjrace marked this pull request as draft February 15, 2024 18:17
@cjrace cjrace marked this pull request as ready for review February 15, 2024 18:29
@cjrace cjrace marked this pull request as draft February 15, 2024 18:29
@cjrace
Copy link
Contributor Author

cjrace commented Feb 18, 2024

Closing in favour of a new PR

@cjrace cjrace closed this Feb 18, 2024
@cjrace cjrace deleted the add-initial-tests branch February 18, 2024 11:03
@cjrace cjrace mentioned this pull request Feb 18, 2024
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