Skip to content

Commit

Permalink
keep shinytest2 and rvest as a soft dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
pawelru committed Jul 4, 2024
1 parent 28ee3c6 commit 6ac7aea
Show file tree
Hide file tree
Showing 14 changed files with 43 additions and 5 deletions.
10 changes: 9 additions & 1 deletion R/TealAppDriver.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,15 @@
#'
TealAppDriver <- R6::R6Class( # nolint: object_name.
"TealAppDriver",
inherit = shinytest2::AppDriver,
inherit = {
if (!requireNamespace("shinytest2", quietly = TRUE)) {
stop("Please install 'shinytest2' package to use this class.")
}
if (!requireNamespace("rvest", quietly = TRUE)) {
stop("Please install 'rvest' package to use this class.")
}
shinytest2::AppDriver
},
# public methods ----
public = list(
#' @description
Expand Down
2 changes: 1 addition & 1 deletion R/validate_inputs.R
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#'
#' @seealso [`shinyvalidate::InputValidator`], [`shiny::validate`]
#'
#' @examples
#' @examplesIf require("shinyvalidate")
#' library(shiny)
#' library(shinyvalidate)
#'
Expand Down
3 changes: 0 additions & 3 deletions tests/testthat/helper-shinytest2.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
library(shinytest2)
library(rvest)

simple_teal_data <- function() {
data <- within(teal_data(), {
iris <- iris
Expand Down
3 changes: 3 additions & 0 deletions tests/testthat/test-shinytest2-filter_panel.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
testthat::skip_if_not_installed("shinytest2")
testthat::skip_if_not_installed("rvest")

testthat::test_that("e2e: module content is updated when a data is filtered in filter panel", {
skip_if_too_deep(5)
app <- TealAppDriver$new(
Expand Down
3 changes: 3 additions & 0 deletions tests/testthat/test-shinytest2-init.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
testthat::skip_if_not_installed("shinytest2")
testthat::skip_if_not_installed("rvest")

testthat::test_that("e2e: teal app initializes with no errors", {
skip_if_too_deep(5)
app <- TealAppDriver$new(
Expand Down
3 changes: 3 additions & 0 deletions tests/testthat/test-shinytest2-landing_popup.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
testthat::skip_if_not_installed("shinytest2")
testthat::skip_if_not_installed("rvest")

testthat::test_that("e2e: teal app with landing_popup_module initializes with no errors", {
skip_if_too_deep(5)
app <- TealAppDriver$new(
Expand Down
3 changes: 3 additions & 0 deletions tests/testthat/test-shinytest2-module_bookmark_manager.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
testthat::skip_if_not_installed("shinytest2")
testthat::skip_if_not_installed("rvest")

testthat::test_that("bookmark_manager_button is not rendered by default", {
skip_if_too_deep(5)
app <- TealAppDriver$new(
Expand Down
3 changes: 3 additions & 0 deletions tests/testthat/test-shinytest2-modules.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
testthat::skip_if_not_installed("shinytest2")
testthat::skip_if_not_installed("rvest")

testthat::test_that("e2e: the module server logic is only triggered when the teal module becomes active", {
skip_if_too_deep(5)
value_export_module <- function(label = "custom module") {
Expand Down
3 changes: 3 additions & 0 deletions tests/testthat/test-shinytest2-reporter.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
testthat::skip_if_not_installed("shinytest2")
testthat::skip_if_not_installed("rvest")

testthat::test_that("e2e: reporter tab is created when a module has reporter", {
skip_if_too_deep(5)
app <- TealAppDriver$new(
Expand Down
3 changes: 3 additions & 0 deletions tests/testthat/test-shinytest2-show-rcode.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
testthat::skip_if_not_installed("shinytest2")
testthat::skip_if_not_installed("rvest")

testthat::test_that("e2e: teal app initializes with Show R Code modal", {
skip_if_too_deep(5)
app <- TealAppDriver$new(
Expand Down
3 changes: 3 additions & 0 deletions tests/testthat/test-shinytest2-teal_data_module.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
testthat::skip_if_not_installed("shinytest2")
testthat::skip_if_not_installed("rvest")

testthat::test_that("e2e: teal_data_module will have a delayed load of datasets", {
skip_if_too_deep(5)
tdm <- teal_data_module(
Expand Down
3 changes: 3 additions & 0 deletions tests/testthat/test-shinytest2-teal_slices.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
testthat::skip_if_not_installed("shinytest2")
testthat::skip_if_not_installed("rvest")

testthat::test_that("e2e: teal_slices filters are initialized when global filters are created", {
skip_if_too_deep(5)
app <- TealAppDriver$new(
Expand Down
3 changes: 3 additions & 0 deletions tests/testthat/test-shinytest2-utils.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
testthat::skip_if_not_installed("shinytest2")
testthat::skip_if_not_installed("rvest")

testthat::test_that("e2e: show/hide hamburger works as expected", {
skip_if_too_deep(5)
app <- TealAppDriver$new(
Expand Down
3 changes: 3 additions & 0 deletions tests/testthat/test-shinytest2-wunder_bar.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
testthat::skip_if_not_installed("shinytest2")
testthat::skip_if_not_installed("rvest")

testthat::test_that("wunder_bar_srv clicking filter icon opens filter-manager modal", {
skip_if_too_deep(5)
app <- TealAppDriver$new(
Expand Down

0 comments on commit 6ac7aea

Please sign in to comment.