-
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Part of #712 ~~- [ ] testing table caption (DT functionality)~~ - [x] testing table - [x] variable selected --------- Signed-off-by: kartikeya kirar <kirar.kartikeya1@gmail.com> Signed-off-by: Marcin <133694481+m7pr@users.noreply.github.com> Co-authored-by: 27856297+dependabot-preview[bot]@users.noreply.github.com <27856297+dependabot-preview[bot]@users.noreply.github.com> Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Marcin <133694481+m7pr@users.noreply.github.com> Co-authored-by: André Veríssimo <211358+averissimo@users.noreply.github.com> Co-authored-by: m7pr <marcin.kosinski.mk1@roche.com>
- Loading branch information
1 parent
c904c4a
commit 7857ad6
Showing
3 changed files
with
103 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | ||
}) |