From 7391580f41faeeda30db45e9d1b1b600a7d53f68 Mon Sep 17 00:00:00 2001 From: m7pr Date: Thu, 21 Mar 2024 13:29:24 +0100 Subject: [PATCH 01/12] add self$wait_for_idle method and add it to initialize for TealAppDriver --- R/TealAppDriver.R | 7 +++++++ man/TealAppDriver.Rd | 19 ++++++++++++++++++- man/reporter_previewer_module.Rd | 6 +++--- tests/testthat/helper-shinytest2.R | 2 +- tests/testthat/test-shinytest2-filter_panel.R | 6 ------ tests/testthat/test-shinytest2-init.R | 3 --- .../testthat/test-shinytest2-landing_popup.R | 6 ------ tests/testthat/test-shinytest2-modules.R | 5 +---- tests/testthat/test-shinytest2-reporter.R | 1 - tests/testthat/test-shinytest2-show-rcode.R | 1 - 10 files changed, 30 insertions(+), 26 deletions(-) diff --git a/R/TealAppDriver.R b/R/TealAppDriver.R index 2a1b5bbf5c..2438140fd6 100644 --- a/R/TealAppDriver.R +++ b/R/TealAppDriver.R @@ -47,6 +47,13 @@ TealAppDriver <- R6::R6Class( # nolint: object_name. ) private$set_active_ns() + self$wait_for_idle() + }, + #' @description + #' Set custom values for `duration` and `timeout` in parent [`AppDriver`] `waif_for_idle()` method. + #' @param duration,timeout (`numeric(1)`) passed to parent [`AppDriver`] `waif_for_idle()` method. + wait_for_idle = function(duration = 500, timeout = 20000) { + super$wait_for_idle(duration = duration, timeout = timeout) }, #' @description #' Check if the app has shiny errors. This checks for global shiny errors. diff --git a/man/TealAppDriver.Rd b/man/TealAppDriver.Rd index a2f2db3ef2..d65abe39a8 100644 --- a/man/TealAppDriver.Rd +++ b/man/TealAppDriver.Rd @@ -20,6 +20,7 @@ driving a teal application for performing interactions for \code{shinytest2} tes \subsection{Public methods}{ \itemize{ \item \href{#method-TealAppDriver-new}{\code{TealAppDriver$new()}} +\item \href{#method-TealAppDriver-wait_for_idle}{\code{TealAppDriver$wait_for_idle()}} \item \href{#method-TealAppDriver-expect_no_shiny_error}{\code{TealAppDriver$expect_no_shiny_error()}} \item \href{#method-TealAppDriver-expect_no_validation_error}{\code{TealAppDriver$expect_no_validation_error()}} \item \href{#method-TealAppDriver-expect_validation_error}{\code{TealAppDriver$expect_validation_error()}} @@ -75,7 +76,6 @@ driving a teal application for performing interactions for \code{shinytest2} tes
  • shinytest2::AppDriver$stop()
  • shinytest2::AppDriver$upload_file()
  • shinytest2::AppDriver$view()
  • -
  • shinytest2::AppDriver$wait_for_idle()
  • shinytest2::AppDriver$wait_for_js()
  • shinytest2::AppDriver$wait_for_value()
  • @@ -112,6 +112,23 @@ Object of class \code{TealAppDriver} } } \if{html}{\out{
    }} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-TealAppDriver-wait_for_idle}{}}} +\subsection{Method \code{wait_for_idle()}}{ +Set custom values for \code{duration} and \code{timeout} in parent \code{\link{AppDriver}} \code{waif_for_idle()} method. +\subsection{Usage}{ +\if{html}{\out{
    }}\preformatted{TealAppDriver$wait_for_idle(duration = 500, timeout = 20000)}\if{html}{\out{
    }} +} + +\subsection{Arguments}{ +\if{html}{\out{
    }} +\describe{ +\item{\code{duration, timeout}}{(\code{numeric(1)}) passed to parent \code{\link{AppDriver}} \code{waif_for_idle()} method.} +} +\if{html}{\out{
    }} +} +} +\if{html}{\out{
    }} \if{html}{\out{}} \if{latex}{\out{\hypertarget{method-TealAppDriver-expect_no_shiny_error}{}}} \subsection{Method \code{expect_no_shiny_error()}}{ diff --git a/man/reporter_previewer_module.Rd b/man/reporter_previewer_module.Rd index e54418141d..1aa7bb0784 100644 --- a/man/reporter_previewer_module.Rd +++ b/man/reporter_previewer_module.Rd @@ -11,7 +11,7 @@ reporter_previewer_module(label = "Report previewer", server_args = list()) For \code{modules()} defaults to \code{"root"}. See \code{Details}.} \item{server_args}{(named \code{list}) -Arguments passed to \code{\link[teal.reporter:reporter_previewer]{teal.reporter::reporter_previewer_srv()}}.} +Arguments passed to \code{\link[teal.reporter:reporter_previewer_srv]{teal.reporter::reporter_previewer_srv()}}.} } \value{ \code{teal_module} (extended with \code{teal_module_previewer} class) containing the \code{teal.reporter} previewer functionality. @@ -19,8 +19,8 @@ Arguments passed to \code{\link[teal.reporter:reporter_previewer]{teal.reporter: \description{ \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#experimental}{\figure{lifecycle-experimental.svg}{options: alt='[Experimental]'}}}{\strong{[Experimental]}} -This function wraps \code{\link[teal.reporter:reporter_previewer]{teal.reporter::reporter_previewer_ui()}} and -\code{\link[teal.reporter:reporter_previewer]{teal.reporter::reporter_previewer_srv()}} into a \code{teal_module} to be +This function wraps \code{\link[teal.reporter:reporter_previewer_ui]{teal.reporter::reporter_previewer_ui()}} and +\code{\link[teal.reporter:reporter_previewer_srv]{teal.reporter::reporter_previewer_srv()}} into a \code{teal_module} to be used in \code{teal} applications. If you are creating a \code{teal} application using \code{\link[=init]{init()}} then this diff --git a/tests/testthat/helper-shinytest2.R b/tests/testthat/helper-shinytest2.R index bf90d956f8..5cea797f81 100644 --- a/tests/testthat/helper-shinytest2.R +++ b/tests/testthat/helper-shinytest2.R @@ -1,7 +1,7 @@ library(shinytest2) library(rvest) -default_idle_timeout <- 20000 +default_idle_timeout <- 2000 simple_teal_data <- function() { data <- within(teal_data(), { diff --git a/tests/testthat/test-shinytest2-filter_panel.R b/tests/testthat/test-shinytest2-filter_panel.R index e2c07884df..d2ab5aa488 100644 --- a/tests/testthat/test-shinytest2-filter_panel.R +++ b/tests/testthat/test-shinytest2-filter_panel.R @@ -14,8 +14,6 @@ testthat::test_that("e2e: module content is updated when a data is filtered in f ) ) - app$wait_for_idle(timeout = default_idle_timeout) - old_output <- app$get_active_module_output("text") app$set_active_filter_selection("iris", "Species", c("setosa", "versicolor")) @@ -47,8 +45,6 @@ testthat::test_that("e2e: filtering a module-specific filter is refected in othe ) ) - app$wait_for_idle(timeout = default_idle_timeout) - expect_equal( app$get_active_filter_selection("iris", "Species"), c("setosa", "versicolor", "virginica") @@ -90,8 +86,6 @@ testthat::test_that("e2e: filtering a module-specific filter is not refected in ) ) - app$wait_for_idle(timeout = default_idle_timeout) - expect_equal( app$get_active_filter_selection("mtcars", "cyl"), c("4", "6") diff --git a/tests/testthat/test-shinytest2-init.R b/tests/testthat/test-shinytest2-init.R index c070d7b539..062110d6fa 100644 --- a/tests/testthat/test-shinytest2-init.R +++ b/tests/testthat/test-shinytest2-init.R @@ -4,7 +4,6 @@ testthat::test_that("e2e: teal app initializes with no errors", { data = simple_teal_data(), modules = example_module(label = "Example Module") ) - app$wait_for_idle(timeout = default_idle_timeout) app$expect_no_shiny_error() app$stop() }) @@ -15,7 +14,6 @@ testthat::test_that("e2e: teal app initializes with sessionInfo modal", { data = simple_teal_data(), modules = example_module(label = "Example Module") ) - app$wait_for_idle(timeout = default_idle_timeout) # Check if button exists. button_selector <- "#teal-sessionInfo-button" @@ -82,7 +80,6 @@ testthat::test_that("e2e: init creates UI containing specified title, favicon, h header = app_header, footer = app_footer ) - app$wait_for_idle(timeout = default_idle_timeout) testthat::expect_equal( app$get_text("head > title")[1], diff --git a/tests/testthat/test-shinytest2-landing_popup.R b/tests/testthat/test-shinytest2-landing_popup.R index c1d3826dbc..826bfa2c86 100644 --- a/tests/testthat/test-shinytest2-landing_popup.R +++ b/tests/testthat/test-shinytest2-landing_popup.R @@ -11,7 +11,6 @@ testthat::test_that("e2e: teal app with landing_popup_module initializes with no ) ) - app$wait_for_idle(timeout = default_idle_timeout) testthat::expect_equal( app$get_text("#landingpopup b"), "A welcome message!" @@ -28,7 +27,6 @@ testthat::test_that("e2e: app with default landing_popup_module creates modal co example_module() ) ) - app$wait_for_idle(timeout = default_idle_timeout) testthat::expect_equal( app$get_text("#shiny-modal-wrapper button"), @@ -47,7 +45,6 @@ testthat::test_that("e2e: when default landing_popup_module is closed, it shows example_module() ) ) - app$wait_for_idle(timeout = default_idle_timeout) # Button is clicked. app$click(selector = "#shiny-modal-wrapper button[data-dismiss='modal']") @@ -104,8 +101,6 @@ testthat::test_that( ) ) - app$wait_for_idle(timeout = default_idle_timeout) - testthat::expect_equal( app$get_text(".modal-title"), modal_title @@ -157,7 +152,6 @@ testthat::test_that("e2e: when customized button in landing_popup_module is clic example_module() ) ) - app$wait_for_idle(timeout = default_idle_timeout) testthat::expect_equal( app$get_attr("#read", "onclick"), diff --git a/tests/testthat/test-shinytest2-modules.R b/tests/testthat/test-shinytest2-modules.R index e547fdd397..536f09f2b9 100644 --- a/tests/testthat/test-shinytest2-modules.R +++ b/tests/testthat/test-shinytest2-modules.R @@ -24,7 +24,7 @@ testthat::test_that("e2e: the module server logic is only triggered when the tea value_export_module(label = "Module 2") ) ) - app$wait_for_idle(timeout = default_idle_timeout) + test_exports <- app$get_values()$export expect_equal(length(test_exports), 1) @@ -45,7 +45,6 @@ testthat::test_that("e2e: filter panel only shows the data supplied using datana example_module(label = "mtcars", datanames = "mtcars") ) ) - app$wait_for_idle(timeout = default_idle_timeout) testthat::expect_identical( app$get_active_filter_vars(), @@ -62,7 +61,6 @@ testthat::test_that("e2e: filter panel shows all the datasets when datanames is example_module(label = "all", datanames = "all") ) ) - app$wait_for_idle(timeout = default_idle_timeout) testthat::expect_identical( app$get_active_filter_vars(), @@ -79,7 +77,6 @@ testthat::test_that("e2e: filter panel is not displayed when datanames is NULL", example_module(label = "NULL", datanames = NULL) ) ) - app$wait_for_idle(timeout = default_idle_timeout) testthat::expect_identical( app$get_html_rvest(".teal_secondary_col") %>% diff --git a/tests/testthat/test-shinytest2-reporter.R b/tests/testthat/test-shinytest2-reporter.R index 46ba6f9bc9..5ec577f567 100644 --- a/tests/testthat/test-shinytest2-reporter.R +++ b/tests/testthat/test-shinytest2-reporter.R @@ -46,7 +46,6 @@ testthat::test_that("e2e: adding a report card in a module adds it in the report data = simple_teal_data(), modules = report_module(label = "Module with Reporter") ) - app$wait_for_idle(timeout = default_idle_timeout) app$click(NS(app$active_module_ns(), "reporter-add_report_card_simple-add_report_card_button")) app$wait_for_idle(timeout = default_idle_timeout) diff --git a/tests/testthat/test-shinytest2-show-rcode.R b/tests/testthat/test-shinytest2-show-rcode.R index 09cc122080..296aae74b9 100644 --- a/tests/testthat/test-shinytest2-show-rcode.R +++ b/tests/testthat/test-shinytest2-show-rcode.R @@ -4,7 +4,6 @@ testthat::test_that("e2e: teal app initializes with Show R Code modal", { data = simple_teal_data(), modules = example_module(label = "Example Module") ) - app$wait_for_idle(timeout = default_idle_timeout) # Check if button exists. button_selector <- app$active_module_element("rcode-button") From ce94fbb728f6054daa9cda7e89c05408c61f5061 Mon Sep 17 00:00:00 2001 From: m7pr Date: Thu, 21 Mar 2024 13:35:27 +0100 Subject: [PATCH 02/12] remove all wait_for_idle after $click() method calls --- R/TealAppDriver.R | 7 +++++++ man/TealAppDriver.Rd | 19 ++++++++++++++++++- tests/testthat/test-shinytest2-init.R | 1 - .../testthat/test-shinytest2-landing_popup.R | 1 - tests/testthat/test-shinytest2-reporter.R | 1 - tests/testthat/test-shinytest2-show-rcode.R | 1 - .../test-shinytest2-teal_data_module.R | 5 +---- tests/testthat/test-shinytest2-teal_slices.R | 3 --- tests/testthat/test-shinytest2-utils.R | 1 - 9 files changed, 26 insertions(+), 13 deletions(-) diff --git a/R/TealAppDriver.R b/R/TealAppDriver.R index 2438140fd6..5dcae13a57 100644 --- a/R/TealAppDriver.R +++ b/R/TealAppDriver.R @@ -56,6 +56,13 @@ TealAppDriver <- R6::R6Class( # nolint: object_name. super$wait_for_idle(duration = duration, timeout = timeout) }, #' @description + #' Append parent [`AppDriver`] `click` method with a call to `waif_for_idle()` method. + #' @param ... arguments passed to parent [`AppDriver`] `click()` method. + click = function(...) { + super$click(...) + wait_for_idle() + }, + #' @description #' Check if the app has shiny errors. This checks for global shiny errors. #' Note that any shiny errors dependent on shiny server render will only be captured after the teal module tab #' is visited because shiny will not trigger server computations when the tab is invisible. diff --git a/man/TealAppDriver.Rd b/man/TealAppDriver.Rd index d65abe39a8..89914eeb6e 100644 --- a/man/TealAppDriver.Rd +++ b/man/TealAppDriver.Rd @@ -21,6 +21,7 @@ driving a teal application for performing interactions for \code{shinytest2} tes \itemize{ \item \href{#method-TealAppDriver-new}{\code{TealAppDriver$new()}} \item \href{#method-TealAppDriver-wait_for_idle}{\code{TealAppDriver$wait_for_idle()}} +\item \href{#method-TealAppDriver-click}{\code{TealAppDriver$click()}} \item \href{#method-TealAppDriver-expect_no_shiny_error}{\code{TealAppDriver$expect_no_shiny_error()}} \item \href{#method-TealAppDriver-expect_no_validation_error}{\code{TealAppDriver$expect_no_validation_error()}} \item \href{#method-TealAppDriver-expect_validation_error}{\code{TealAppDriver$expect_validation_error()}} @@ -48,7 +49,6 @@ driving a teal application for performing interactions for \code{shinytest2} tes \if{html}{\out{
    Inherited methods
      -
    • shinytest2::AppDriver$click()
    • shinytest2::AppDriver$expect_download()
    • shinytest2::AppDriver$expect_html()
    • shinytest2::AppDriver$expect_js()
    • @@ -129,6 +129,23 @@ Set custom values for \code{duration} and \code{timeout} in parent \code{\link{A } } \if{html}{\out{
      }} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-TealAppDriver-click}{}}} +\subsection{Method \code{click()}}{ +Append parent \code{\link{AppDriver}} \code{click} method with a call to \code{waif_for_idle()} method. +\subsection{Usage}{ +\if{html}{\out{
      }}\preformatted{TealAppDriver$click(...)}\if{html}{\out{
      }} +} + +\subsection{Arguments}{ +\if{html}{\out{
      }} +\describe{ +\item{\code{...}}{arguments passed to parent \code{\link{AppDriver}} \code{click()} method.} +} +\if{html}{\out{
      }} +} +} +\if{html}{\out{
      }} \if{html}{\out{}} \if{latex}{\out{\hypertarget{method-TealAppDriver-expect_no_shiny_error}{}}} \subsection{Method \code{expect_no_shiny_error()}}{ diff --git a/tests/testthat/test-shinytest2-init.R b/tests/testthat/test-shinytest2-init.R index 062110d6fa..9f57bfa904 100644 --- a/tests/testthat/test-shinytest2-init.R +++ b/tests/testthat/test-shinytest2-init.R @@ -23,7 +23,6 @@ testthat::test_that("e2e: teal app initializes with sessionInfo modal", { ) app$click(selector = button_selector) - app$wait_for_idle(timeout = default_idle_timeout) # Check header and title content. testthat::expect_equal( diff --git a/tests/testthat/test-shinytest2-landing_popup.R b/tests/testthat/test-shinytest2-landing_popup.R index 826bfa2c86..adaa82c19a 100644 --- a/tests/testthat/test-shinytest2-landing_popup.R +++ b/tests/testthat/test-shinytest2-landing_popup.R @@ -48,7 +48,6 @@ testthat::test_that("e2e: when default landing_popup_module is closed, it shows # Button is clicked. app$click(selector = "#shiny-modal-wrapper button[data-dismiss='modal']") - app$wait_for_idle(timeout = default_idle_timeout) # There is no more modal displayed. testthat::expect_null(app$get_html("#shiny-modal-wrapper")) diff --git a/tests/testthat/test-shinytest2-reporter.R b/tests/testthat/test-shinytest2-reporter.R index 5ec577f567..77b6b190d8 100644 --- a/tests/testthat/test-shinytest2-reporter.R +++ b/tests/testthat/test-shinytest2-reporter.R @@ -48,7 +48,6 @@ testthat::test_that("e2e: adding a report card in a module adds it in the report ) app$click(NS(app$active_module_ns(), "reporter-add_report_card_simple-add_report_card_button")) - app$wait_for_idle(timeout = default_idle_timeout) app$set_input( NS(app$active_module_ns(), "reporter-add_report_card_simple-label"), diff --git a/tests/testthat/test-shinytest2-show-rcode.R b/tests/testthat/test-shinytest2-show-rcode.R index 296aae74b9..383ed57b90 100644 --- a/tests/testthat/test-shinytest2-show-rcode.R +++ b/tests/testthat/test-shinytest2-show-rcode.R @@ -13,7 +13,6 @@ testthat::test_that("e2e: teal app initializes with Show R Code modal", { ) app$click(selector = button_selector) - app$wait_for_idle(timeout = default_idle_timeout) # Check header and title content. testthat::expect_equal( diff --git a/tests/testthat/test-shinytest2-teal_data_module.R b/tests/testthat/test-shinytest2-teal_data_module.R index 3c90248e0c..c050dc5ee4 100644 --- a/tests/testthat/test-shinytest2-teal_data_module.R +++ b/tests/testthat/test-shinytest2-teal_data_module.R @@ -30,7 +30,6 @@ testthat::test_that("e2e: teal_data_module will have a delayed load of datasets" ) app$click("teal_data_module-submit") - app$wait_for_idle() testthat::expect_setequal(app$get_active_filter_vars(), c("dataset1", "dataset2")) app$stop() @@ -65,7 +64,6 @@ testthat::test_that("e2e: teal_data_module shows validation errors", { modules = example_module(label = "Example Module"), timeout = default_idle_timeout ) - app$wait_for_idle() app$click("teal_data_module-submit") @@ -111,14 +109,13 @@ testthat::test_that("e2e: teal_data_module inputs change teal_data object that i modules = example_module(label = "Example Module"), timeout = default_idle_timeout ) - app$wait_for_idle() + app$set_input("teal_data_module-new_column", "A_New_Column") app$click("teal_data_module-submit") # This may fail if teal_data_module does not perform the transformation testthat::expect_no_error(app$add_filter_var("dataset1", "A_New_Column")) - app$wait_for_idle() testthat::expect_setequal( app$get_active_filter_selection("dataset1", "A_New_Column"), unique(sprintf("%s new", iris$Species)) diff --git a/tests/testthat/test-shinytest2-teal_slices.R b/tests/testthat/test-shinytest2-teal_slices.R index 119bd7526a..0ff0bee8ed 100644 --- a/tests/testthat/test-shinytest2-teal_slices.R +++ b/tests/testthat/test-shinytest2-teal_slices.R @@ -14,8 +14,6 @@ testthat::test_that("e2e: teal_slices filters are initialized when global filter ) ) - app$wait_for_idle(timeout = default_idle_timeout) - testthat::expect_identical( names(app$get_active_data_filters("iris")), "Species" @@ -63,7 +61,6 @@ testthat::test_that("e2e: teal_slices filters are initialized when module specif ) ) ) - app$wait_for_idle(timeout = default_idle_timeout) testthat::expect_identical( names(app$get_active_data_filters("iris")), diff --git a/tests/testthat/test-shinytest2-utils.R b/tests/testthat/test-shinytest2-utils.R index 20b3e9d0d3..30b0d2bef2 100644 --- a/tests/testthat/test-shinytest2-utils.R +++ b/tests/testthat/test-shinytest2-utils.R @@ -21,7 +21,6 @@ testthat::test_that("e2e: show/hide hamburger works as expected", { testthat::expect_false(isTruthy(secondary_attrs$style)) app$click(selector = ".btn.action-button.filter_hamburger") - app$wait_for_idle(timeout = default_idle_timeout) primary_attrs <- get_class_attributes(app, ".teal_primary_col") secondary_attrs <- get_class_attributes(app, ".teal_secondary_col") From ae7638e10e9f81b1d9b8a3eedc82728dbbc3bfbc Mon Sep 17 00:00:00 2001 From: m7pr Date: Thu, 21 Mar 2024 13:37:21 +0100 Subject: [PATCH 03/12] remove wait_for_idle after $navigate_teal_tab metho calls --- tests/testthat/test-shinytest2-filter_panel.R | 4 ---- tests/testthat/test-shinytest2-teal_slices.R | 1 - 2 files changed, 5 deletions(-) diff --git a/tests/testthat/test-shinytest2-filter_panel.R b/tests/testthat/test-shinytest2-filter_panel.R index d2ab5aa488..31e9a0537d 100644 --- a/tests/testthat/test-shinytest2-filter_panel.R +++ b/tests/testthat/test-shinytest2-filter_panel.R @@ -51,12 +51,10 @@ testthat::test_that("e2e: filtering a module-specific filter is refected in othe ) app$navigate_teal_tab("Module_2") - app$wait_for_idle(timeout = default_idle_timeout) app$set_active_filter_selection("iris", "Species", c("setosa")) app$navigate_teal_tab("Module_1") - app$wait_for_idle(timeout = default_idle_timeout) expect_equal( app$get_active_filter_selection("iris", "Species"), @@ -92,12 +90,10 @@ testthat::test_that("e2e: filtering a module-specific filter is not refected in ) app$navigate_teal_tab("Module_2") - app$wait_for_idle(timeout = default_idle_timeout) app$set_active_filter_selection("mtcars", "cyl", c("4")) app$navigate_teal_tab("Module_1") - app$wait_for_idle(timeout = default_idle_timeout) expect_equal( app$get_active_filter_selection("mtcars", "cyl"), diff --git a/tests/testthat/test-shinytest2-teal_slices.R b/tests/testthat/test-shinytest2-teal_slices.R index 0ff0bee8ed..3797590074 100644 --- a/tests/testthat/test-shinytest2-teal_slices.R +++ b/tests/testthat/test-shinytest2-teal_slices.R @@ -83,7 +83,6 @@ testthat::test_that("e2e: teal_slices filters are initialized when module specif testthat::expect_null(app$get_active_data_filters("mtcars")$gear) app$navigate_teal_tab("Module_2") - app$wait_for_idle(timeout = default_idle_timeout) testthat::expect_identical( names(app$get_active_data_filters("iris")), From 775c89b3c6a11ee607b4957a9ad55a61612ca7ea Mon Sep 17 00:00:00 2001 From: "27856297+dependabot-preview[bot]@users.noreply.github.com" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Thu, 21 Mar 2024 12:44:26 +0000 Subject: [PATCH 04/12] [skip roxygen] [skip vbump] Roxygen Man Pages Auto Update --- man/reporter_previewer_module.Rd | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/man/reporter_previewer_module.Rd b/man/reporter_previewer_module.Rd index 1aa7bb0784..e54418141d 100644 --- a/man/reporter_previewer_module.Rd +++ b/man/reporter_previewer_module.Rd @@ -11,7 +11,7 @@ reporter_previewer_module(label = "Report previewer", server_args = list()) For \code{modules()} defaults to \code{"root"}. See \code{Details}.} \item{server_args}{(named \code{list}) -Arguments passed to \code{\link[teal.reporter:reporter_previewer_srv]{teal.reporter::reporter_previewer_srv()}}.} +Arguments passed to \code{\link[teal.reporter:reporter_previewer]{teal.reporter::reporter_previewer_srv()}}.} } \value{ \code{teal_module} (extended with \code{teal_module_previewer} class) containing the \code{teal.reporter} previewer functionality. @@ -19,8 +19,8 @@ Arguments passed to \code{\link[teal.reporter:reporter_previewer_srv]{teal.repor \description{ \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#experimental}{\figure{lifecycle-experimental.svg}{options: alt='[Experimental]'}}}{\strong{[Experimental]}} -This function wraps \code{\link[teal.reporter:reporter_previewer_ui]{teal.reporter::reporter_previewer_ui()}} and -\code{\link[teal.reporter:reporter_previewer_srv]{teal.reporter::reporter_previewer_srv()}} into a \code{teal_module} to be +This function wraps \code{\link[teal.reporter:reporter_previewer]{teal.reporter::reporter_previewer_ui()}} and +\code{\link[teal.reporter:reporter_previewer]{teal.reporter::reporter_previewer_srv()}} into a \code{teal_module} to be used in \code{teal} applications. If you are creating a \code{teal} application using \code{\link[=init]{init()}} then this From 8ea8f5c28db7b5042cac9507a1ef8067d539d18e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Ver=C3=ADssimo?= <211358+averissimo@users.noreply.github.com> Date: Mon, 25 Mar 2024 15:10:43 +0100 Subject: [PATCH 05/12] Update R/TealAppDriver.R MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: André Veríssimo <211358+averissimo@users.noreply.github.com> --- R/TealAppDriver.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/TealAppDriver.R b/R/TealAppDriver.R index 5dcae13a57..69a15f6b40 100644 --- a/R/TealAppDriver.R +++ b/R/TealAppDriver.R @@ -60,7 +60,7 @@ TealAppDriver <- R6::R6Class( # nolint: object_name. #' @param ... arguments passed to parent [`AppDriver`] `click()` method. click = function(...) { super$click(...) - wait_for_idle() + self$wait_for_idle() }, #' @description #' Check if the app has shiny errors. This checks for global shiny errors. From b5ea9572f08bcaead0b046f1fe2f1280945aab6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Ver=C3=ADssimo?= <211358+averissimo@users.noreply.github.com> Date: Wed, 27 Mar 2024 11:14:13 +0100 Subject: [PATCH 06/12] feat: change internal timeout value for 20s --- R/TealAppDriver.R | 37 +++++++++++-------- man/TealAppDriver.Rd | 23 ++---------- tests/testthat/helper-shinytest2.R | 2 - .../test-shinytest2-teal_data_module.R | 9 ++--- 4 files changed, 27 insertions(+), 44 deletions(-) diff --git a/R/TealAppDriver.R b/R/TealAppDriver.R index 69a15f6b40..cde349f57b 100644 --- a/R/TealAppDriver.R +++ b/R/TealAppDriver.R @@ -37,12 +37,24 @@ TealAppDriver <- R6::R6Class( # nolint: object_name. header = header, footer = footer ) + + dots <- rlang::list2(...) + # Default timeout is hardcoded to 4s in shinytest2:::resolve_timeout + # It must be set as parameter to the driver if no + if (is.null(dots$timeout)) dots$timeout <- 20 * 1000 + if (is.null(dots$load_timeout)) dots$load_timeout <- 100 * 1000 + suppressWarnings( - super$initialize( - shinyApp(app$ui, app$server), - name = "teal", - variant = platform_variant(), - ... + do.call( + super$initialize, + modifyList( + dots, + list( + app_dir = shinyApp(app$ui, app$server), + name = "teal", + variant = platform_variant() + ) + ) ) ) @@ -50,14 +62,8 @@ TealAppDriver <- R6::R6Class( # nolint: object_name. self$wait_for_idle() }, #' @description - #' Set custom values for `duration` and `timeout` in parent [`AppDriver`] `waif_for_idle()` method. - #' @param duration,timeout (`numeric(1)`) passed to parent [`AppDriver`] `waif_for_idle()` method. - wait_for_idle = function(duration = 500, timeout = 20000) { - super$wait_for_idle(duration = duration, timeout = timeout) - }, - #' @description - #' Append parent [`AppDriver`] `click` method with a call to `waif_for_idle()` method. - #' @param ... arguments passed to parent [`AppDriver`] `click()` method. + #' Append parent [`shinytest2::AppDriver`] `click` method with a call to `waif_for_idle()` method. + #' @param ... arguments passed to parent [`shinytest2::AppDriver`] `click()` method. click = function(...) { super$click(...) self$wait_for_idle() @@ -126,7 +132,7 @@ TealAppDriver <- R6::R6Class( # nolint: object_name. ) root <- sprintf("%s-%s", private$modules$label, get_unique_labels(tab)) } - self$wait_for_idle(timeout = private$idle_timeout) + self$wait_for_idle() private$set_active_ns() invisible(self) }, @@ -433,8 +439,7 @@ TealAppDriver <- R6::R6Class( # nolint: object_name. module = character(0), filter_panel = character(0) ), - idle_timeout = 20000, # 20 seconds - load_timeout = 100000, # 100 seconds + load_timeout = NULL, # private methods ---- set_active_ns = function() { all_inputs <- self$get_values()$input diff --git a/man/TealAppDriver.Rd b/man/TealAppDriver.Rd index 89914eeb6e..4ac4688bd2 100644 --- a/man/TealAppDriver.Rd +++ b/man/TealAppDriver.Rd @@ -20,7 +20,6 @@ driving a teal application for performing interactions for \code{shinytest2} tes \subsection{Public methods}{ \itemize{ \item \href{#method-TealAppDriver-new}{\code{TealAppDriver$new()}} -\item \href{#method-TealAppDriver-wait_for_idle}{\code{TealAppDriver$wait_for_idle()}} \item \href{#method-TealAppDriver-click}{\code{TealAppDriver$click()}} \item \href{#method-TealAppDriver-expect_no_shiny_error}{\code{TealAppDriver$expect_no_shiny_error()}} \item \href{#method-TealAppDriver-expect_no_validation_error}{\code{TealAppDriver$expect_no_validation_error()}} @@ -76,6 +75,7 @@ driving a teal application for performing interactions for \code{shinytest2} tes
    • shinytest2::AppDriver$stop()
    • shinytest2::AppDriver$upload_file()
    • shinytest2::AppDriver$view()
    • +
    • shinytest2::AppDriver$wait_for_idle()
    • shinytest2::AppDriver$wait_for_js()
    • shinytest2::AppDriver$wait_for_value()
    @@ -112,27 +112,10 @@ Object of class \code{TealAppDriver} } } \if{html}{\out{
    }} -\if{html}{\out{}} -\if{latex}{\out{\hypertarget{method-TealAppDriver-wait_for_idle}{}}} -\subsection{Method \code{wait_for_idle()}}{ -Set custom values for \code{duration} and \code{timeout} in parent \code{\link{AppDriver}} \code{waif_for_idle()} method. -\subsection{Usage}{ -\if{html}{\out{
    }}\preformatted{TealAppDriver$wait_for_idle(duration = 500, timeout = 20000)}\if{html}{\out{
    }} -} - -\subsection{Arguments}{ -\if{html}{\out{
    }} -\describe{ -\item{\code{duration, timeout}}{(\code{numeric(1)}) passed to parent \code{\link{AppDriver}} \code{waif_for_idle()} method.} -} -\if{html}{\out{
    }} -} -} -\if{html}{\out{
    }} \if{html}{\out{}} \if{latex}{\out{\hypertarget{method-TealAppDriver-click}{}}} \subsection{Method \code{click()}}{ -Append parent \code{\link{AppDriver}} \code{click} method with a call to \code{waif_for_idle()} method. +Append parent \code{\link[shinytest2:AppDriver]{shinytest2::AppDriver}} \code{click} method with a call to \code{waif_for_idle()} method. \subsection{Usage}{ \if{html}{\out{
    }}\preformatted{TealAppDriver$click(...)}\if{html}{\out{
    }} } @@ -140,7 +123,7 @@ Append parent \code{\link{AppDriver}} \code{click} method with a call to \code{w \subsection{Arguments}{ \if{html}{\out{
    }} \describe{ -\item{\code{...}}{arguments passed to parent \code{\link{AppDriver}} \code{click()} method.} +\item{\code{...}}{arguments passed to parent \code{\link[shinytest2:AppDriver]{shinytest2::AppDriver}} \code{click()} method.} } \if{html}{\out{
    }} } diff --git a/tests/testthat/helper-shinytest2.R b/tests/testthat/helper-shinytest2.R index 5cea797f81..f5c298ac40 100644 --- a/tests/testthat/helper-shinytest2.R +++ b/tests/testthat/helper-shinytest2.R @@ -1,8 +1,6 @@ library(shinytest2) library(rvest) -default_idle_timeout <- 2000 - simple_teal_data <- function() { data <- within(teal_data(), { iris <- iris diff --git a/tests/testthat/test-shinytest2-teal_data_module.R b/tests/testthat/test-shinytest2-teal_data_module.R index 88514970cf..87025f1542 100644 --- a/tests/testthat/test-shinytest2-teal_data_module.R +++ b/tests/testthat/test-shinytest2-teal_data_module.R @@ -25,8 +25,7 @@ testthat::test_that("e2e: teal_data_module will have a delayed load of datasets" app <- TealAppDriver$new( data = tdm, - modules = example_module(label = "Example Module"), - timeout = default_idle_timeout + modules = example_module(label = "Example Module") ) app$click("teal_data_module-submit") @@ -61,8 +60,7 @@ testthat::test_that("e2e: teal_data_module shows validation errors", { app <- TealAppDriver$new( data = tdm, - modules = example_module(label = "Example Module"), - timeout = default_idle_timeout + modules = example_module(label = "Example Module") ) app$click("teal_data_module-submit") @@ -106,8 +104,7 @@ testthat::test_that("e2e: teal_data_module inputs change teal_data object that i app <- TealAppDriver$new( data = tdm, - modules = example_module(label = "Example Module"), - timeout = default_idle_timeout + modules = example_module(label = "Example Module") ) app$set_input("teal_data_module-new_column", "A_New_Column") From 14cc3934808fa2092b85ffacc1b25a62b64e0c61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Ver=C3=ADssimo?= <211358+averissimo@users.noreply.github.com> Date: Wed, 27 Mar 2024 12:03:15 +0100 Subject: [PATCH 07/12] docs: typo --- R/TealAppDriver.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/TealAppDriver.R b/R/TealAppDriver.R index cde349f57b..d23e6e2481 100644 --- a/R/TealAppDriver.R +++ b/R/TealAppDriver.R @@ -40,7 +40,7 @@ TealAppDriver <- R6::R6Class( # nolint: object_name. dots <- rlang::list2(...) # Default timeout is hardcoded to 4s in shinytest2:::resolve_timeout - # It must be set as parameter to the driver if no + # It must be set as parameter to the AppDriver if (is.null(dots$timeout)) dots$timeout <- 20 * 1000 if (is.null(dots$load_timeout)) dots$load_timeout <- 100 * 1000 From b8c08342066231f4c0a7a8b6eee75822b6200c00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Ver=C3=ADssimo?= <211358+averissimo@users.noreply.github.com> Date: Wed, 27 Mar 2024 12:08:48 +0100 Subject: [PATCH 08/12] fix: remove NULL initialization as variable exists upstream --- R/TealAppDriver.R | 1 - 1 file changed, 1 deletion(-) diff --git a/R/TealAppDriver.R b/R/TealAppDriver.R index d23e6e2481..7a737ebc0f 100644 --- a/R/TealAppDriver.R +++ b/R/TealAppDriver.R @@ -439,7 +439,6 @@ TealAppDriver <- R6::R6Class( # nolint: object_name. module = character(0), filter_panel = character(0) ), - load_timeout = NULL, # private methods ---- set_active_ns = function() { all_inputs <- self$get_values()$input From 52fda1b54513220dc147de01321b29a987e9ea14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Ver=C3=ADssimo?= <211358+averissimo@users.noreply.github.com> Date: Wed, 27 Mar 2024 12:15:32 +0100 Subject: [PATCH 09/12] docs: Add details on timeouts --- R/TealAppDriver.R | 4 ++++ man/TealAppDriver.Rd | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/R/TealAppDriver.R b/R/TealAppDriver.R index 7a737ebc0f..e764dc38ca 100644 --- a/R/TealAppDriver.R +++ b/R/TealAppDriver.R @@ -5,6 +5,10 @@ #' Extension of the `shinytest2::AppDriver` class with methods for #' driving a teal application for performing interactions for `shinytest2` tests. #' +#' Default timeout values are overridden to 20s and 100s for `timeout` and +#' `load_timeout` respectively. These can be further overridden by passing them as +#' arguments when initializing `TealAppDriver`. +#' #' @keywords internal #' TealAppDriver <- R6::R6Class( # nolint: object_name. diff --git a/man/TealAppDriver.Rd b/man/TealAppDriver.Rd index 4ac4688bd2..ae097cb2ec 100644 --- a/man/TealAppDriver.Rd +++ b/man/TealAppDriver.Rd @@ -11,6 +11,10 @@ Drive a \code{teal} application \details{ Extension of the \code{shinytest2::AppDriver} class with methods for driving a teal application for performing interactions for \code{shinytest2} tests. + +Default timeout values are overridden to 20s and 100s for \code{timeout} and +\code{load_timeout} respectively. These can be further overridden by passing them as +arguments when initializing \code{TealAppDriver}. } \keyword{internal} \section{Super class}{ From d6d59ae6212b2b36809e42ed4fd4f7695cbe072d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Ver=C3=ADssimo?= <211358+averissimo@users.noreply.github.com> Date: Wed, 27 Mar 2024 13:57:20 +0100 Subject: [PATCH 10/12] docs: explicit documentation for timeout parameters --- R/TealAppDriver.R | 37 +++++++++++++++++++------------------ man/TealAppDriver.Rd | 17 +++++++++++++---- 2 files changed, 32 insertions(+), 22 deletions(-) diff --git a/R/TealAppDriver.R b/R/TealAppDriver.R index e764dc38ca..a4a0bfdf74 100644 --- a/R/TealAppDriver.R +++ b/R/TealAppDriver.R @@ -5,10 +5,6 @@ #' Extension of the `shinytest2::AppDriver` class with methods for #' driving a teal application for performing interactions for `shinytest2` tests. #' -#' Default timeout values are overridden to 20s and 100s for `timeout` and -#' `load_timeout` respectively. These can be further overridden by passing them as -#' arguments when initializing `TealAppDriver`. -#' #' @keywords internal #' TealAppDriver <- R6::R6Class( # nolint: object_name. @@ -20,8 +16,18 @@ TealAppDriver <- R6::R6Class( # nolint: object_name. #' Initialize a `TealAppDriver` object for testing a `teal` application. #' #' @param data,modules,filter,title,header,footer arguments passed to `init` + #' @param timeout (`numeric`) Default number of milliseconds for any timeout or + #' timeout_ parameter in the `TealAppDriver` class. + #' Defaults to 20s. + #' + #' See [`shinytest2::AppDriver`] `new` method for more details. + #' @param load_timeout (`numeric`) How long to wait for the app to load, in ms. + #' This includes the time to start R. Defaults to 100s. + #' + #' See [`shinytest2::AppDriver`] `new` method for more details. #' @param ... Additional arguments to be passed to `shinytest2::AppDriver$new` #' + #' #' @return Object of class `TealAppDriver` initialize = function(data, modules, @@ -29,6 +35,8 @@ TealAppDriver <- R6::R6Class( # nolint: object_name. title = build_app_title(), header = tags$p(), footer = tags$p(), + timeout = rlang::missing_arg(), + load_timeout = rlant::missing_arg(), ...) { private$data <- data private$modules <- modules @@ -42,23 +50,16 @@ TealAppDriver <- R6::R6Class( # nolint: object_name. footer = footer ) - dots <- rlang::list2(...) # Default timeout is hardcoded to 4s in shinytest2:::resolve_timeout # It must be set as parameter to the AppDriver - if (is.null(dots$timeout)) dots$timeout <- 20 * 1000 - if (is.null(dots$load_timeout)) dots$load_timeout <- 100 * 1000 - suppressWarnings( - do.call( - super$initialize, - modifyList( - dots, - list( - app_dir = shinyApp(app$ui, app$server), - name = "teal", - variant = platform_variant() - ) - ) + super$initialize( + app_dir = shinyApp(app$ui, app$server), + name = "teal", + variant = platform_variant(), + timeout = rlang::maybe_missing(timeout, 20 * 1000), + load_timeout = rlang::maybe_missing(load_timeout, 100 * 1000), + ... ) ) diff --git a/man/TealAppDriver.Rd b/man/TealAppDriver.Rd index ae097cb2ec..0e1b46f8a6 100644 --- a/man/TealAppDriver.Rd +++ b/man/TealAppDriver.Rd @@ -11,10 +11,6 @@ Drive a \code{teal} application \details{ Extension of the \code{shinytest2::AppDriver} class with methods for driving a teal application for performing interactions for \code{shinytest2} tests. - -Default timeout values are overridden to 20s and 100s for \code{timeout} and -\code{load_timeout} respectively. These can be further overridden by passing them as -arguments when initializing \code{TealAppDriver}. } \keyword{internal} \section{Super class}{ @@ -98,6 +94,8 @@ Initialize a \code{TealAppDriver} object for testing a \code{teal} application. title = build_app_title(), header = tags$p(), footer = tags$p(), + timeout = rlang::missing_arg(), + load_timeout = rlant::missing_arg(), ... )}\if{html}{\out{}} } @@ -107,6 +105,17 @@ Initialize a \code{TealAppDriver} object for testing a \code{teal} application. \describe{ \item{\code{data, modules, filter, title, header, footer}}{arguments passed to \code{init}} +\item{\code{timeout}}{(\code{numeric}) Default number of milliseconds for any timeout or +timeout_ parameter in the \code{TealAppDriver} class. +Defaults to 20s. + +See \code{\link[shinytest2:AppDriver]{shinytest2::AppDriver}} \code{new} method for more details.} + +\item{\code{load_timeout}}{(\code{numeric}) How long to wait for the app to load, in ms. +This includes the time to start R. Defaults to 100s. + +See \code{\link[shinytest2:AppDriver]{shinytest2::AppDriver}} \code{new} method for more details.} + \item{\code{...}}{Additional arguments to be passed to \code{shinytest2::AppDriver$new}} } \if{html}{\out{}} From 9a4ff969b49cf906431af62d1e9f5123d84eed83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Ver=C3=ADssimo?= <211358+averissimo@users.noreply.github.com> Date: Wed, 27 Mar 2024 14:00:15 +0100 Subject: [PATCH 11/12] docs: small fix --- R/TealAppDriver.R | 6 ++++-- man/TealAppDriver.Rd | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/R/TealAppDriver.R b/R/TealAppDriver.R index a4a0bfdf74..c0439cfdc8 100644 --- a/R/TealAppDriver.R +++ b/R/TealAppDriver.R @@ -20,11 +20,13 @@ TealAppDriver <- R6::R6Class( # nolint: object_name. #' timeout_ parameter in the `TealAppDriver` class. #' Defaults to 20s. #' - #' See [`shinytest2::AppDriver`] `new` method for more details. + #' See [`shinytest2::AppDriver`] `new` method for more details on how to change it + #' via options or environment variables. #' @param load_timeout (`numeric`) How long to wait for the app to load, in ms. #' This includes the time to start R. Defaults to 100s. #' - #' See [`shinytest2::AppDriver`] `new` method for more details. + #' See [`shinytest2::AppDriver`] `new` method for more details on how to change it + #' via options or environment variables #' @param ... Additional arguments to be passed to `shinytest2::AppDriver$new` #' #' diff --git a/man/TealAppDriver.Rd b/man/TealAppDriver.Rd index 0e1b46f8a6..e68f699985 100644 --- a/man/TealAppDriver.Rd +++ b/man/TealAppDriver.Rd @@ -109,12 +109,14 @@ Initialize a \code{TealAppDriver} object for testing a \code{teal} application. timeout_ parameter in the \code{TealAppDriver} class. Defaults to 20s. -See \code{\link[shinytest2:AppDriver]{shinytest2::AppDriver}} \code{new} method for more details.} +See \code{\link[shinytest2:AppDriver]{shinytest2::AppDriver}} \code{new} method for more details on how to change it +via options or environment variables.} \item{\code{load_timeout}}{(\code{numeric}) How long to wait for the app to load, in ms. This includes the time to start R. Defaults to 100s. -See \code{\link[shinytest2:AppDriver]{shinytest2::AppDriver}} \code{new} method for more details.} +See \code{\link[shinytest2:AppDriver]{shinytest2::AppDriver}} \code{new} method for more details on how to change it +via options or environment variables} \item{\code{...}}{Additional arguments to be passed to \code{shinytest2::AppDriver$new}} } From 0d2d34a36a2f3fe66e38f2d32dda3ca19113e54c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Ver=C3=ADssimo?= <211358+averissimo@users.noreply.github.com> Date: Wed, 27 Mar 2024 15:34:22 +0100 Subject: [PATCH 12/12] fix: typo --- R/TealAppDriver.R | 2 +- man/TealAppDriver.Rd | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/R/TealAppDriver.R b/R/TealAppDriver.R index c0439cfdc8..6a1a3bd0cb 100644 --- a/R/TealAppDriver.R +++ b/R/TealAppDriver.R @@ -38,7 +38,7 @@ TealAppDriver <- R6::R6Class( # nolint: object_name. header = tags$p(), footer = tags$p(), timeout = rlang::missing_arg(), - load_timeout = rlant::missing_arg(), + load_timeout = rlang::missing_arg(), ...) { private$data <- data private$modules <- modules diff --git a/man/TealAppDriver.Rd b/man/TealAppDriver.Rd index e68f699985..d84dc7bdca 100644 --- a/man/TealAppDriver.Rd +++ b/man/TealAppDriver.Rd @@ -95,7 +95,7 @@ Initialize a \code{TealAppDriver} object for testing a \code{teal} application. header = tags$p(), footer = tags$p(), timeout = rlang::missing_arg(), - load_timeout = rlant::missing_arg(), + load_timeout = rlang::missing_arg(), ... )}\if{html}{\out{}} }