Skip to content

Commit

Permalink
Merge branch 'main' into 712-tm_a_regression@main
Browse files Browse the repository at this point in the history
  • Loading branch information
m7pr authored Apr 18, 2024
2 parents da785b9 + 37bd8d2 commit 024ef4f
Show file tree
Hide file tree
Showing 3 changed files with 113 additions and 2 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.9009
Version: 0.3.0.9010
Date: 2024-04-18
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.9009
# teal.modules.general 0.3.0.9010

# teal.modules.general 0.3.0

Expand Down
111 changes: 111 additions & 0 deletions tests/testthat/test-shinytest2-tm_g_association.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
app_driver_tm_g_association <- function() {
data <- within(teal.data::teal_data(), {
require(nestcolor)
require(ggplot2)
CO2 <- CO2 # nolint: object_name.
factors <- names(Filter(isTRUE, vapply(CO2, is.factor, logical(1L))))
CO2[factors] <- lapply(CO2[factors], as.character) # nolint: object_name.
})
teal.data::datanames(data) <- c("CO2")

init_teal_app_driver(
data = data,
modules = tm_g_association(
label = "Association",
ref = teal.transform::data_extract_spec(
dataname = "CO2",
select = teal.transform::select_spec(
label = "Select variable:",
choices = teal.transform::variable_choices(data[["CO2"]], c("Plant", "Type", "Treatment")),
selected = "Plant",
fixed = FALSE
)
),
vars = teal.transform::data_extract_spec(
dataname = "CO2",
select = teal.transform::select_spec(
label = "Select variables:",
choices = teal.transform::variable_choices(data[["CO2"]], c("Plant", "Type", "Treatment")),
selected = "Treatment",
multiple = TRUE,
fixed = FALSE
)
),
show_association = TRUE,
plot_height = c(600, 400, 5000),
plot_width = NULL,
distribution_theme = c("gray", "bw", "linedraw", "light", "dark", "minimal", "classic", "void"),
association_theme = c("gray", "bw", "linedraw", "light", "dark", "minimal", "classic", "void"),
pre_output = NULL,
post_output = NULL,
ggplot2_args = teal.widgets::ggplot2_args(
labs = list(subtitle = "Plot generated by Association Module")
)
)
)
}

testthat::test_that("e2e - tm_g_association: data parameter and module label is passed properly", {
skip_if_too_deep(5)

app_driver <- app_driver_tm_g_association()
app_driver$expect_no_shiny_error()

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

encoding_dataset <- app_driver$get_text("#teal-main_ui-root-association .help-block")
testthat::expect_match(encoding_dataset, "Dataset:[\n ]*CO2", all = FALSE)

app_driver$stop()
})

testthat::test_that("e2e - tm_g_association:
data extract spec elements are initialized with the default values specified by ref and vars arguments", {
skip_if_too_deep(5)
app_driver <- app_driver_tm_g_association()

testthat::expect_identical(
app_driver$get_active_module_input("ref-dataset_CO2_singleextract-select"),
"Plant"
)
app_driver$set_active_module_input("ref-dataset_CO2_singleextract-select", "Type")
app_driver$expect_no_validation_error()

testthat::expect_identical(
app_driver$get_active_module_input("vars-dataset_CO2_singleextract-select"),
"Treatment"
)
app_driver$set_active_module_input("vars-dataset_CO2_singleextract-select", "Plant")
app_driver$expect_no_validation_error()

app_driver$stop()
})
testthat::test_that("e2e - tm_g_association: module plot is visible", {
skip_if_too_deep(5)
app_driver <- app_driver_tm_g_association()

testthat::expect_true(app_driver$is_visible(app_driver$active_module_element("myplot-plot_main > img")))

app_driver$stop()
})


testthat::test_that("e2e - tm_g_association: test if default radio buttons are checked", {
skip_if_too_deep(5)
app_driver <- app_driver_tm_g_association()

testthat::expect_true(app_driver$get_active_module_input("association"))
testthat::expect_false(app_driver$get_active_module_input("show_dist"))
testthat::expect_false(app_driver$get_active_module_input("log_transformation"))

app_driver$set_active_module_input("association", FALSE)
app_driver$set_active_module_input("show_dist", TRUE)
app_driver$set_active_module_input("log_transformation", TRUE)
app_driver$expect_no_validation_error()
app_driver$expect_no_shiny_error()

app_driver$stop()
})

0 comments on commit 024ef4f

Please sign in to comment.