diff --git a/DESCRIPTION b/DESCRIPTION index e988f52..cfe669d 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -30,7 +30,7 @@ Suggests: Config/testthat/edition: 3 Encoding: UTF-8 Roxygen: list(markdown = TRUE) -RoxygenNote: 7.3.1 +RoxygenNote: 7.3.2 URL: https://dfe-analytical-services.github.io/dfeshiny/ https://www.github.com/dfe-analytical-services/dfeshiny/ VignetteBuilder: knitr diff --git a/R/cookies.R b/R/cookies.R index 261da09..909457b 100644 --- a/R/cookies.R +++ b/R/cookies.R @@ -1,10 +1,54 @@ #' dfe_cookie_script #' +#' Calls in JavaScript dependencies to the shiny app used to set and unset the +#' cookies. Function should be placed in the ui.R script. +#' +#' @name cookies #' @return shiny::tags$head() #' @export #' +#' @family cookies #' @examples -#' dfe_cookie_script() +#' if (interactive()) { +#' # This example shows how to use the full family of cookie functions together +#' # This will be in your global.R script ===================================== +#' +#' library(shiny) +#' library(shinyjs) +#' library(dfeshiny) +#' ga_key <- "ABCDE12345" +#' +#' # This will be what is in your ui.R script ================================= +#' +#' ui <- fluidPage( +#' # Place these lines above your header ------------------------------------ +#' dfe_cookie_script(), +#' useShinyjs(), +#' cookie_banner_ui(name = "My DfE R-Shiny data dashboard"), +#' +#' # Place the cookies panel under the header but in the main content ------- +#' cookies_panel_ui(google_analytics_key = ga_key) +#' ) +#' +#' # This will be in your server.R file ======================================= +#' +#' server <- function(input, output, session) { +#' # Server logic for the pop up banner, can be placed anywhere in server.R - +#' output$cookie_status <- dfeshiny::cookie_banner_server( +#' input_cookies = reactive(input$cookies), +#' google_analytics_key = ga_key +#' ) +#' +#' # Server logic for the panel, can be placed anywhere in server.R --------- +#' cookies_panel_server( +#' input_cookies = reactive(input$cookies), +#' google_analytics_key = ga_key +#' ) +#' } +#' +#' # How to run the minimal app given in this example ========================= +#' shinyApp(ui, server) +#' } dfe_cookie_script <- function() { shiny::tags$head( shiny::tags$script( @@ -26,16 +70,16 @@ dfe_cookie_script <- function() { #' functionality is provided by cookie_banner_server(), whilst users will also #' need to include the dfe_cookie_script() function in their ui.R file. #' -#' @param id Shiny tag shared with cookie_banner_server() +#' @param id Shiny tag shared with cookie_banner_server(), can be any string set +#' by the user as long as it matches the id in the cookie_banner_server() #' @param name Name of the dashboard on which the cookie authorisation is being #' applied #' +#' @family cookies #' @return shiny::tags$div() #' @export -#' -#' @examples -#' cookie_banner_ui("cookies", name = "My DfE R-Shiny data dashboard") -cookie_banner_ui <- function(id, name = "DfE R-Shiny dashboard template") { +#' @inherit cookies examples +cookie_banner_ui <- function(id = "cookies_banner", name = "DfE R-Shiny dashboard template") { shiny::tags$div( id = shiny::NS(id, "cookie_div"), class = "govuk-cookie-banner", @@ -94,35 +138,27 @@ cookie_banner_ui <- function(id, name = "DfE R-Shiny dashboard template") { #' reject cookie consent for the provision of Google Analytics tracking on DfE #' R-Shiny dashboards. #' -#' @param id Shiny tag shared with cookie_banner_ui() +#' @param id Shiny tag shared with cookie_banner_ui(), can be any string set by +#' the user as long as it matches the id in the cookie_banner_ui() #' @param input_cookies The cookie input passed from cookies.js (should always -#' be reactive(input$cookies)) -#' Should always be set to reactive(input$cookie_consent_clear). +#' be `reactive(input$cookies)`) #' @param parent_session This should be the R Shiny app session #' @param google_analytics_key Provide the GA 10 digit key of the form #' "ABCDE12345" #' @param cookie_link_panel name of the navlistPanel that the cookie banner #' provides a link to, usually "cookies_panel_ui" #' +#' @family cookies #' @return NULL #' @export #' -#' @examples -#' \dontrun{ -#' output$cookie_status <- dfeshiny::cookie_banner_server( -#' "cookies", -#' input_cookies = reactive(input$cookies), -#' parent_session = session, -#' google_analytics_key = "ABCDE12345", -#' cookie_link_panel = "cookies_panel_ui" -#' ) -#' } +#' @inherit cookies examples cookie_banner_server <- function( - id, - input_cookies, - parent_session, + id = "cookies_banner", + input_cookies = reactive(input$cookies), + parent_session = session, google_analytics_key = NULL, - cookie_link_panel) { + cookie_link_panel = "cookies_panel_ui") { shiny::moduleServer(id, function(input, output, session) { if (is.null(google_analytics_key)) { warning("Please provide a valid Google Analytics key") @@ -252,23 +288,15 @@ init_cookies <- function() { #' Create the standard DfE R-Shiny cookies dashboard panel in the ui. The server #' side functionality is provided by cookies_panel_server() #' -#' @param id ID shared with cookies_panel_server() +#' @param id Shiny tag shared with cookies_panel_server(), can be any string set by +#' the user as long as it matches the id in the cookies_panel_server() #' @param google_analytics_key Provide the GA 10 digit key of the form #' "ABCDE12345" #' -#' #' @return a standardised panel for a public R Shiny dashboard in DfE #' @export -#' -#' @examples -#' \dontrun{ -#' cookies_panel_ui( -#' id = "cookies_panel", -#' google_analytics_key = "ABCDE12345" -#' ) -#' } -#' -cookies_panel_ui <- function(id, google_analytics_key = NULL) { +#' @inherit cookies examples +cookies_panel_ui <- function(id = "cookies_panel", google_analytics_key = NULL) { # Build the support page ---------------------------------------------------- shiny::tabPanel( id = shiny::NS(id, "cookies_panel"), @@ -374,24 +402,18 @@ cookies_panel_ui <- function(id, google_analytics_key = NULL) { #' Create the server module of DfE R-Shiny cookies dashboard panel to be used #' alongside cookies_panel_ui(). #' -#' @param id ID shared with cookies_panel_ui() +#' @param id Shiny tag shared with cookies_panel_ui(), can be any string set by +#' the user as long as it matches the id in the cookies_panel_ui() #' @param input_cookies The cookie input passed from cookies.js (should always -#' be reactive(input$cookies)) +#' be `reactive(input$cookies))` #' @param google_analytics_key Provide the GA 10 digit key of the form #' "ABCDE12345" #' #' @export -#' -#' @examples -#' \dontrun{ -#' cookies_panel_server( -#' id = "cookies_panel", -#' input_cookies = reactive(input$cookies), -#' google_analytics_key = "ABCDE12345" -#' ) -#' } -cookies_panel_server <- function(id, - input_cookies, +#' @inherit cookies examples +cookies_panel_server <- function(id = "cookies_panel", + input_cookies = reactive(input$cookies), + google_analytics_key = NULL) { shiny::moduleServer(id, module = function(input, output, session) { shiny::observeEvent(input_cookies(), { diff --git a/man/cookie_banner_server.Rd b/man/cookie_banner_server.Rd index 74301f6..3367981 100644 --- a/man/cookie_banner_server.Rd +++ b/man/cookie_banner_server.Rd @@ -5,19 +5,19 @@ \title{cookie_banner_server} \usage{ cookie_banner_server( - id, - input_cookies, - parent_session, + id = "cookies_banner", + input_cookies = reactive(input$cookies), + parent_session = session, google_analytics_key = NULL, - cookie_link_panel + cookie_link_panel = "cookies_panel_ui" ) } \arguments{ -\item{id}{Shiny tag shared with cookie_banner_ui()} +\item{id}{Shiny tag shared with cookie_banner_ui(), can be any string set by +the user as long as it matches the id in the cookie_banner_ui()} \item{input_cookies}{The cookie input passed from cookies.js (should always -be reactive(input$cookies)) -Should always be set to reactive(input$cookie_consent_clear).} +be \code{reactive(input$cookies)})} \item{parent_session}{This should be the R Shiny app session} @@ -35,13 +35,50 @@ reject cookie consent for the provision of Google Analytics tracking on DfE R-Shiny dashboards. } \examples{ -\dontrun{ -output$cookie_status <- dfeshiny::cookie_banner_server( - "cookies", - input_cookies = reactive(input$cookies), - parent_session = session, - google_analytics_key = "ABCDE12345", - cookie_link_panel = "cookies_panel_ui" -) +if (interactive()) { + # This example shows how to use the full family of cookie functions together + # This will be in your global.R script ===================================== + + library(shiny) + library(shinyjs) + library(dfeshiny) + ga_key <- "ABCDE12345" + + # This will be what is in your ui.R script ================================= + + ui <- fluidPage( + # Place these lines above your header ------------------------------------ + dfe_cookie_script(), + useShinyjs(), + cookie_banner_ui(name = "My DfE R-Shiny data dashboard"), + + # Place the cookies panel under the header but in the main content ------- + cookies_panel_ui(google_analytics_key = ga_key) + ) + + # This will be in your server.R file ======================================= + + server <- function(input, output, session) { + # Server logic for the pop up banner, can be placed anywhere in server.R - + output$cookie_status <- dfeshiny::cookie_banner_server( + input_cookies = reactive(input$cookies), + google_analytics_key = ga_key + ) + + # Server logic for the panel, can be placed anywhere in server.R --------- + cookies_panel_server( + input_cookies = reactive(input$cookies), + google_analytics_key = ga_key + ) + } + + # How to run the minimal app given in this example ========================= + shinyApp(ui, server) +} } +\seealso{ +Other cookies: +\code{\link{cookie_banner_ui}()}, +\code{\link{cookies}} } +\concept{cookies} diff --git a/man/cookie_banner_ui.Rd b/man/cookie_banner_ui.Rd index 038166f..8a48f18 100644 --- a/man/cookie_banner_ui.Rd +++ b/man/cookie_banner_ui.Rd @@ -4,10 +4,14 @@ \alias{cookie_banner_ui} \title{cookie_banner_ui} \usage{ -cookie_banner_ui(id, name = "DfE R-Shiny dashboard template") +cookie_banner_ui( + id = "cookies_banner", + name = "DfE R-Shiny dashboard template" +) } \arguments{ -\item{id}{Shiny tag shared with cookie_banner_server()} +\item{id}{Shiny tag shared with cookie_banner_server(), can be any string set +by the user as long as it matches the id in the cookie_banner_server()} \item{name}{Name of the dashboard on which the cookie authorisation is being applied} @@ -22,5 +26,50 @@ functionality is provided by cookie_banner_server(), whilst users will also need to include the dfe_cookie_script() function in their ui.R file. } \examples{ -cookie_banner_ui("cookies", name = "My DfE R-Shiny data dashboard") +if (interactive()) { + # This example shows how to use the full family of cookie functions together + # This will be in your global.R script ===================================== + + library(shiny) + library(shinyjs) + library(dfeshiny) + ga_key <- "ABCDE12345" + + # This will be what is in your ui.R script ================================= + + ui <- fluidPage( + # Place these lines above your header ------------------------------------ + dfe_cookie_script(), + useShinyjs(), + cookie_banner_ui(name = "My DfE R-Shiny data dashboard"), + + # Place the cookies panel under the header but in the main content ------- + cookies_panel_ui(google_analytics_key = ga_key) + ) + + # This will be in your server.R file ======================================= + + server <- function(input, output, session) { + # Server logic for the pop up banner, can be placed anywhere in server.R - + output$cookie_status <- dfeshiny::cookie_banner_server( + input_cookies = reactive(input$cookies), + google_analytics_key = ga_key + ) + + # Server logic for the panel, can be placed anywhere in server.R --------- + cookies_panel_server( + input_cookies = reactive(input$cookies), + google_analytics_key = ga_key + ) + } + + # How to run the minimal app given in this example ========================= + shinyApp(ui, server) +} +} +\seealso{ +Other cookies: +\code{\link{cookie_banner_server}()}, +\code{\link{cookies}} } +\concept{cookies} diff --git a/man/cookies.Rd b/man/cookies.Rd new file mode 100644 index 0000000..1eeaf47 --- /dev/null +++ b/man/cookies.Rd @@ -0,0 +1,64 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/cookies.R +\name{cookies} +\alias{cookies} +\alias{dfe_cookie_script} +\title{dfe_cookie_script} +\usage{ +dfe_cookie_script() +} +\value{ +shiny::tags$head() +} +\description{ +Calls in JavaScript dependencies to the shiny app used to set and unset the +cookies. Function should be placed in the ui.R script. +} +\examples{ +if (interactive()) { + # This example shows how to use the full family of cookie functions together + # This will be in your global.R script ===================================== + + library(shiny) + library(shinyjs) + library(dfeshiny) + ga_key <- "ABCDE12345" + + # This will be what is in your ui.R script ================================= + + ui <- fluidPage( + # Place these lines above your header ------------------------------------ + dfe_cookie_script(), + useShinyjs(), + cookie_banner_ui(name = "My DfE R-Shiny data dashboard"), + + # Place the cookies panel under the header but in the main content ------- + cookies_panel_ui(google_analytics_key = ga_key) + ) + + # This will be in your server.R file ======================================= + + server <- function(input, output, session) { + # Server logic for the pop up banner, can be placed anywhere in server.R - + output$cookie_status <- dfeshiny::cookie_banner_server( + input_cookies = reactive(input$cookies), + google_analytics_key = ga_key + ) + + # Server logic for the panel, can be placed anywhere in server.R --------- + cookies_panel_server( + input_cookies = reactive(input$cookies), + google_analytics_key = ga_key + ) + } + + # How to run the minimal app given in this example ========================= + shinyApp(ui, server) +} +} +\seealso{ +Other cookies: +\code{\link{cookie_banner_server}()}, +\code{\link{cookie_banner_ui}()} +} +\concept{cookies} diff --git a/man/cookies_panel_server.Rd b/man/cookies_panel_server.Rd index 43d0ae3..778dcd7 100644 --- a/man/cookies_panel_server.Rd +++ b/man/cookies_panel_server.Rd @@ -4,13 +4,18 @@ \alias{cookies_panel_server} \title{cookies_panel_server} \usage{ -cookies_panel_server(id, input_cookies, google_analytics_key = NULL) +cookies_panel_server( + id = "cookies_panel", + input_cookies = reactive(input$cookies), + google_analytics_key = NULL +) } \arguments{ -\item{id}{ID shared with cookies_panel_ui()} +\item{id}{Shiny tag shared with cookies_panel_ui(), can be any string set by +the user as long as it matches the id in the cookies_panel_ui()} \item{input_cookies}{The cookie input passed from cookies.js (should always -be reactive(input$cookies))} +be \verb{reactive(input$cookies))}} \item{google_analytics_key}{Provide the GA 10 digit key of the form "ABCDE12345"} @@ -20,11 +25,44 @@ Create the server module of DfE R-Shiny cookies dashboard panel to be used alongside cookies_panel_ui(). } \examples{ -\dontrun{ -cookies_panel_server( - id = "cookies_panel", - input_cookies = reactive(input$cookies), - google_analytics_key = "ABCDE12345" -) +if (interactive()) { + # This example shows how to use the full family of cookie functions together + # This will be in your global.R script ===================================== + + library(shiny) + library(shinyjs) + library(dfeshiny) + ga_key <- "ABCDE12345" + + # This will be what is in your ui.R script ================================= + + ui <- fluidPage( + # Place these lines above your header ------------------------------------ + dfe_cookie_script(), + useShinyjs(), + cookie_banner_ui(name = "My DfE R-Shiny data dashboard"), + + # Place the cookies panel under the header but in the main content ------- + cookies_panel_ui(google_analytics_key = ga_key) + ) + + # This will be in your server.R file ======================================= + + server <- function(input, output, session) { + # Server logic for the pop up banner, can be placed anywhere in server.R - + output$cookie_status <- dfeshiny::cookie_banner_server( + input_cookies = reactive(input$cookies), + google_analytics_key = ga_key + ) + + # Server logic for the panel, can be placed anywhere in server.R --------- + cookies_panel_server( + input_cookies = reactive(input$cookies), + google_analytics_key = ga_key + ) + } + + # How to run the minimal app given in this example ========================= + shinyApp(ui, server) } } diff --git a/man/cookies_panel_ui.Rd b/man/cookies_panel_ui.Rd index e609394..831dbb2 100644 --- a/man/cookies_panel_ui.Rd +++ b/man/cookies_panel_ui.Rd @@ -4,10 +4,11 @@ \alias{cookies_panel_ui} \title{cookies_panel_ui} \usage{ -cookies_panel_ui(id, google_analytics_key = NULL) +cookies_panel_ui(id = "cookies_panel", google_analytics_key = NULL) } \arguments{ -\item{id}{ID shared with cookies_panel_server()} +\item{id}{Shiny tag shared with cookies_panel_server(), can be any string set by +the user as long as it matches the id in the cookies_panel_server()} \item{google_analytics_key}{Provide the GA 10 digit key of the form "ABCDE12345"} @@ -20,11 +21,44 @@ Create the standard DfE R-Shiny cookies dashboard panel in the ui. The server side functionality is provided by cookies_panel_server() } \examples{ -\dontrun{ -cookies_panel_ui( - id = "cookies_panel", - google_analytics_key = "ABCDE12345" -) -} +if (interactive()) { + # This example shows how to use the full family of cookie functions together + # This will be in your global.R script ===================================== + + library(shiny) + library(shinyjs) + library(dfeshiny) + ga_key <- "ABCDE12345" + + # This will be what is in your ui.R script ================================= + + ui <- fluidPage( + # Place these lines above your header ------------------------------------ + dfe_cookie_script(), + useShinyjs(), + cookie_banner_ui(name = "My DfE R-Shiny data dashboard"), + + # Place the cookies panel under the header but in the main content ------- + cookies_panel_ui(google_analytics_key = ga_key) + ) + # This will be in your server.R file ======================================= + + server <- function(input, output, session) { + # Server logic for the pop up banner, can be placed anywhere in server.R - + output$cookie_status <- dfeshiny::cookie_banner_server( + input_cookies = reactive(input$cookies), + google_analytics_key = ga_key + ) + + # Server logic for the panel, can be placed anywhere in server.R --------- + cookies_panel_server( + input_cookies = reactive(input$cookies), + google_analytics_key = ga_key + ) + } + + # How to run the minimal app given in this example ========================= + shinyApp(ui, server) +} } diff --git a/man/dfe_cookie_script.Rd b/man/dfe_cookie_script.Rd deleted file mode 100644 index 15af849..0000000 --- a/man/dfe_cookie_script.Rd +++ /dev/null @@ -1,17 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/cookies.R -\name{dfe_cookie_script} -\alias{dfe_cookie_script} -\title{dfe_cookie_script} -\usage{ -dfe_cookie_script() -} -\value{ -shiny::tags$head() -} -\description{ -dfe_cookie_script -} -\examples{ -dfe_cookie_script() -} diff --git a/tests/test_dashboard/global.R b/tests/test_dashboard/global.R index 0ad3c3b..8e7fd4c 100644 --- a/tests/test_dashboard/global.R +++ b/tests/test_dashboard/global.R @@ -1,4 +1,4 @@ library(shiny) devtools::load_all(path = "../../") -google_analytics_key <- "ABCDE12345" +ga_key <- "ABCDE12345" diff --git a/tests/test_dashboard/server.R b/tests/test_dashboard/server.R index c21bf8c..d8a539a 100644 --- a/tests/test_dashboard/server.R +++ b/tests/test_dashboard/server.R @@ -5,17 +5,12 @@ server <- function(input, output, session) { ) output$cookie_status <- cookie_banner_server( - "cookies", - input_cookies = shiny::reactive(input$cookies), - parent_session = session, - google_analytics_key = google_analytics_key, # # nolint: [object_usage_linter] - cookie_link_panel = "cookies_panel_ui" + input_cookies = reactive(input$cookies), + google_analytics_key = ga_key # nolint: [object_usage_linter] ) - cookies_panel_server( - id = "cookies_panel", - input_cookies = shiny::reactive(input$cookies), - google_analytics_key = google_analytics_key # # nolint: [object_usage_linter] + input_cookies = reactive(input$cookies), + google_analytics_key = ga_key # nolint: [object_usage_linter] ) } diff --git a/tests/test_dashboard/tests/testthat/_snaps/cookie-auth/cookie_consent-001.json b/tests/test_dashboard/tests/testthat/_snaps/cookie-auth/cookie_consent-001.json index df04873..1fb8c63 100644 --- a/tests/test_dashboard/tests/testthat/_snaps/cookie-auth/cookie_consent-001.json +++ b/tests/test_dashboard/tests/testthat/_snaps/cookie-auth/cookie_consent-001.json @@ -3,9 +3,9 @@ "cookies": { }, - "cookies-cookie_accept": 0, - "cookies-cookie_link": 0, - "cookies-cookie_reject": 0, + "cookies_banner-cookie_accept": 0, + "cookies_banner-cookie_link": 0, + "cookies_banner-cookie_reject": 0, "cookies_panel-cookies_analytics": "no", "cookies_panel-submit_btn": 0, "navlistPanel": "support_panel" diff --git a/tests/test_dashboard/tests/testthat/_snaps/cookie-auth/cookie_consent-001_.new.png b/tests/test_dashboard/tests/testthat/_snaps/cookie-auth/cookie_consent-001_.new.png deleted file mode 100644 index f9ff9dd..0000000 Binary files a/tests/test_dashboard/tests/testthat/_snaps/cookie-auth/cookie_consent-001_.new.png and /dev/null differ diff --git a/tests/test_dashboard/tests/testthat/_snaps/cookie-auth/cookie_consent-001_.png b/tests/test_dashboard/tests/testthat/_snaps/cookie-auth/cookie_consent-001_.png index f3db118..88b5e7a 100644 Binary files a/tests/test_dashboard/tests/testthat/_snaps/cookie-auth/cookie_consent-001_.png and b/tests/test_dashboard/tests/testthat/_snaps/cookie-auth/cookie_consent-001_.png differ diff --git a/tests/test_dashboard/tests/testthat/_snaps/cookie-auth/cookie_consent-002.json b/tests/test_dashboard/tests/testthat/_snaps/cookie-auth/cookie_consent-002.json index 76e1d43..3abae31 100644 --- a/tests/test_dashboard/tests/testthat/_snaps/cookie-auth/cookie_consent-002.json +++ b/tests/test_dashboard/tests/testthat/_snaps/cookie-auth/cookie_consent-002.json @@ -3,9 +3,9 @@ "cookies": { "dfe_analytics": "granted" }, - "cookies-cookie_accept": 1, - "cookies-cookie_link": 0, - "cookies-cookie_reject": 0, + "cookies_banner-cookie_accept": 1, + "cookies_banner-cookie_link": 0, + "cookies_banner-cookie_reject": 0, "cookies_panel-cookies_analytics": "yes", "cookies_panel-submit_btn": 0, "navlistPanel": "support_panel" diff --git a/tests/test_dashboard/tests/testthat/_snaps/cookie-auth/cookie_consent-003.json b/tests/test_dashboard/tests/testthat/_snaps/cookie-auth/cookie_consent-003.json index cdb69e2..0f73b32 100644 --- a/tests/test_dashboard/tests/testthat/_snaps/cookie-auth/cookie_consent-003.json +++ b/tests/test_dashboard/tests/testthat/_snaps/cookie-auth/cookie_consent-003.json @@ -3,9 +3,9 @@ "cookies": { "dfe_analytics": "denied" }, - "cookies-cookie_accept": 1, - "cookies-cookie_link": 0, - "cookies-cookie_reject": 1, + "cookies_banner-cookie_accept": 1, + "cookies_banner-cookie_link": 0, + "cookies_banner-cookie_reject": 1, "cookies_panel-cookies_analytics": "no", "cookies_panel-submit_btn": 0, "navlistPanel": "support_panel" diff --git a/tests/test_dashboard/tests/testthat/_snaps/cookie-auth/cookie_consent-004.json b/tests/test_dashboard/tests/testthat/_snaps/cookie-auth/cookie_consent-004.json index 6f912d4..318fc7f 100644 --- a/tests/test_dashboard/tests/testthat/_snaps/cookie-auth/cookie_consent-004.json +++ b/tests/test_dashboard/tests/testthat/_snaps/cookie-auth/cookie_consent-004.json @@ -3,9 +3,9 @@ "cookies": { "dfe_analytics": "granted" }, - "cookies-cookie_accept": 1, - "cookies-cookie_link": 0, - "cookies-cookie_reject": 1, + "cookies_banner-cookie_accept": 1, + "cookies_banner-cookie_link": 0, + "cookies_banner-cookie_reject": 1, "cookies_panel-cookies_analytics": "yes", "cookies_panel-submit_btn": 1, "navlistPanel": "support_panel" diff --git a/tests/test_dashboard/tests/testthat/_snaps/cookie-auth/cookie_consent-005.json b/tests/test_dashboard/tests/testthat/_snaps/cookie-auth/cookie_consent-005.json index 9065917..fd79ef6 100644 --- a/tests/test_dashboard/tests/testthat/_snaps/cookie-auth/cookie_consent-005.json +++ b/tests/test_dashboard/tests/testthat/_snaps/cookie-auth/cookie_consent-005.json @@ -3,9 +3,9 @@ "cookies": { "dfe_analytics": "denied" }, - "cookies-cookie_accept": 1, - "cookies-cookie_link": 0, - "cookies-cookie_reject": 1, + "cookies_banner-cookie_accept": 1, + "cookies_banner-cookie_link": 0, + "cookies_banner-cookie_reject": 1, "cookies_panel-cookies_analytics": "no", "cookies_panel-submit_btn": 2, "navlistPanel": "support_panel" diff --git a/tests/test_dashboard/tests/testthat/test-cookie-auth.R b/tests/test_dashboard/tests/testthat/test-cookie-auth.R index cd220cb..6939ed3 100644 --- a/tests/test_dashboard/tests/testthat/test-cookie-auth.R +++ b/tests/test_dashboard/tests/testthat/test-cookie-auth.R @@ -21,13 +21,13 @@ test_that("App loads", { app$expect_values() }) -app$click("cookies-cookie_accept") +app$click("cookies_banner-cookie_accept") test_that("Cookies accepted banner", { # Capture initial values app$expect_values() }) -app$click("cookies-cookie_reject") +app$click("cookies_banner-cookie_reject") test_that("Cookies rejected banner", { # Capture initial values app$expect_values() diff --git a/tests/test_dashboard/ui.R b/tests/test_dashboard/ui.R index 4dcd13f..7dd123a 100644 --- a/tests/test_dashboard/ui.R +++ b/tests/test_dashboard/ui.R @@ -11,7 +11,7 @@ ui <- function(input, output, session) { publication_link = "https://explore-education-statistics.service.gov.uk/find-statistics/pupil-attendance-in-schools" # nolint: [line_length_linter] ), dfe_cookie_script(), - cookie_banner_ui("cookies"), + cookie_banner_ui(name = "My DfE R-Shiny data dashboard"), shiny::navlistPanel( "", id = "navlistPanel", @@ -22,10 +22,7 @@ ui <- function(input, output, session) { repo_name = "https://github.com/dfe-analytical-services/dfeshiny/", form_url = "https://forms.office.com" ), - cookies_panel_ui( - id = "cookies_panel", - google_analytics_key = google_analytics_key - ) # # nolint: [object_usage_linter] + cookies_panel_ui(google_analytics_key = ga_key) # nolint: [object_usage_linter] ) ) }