Skip to content

Commit

Permalink
Merge branch 'main' into 712-tm_g_bivariate@main
Browse files Browse the repository at this point in the history
  • Loading branch information
averissimo authored Apr 19, 2024
2 parents fc3f9c8 + 54b1f18 commit 90ab7ed
Show file tree
Hide file tree
Showing 5 changed files with 105 additions and 4 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Type: Package
Package: teal.modules.general
Title: General Modules for 'teal' Applications
Version: 0.3.0.9016
Version: 0.3.0.9017
Date: 2024-04-19
Authors@R: c(
person("Dawid", "Kaledkowski", , "dawid.kaledkowski@roche.com", role = c("aut", "cre")),
Expand Down
2 changes: 1 addition & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# teal.modules.general 0.3.0.9016
# teal.modules.general 0.3.0.9017

# teal.modules.general 0.3.0

Expand Down
2 changes: 1 addition & 1 deletion R/tm_data_table.R
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
#' variables_selected = list(
#' iris = c("Sepal.Length", "Sepal.Width", "Petal.Length", "Petal.Width", "Species")
#' ),
#' dt_args = list(caption = "ADSL Table Caption")
#' dt_args = list(caption = "IRIS Table Caption")
#' )
#' )
#' )
Expand Down
2 changes: 1 addition & 1 deletion man/tm_data_table.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

101 changes: 101 additions & 0 deletions tests/testthat/test-shinytest2-tm_data_table.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
app_driver_tm_data_table <- function() {
init_teal_app_driver(
data = simple_teal_data(),
modules = tm_data_table(
label = "Data Table",
variables_selected = list(
iris = c("Sepal.Length", "Sepal.Width", "Petal.Length", "Petal.Width", "Species")
),
datasets_selected = c("iris", "mtcars"),
dt_args = list(caption = "Table Caption"),
dt_options = list(
searching = FALSE, pageLength = 30, lengthMenu = c(5, 15, 30, 100),
scrollX = TRUE
),
server_rendering = FALSE,
pre_output = NULL,
post_output = NULL
),
timeout = 3000
)
}

test_that("e2e - tm_data_table: Initializes without errors", {
skip_if_too_deep(5)
app_driver <- app_driver_tm_data_table()

app_driver$expect_no_shiny_error()

testthat::expect_equal(
app_driver$get_text("#teal-main_ui-root-active_tab > li.active > a"),
"Data Table"
)

app_driver$stop()
})

test_that("e2e - tm_data_table: Verify checkbox displayed over data table", {
skip_if_too_deep(5)
app_driver <- app_driver_tm_data_table()

testthat::expect_false(app_driver$get_active_module_input("if_distinct"))

app_driver$stop()
})

test_that("e2e - tm_data_table: Verify module displays data table", {
skip_if_too_deep(5)
app_driver <- app_driver_tm_data_table()

# table
testthat::expect_match(app_driver$get_active_module_output("iris-data_table"), "Table Caption")
testthat::expect_true(app_driver$is_visible(selector = app_driver$active_module_element("iris-data_table")))

extract_iris_table <- function() {
app_driver$active_module_element("iris-data_table") %>%
app_driver$get_html_rvest() %>%
rvest::html_table(fill = TRUE) %>%
.[[2]] %>%
dplyr::select(-1) %>%
data.frame()
}
# Non-distinct version.
iris_extracted <- extract_iris_table()
iris_subset <- iris %>%
dplyr::mutate(Species = as.character(Species)) %>%
dplyr::slice(1:30)
testthat::expect_equal(iris_extracted, iris_subset)

# Distinct version.
app_driver$set_active_module_input("if_distinct", TRUE)
iris_extracted_distinct <- extract_iris_table()
iris_subset_distinct <- iris %>%
dplyr::mutate(n = 1) %>%
dplyr::arrange(dplyr::across(dplyr::everything())) %>%
dplyr::mutate(Species = as.character(Species)) %>%
dplyr::slice(1:30)
testthat::expect_equal(iris_extracted_distinct, iris_subset_distinct)

app_driver$stop()
})

test_that("e2e - tm_data_table: Verify default variable selection and set new selection", {
skip_if_too_deep(5)
app_driver <- app_driver_tm_data_table()

# default variable selection
testthat::expect_equal(
app_driver$get_active_module_input("iris-variables"),
c("Sepal.Length", "Sepal.Width", "Petal.Length", "Petal.Width", "Species")
)

# new variable selection
app_driver$set_active_module_input("iris-variables", c("Petal.Width", "Species"))
app_driver$expect_no_validation_error()
testthat::expect_equal(
app_driver$get_active_module_input("iris-variables"),
c("Petal.Width", "Species")
)

app_driver$stop()
})

0 comments on commit 90ab7ed

Please sign in to comment.