Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion R/tm_a_mmrm.R
Original file line number Diff line number Diff line change
Expand Up @@ -1553,6 +1553,5 @@ srv_mmrm <- function(id,
set_chunk_dims(pws, reactive({
decorated_objs_q[[obj_ix_r()]]()
}))

})
}
56 changes: 29 additions & 27 deletions tests/testthat/test-shinytest2-tm_a_gee.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,27 @@ app_driver_tm_a_gee <- function() {
teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[names(data)]

init_teal_app_driver(
data = data,
modules = tm_a_gee(
label = "GEE",
dataname = "ADQS",
parentname = "ADSL",
aval_var = teal.transform::choices_selected("AVALBIN", fixed = TRUE),
id_var = teal.transform::choices_selected(c("USUBJID", "SUBJID"), "USUBJID"),
arm_var = teal.transform::choices_selected(c("ARM", "ARMCD"), "ARM"),
visit_var = teal.transform::choices_selected(c("AVISIT", "AVISITN"), "AVISIT"),
paramcd = teal.transform::choices_selected(
choices = teal.transform::value_choices(data[["ADQS"]], "PARAMCD", "PARAM"),
selected = "FKSI-FWB"
),
cov_var = teal.transform::choices_selected(c("BASE", "AGE", "SEX", "BASE:AVISIT"), NULL),
conf_level = teal.transform::choices_selected(c(0.95, 0.9, 0.8, -1), 0.95, keep_order = TRUE),
arm_ref_comp = NULL,
pre_output = NULL,
post_output = NULL,
basic_table_args = teal.widgets::basic_table_args()
teal::init(
data = data,
modules = tm_a_gee(
label = "GEE",
dataname = "ADQS",
parentname = "ADSL",
aval_var = teal.transform::choices_selected("AVALBIN", fixed = TRUE),
id_var = teal.transform::choices_selected(c("USUBJID", "SUBJID"), "USUBJID"),
arm_var = teal.transform::choices_selected(c("ARM", "ARMCD"), "ARM"),
visit_var = teal.transform::choices_selected(c("AVISIT", "AVISITN"), "AVISIT"),
paramcd = teal.transform::choices_selected(
choices = teal.transform::value_choices(data[["ADQS"]], "PARAMCD", "PARAM"),
selected = "FKSI-FWB"
),
cov_var = teal.transform::choices_selected(c("BASE", "AGE", "SEX", "BASE:AVISIT"), NULL),
conf_level = teal.transform::choices_selected(c(0.95, 0.9, 0.8, -1), 0.95, keep_order = TRUE),
arm_ref_comp = NULL,
pre_output = NULL,
post_output = NULL,
basic_table_args = teal.widgets::basic_table_args()
)
)
)
}
Expand All @@ -48,7 +50,7 @@ testthat::test_that("e2e - tm_a_gee: Module initializes in teal without errors a
app_driver <- app_driver_tm_a_gee()
app_driver$expect_no_shiny_error()
app_driver$expect_no_validation_error()
testthat::expect_true(app_driver$is_visible(app_driver$active_module_element("table-table-with-settings")))
testthat::expect_true(app_driver$is_visible(app_driver$namespaces(TRUE)$module("table-table-with-settings")))
app_driver$stop()
})

Expand Down Expand Up @@ -98,7 +100,7 @@ testthat::test_that(

testthat::expect_equal(app_driver$get_active_module_input("cor_struct"), "unstructured")

radio_buttons <- app_driver$active_module_element_text("output_table")
radio_buttons <- app_driver$namespaces(TRUE)$module("output_table")
testthat::expect_match(
radio_buttons,
"Output Type.*LS means.*Covariance.*Coefficients",
Expand Down Expand Up @@ -135,7 +137,7 @@ testthat::test_that("e2e - tm_a_gee: Deselection of id_var throws validation err
testthat::expect_identical(app_driver$get_active_module_table_output("table-table-with-settings"), data.frame())
app_driver$expect_validation_error()
testthat::expect_equal(
app_driver$active_module_element_text("id_var-dataset_ADQS_singleextract-select_input > div > span"),
app_driver$namespaces(TRUE)$module("id_var-dataset_ADQS_singleextract-select_input > div > span"),
"A Subject identifier is required"
)
app_driver$stop()
Expand Down Expand Up @@ -166,7 +168,7 @@ testthat::test_that("e2e - tm_a_gee: Deselection of arm_var throws validation er
testthat::expect_identical(app_driver$get_active_module_table_output("table-table-with-settings"), data.frame())
app_driver$expect_validation_error()
testthat::expect_equal(
app_driver$active_module_element_text("arm_var-dataset_ADSL_singleextract-select_input > div > span"),
app_driver$namespaces(TRUE)$module("arm_var-dataset_ADSL_singleextract-select_input > div > span"),
"A treatment variable is required"
)
app_driver$stop()
Expand Down Expand Up @@ -200,7 +202,7 @@ testthat::test_that("e2e - tm_a_gee: Deselection of visit_var throws validation
testthat::expect_identical(app_driver$get_active_module_table_output("table-table-with-settings"), data.frame())
app_driver$expect_validation_error()
testthat::expect_equal(
app_driver$active_module_element_text("visit_var-dataset_ADQS_singleextract-select_input > div > span"),
app_driver$namespaces(TRUE)$module("visit_var-dataset_ADQS_singleextract-select_input > div > span"),
"A visit variable is required"
)
app_driver$stop()
Expand Down Expand Up @@ -230,7 +232,7 @@ testthat::test_that("e2e - tm_a_gee: Deselection of paramcd throws validation er
testthat::expect_identical(app_driver$get_active_module_table_output("table-table-with-settings"), data.frame())
app_driver$expect_validation_error()
testthat::expect_equal(
app_driver$active_module_element_text("paramcd-dataset_ADQS_singleextract-filter1-vals_input > div > span"),
app_driver$namespaces(TRUE)$module("paramcd-dataset_ADQS_singleextract-filter1-vals_input > div > span"),
"An endpoint is required"
)
app_driver$stop()
Expand Down Expand Up @@ -277,7 +279,7 @@ testthat::test_that("e2e - tm_a_gee: Selection of conf_level out of [0,1] range
testthat::expect_identical(app_driver$get_active_module_table_output("table-table-with-settings"), data.frame())
app_driver$expect_validation_error()
testthat::expect_equal(
app_driver$active_module_element_text("conf_level_input > div > span"),
app_driver$namespaces(TRUE)$module("conf_level_input > div > span"),
"Confidence level must be between 0 and 1"
)
app_driver$stop()
Expand All @@ -291,7 +293,7 @@ testthat::test_that("e2e - tm_a_gee: Deselection of conf_level throws validation
testthat::expect_identical(app_driver$get_active_module_table_output("table-table-with-settings"), data.frame())
app_driver$expect_validation_error()
testthat::expect_equal(
app_driver$active_module_element_text("conf_level_input > div > span"),
app_driver$namespaces(TRUE)$module("conf_level_input > div > span"),
"Please choose a confidence level"
)
app_driver$stop()
Expand Down
90 changes: 46 additions & 44 deletions tests/testthat/test-shinytest2-tm_a_mmrm.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,43 +25,45 @@ app_driver_tm_a_mmrm <- function(fit_model = TRUE) {
arm_var <- choices_selected(c("ARM", "ARMCD"), "ARM")

app_driver <- init_teal_app_driver(
data = data,
modules = tm_a_mmrm(
label = "MMRM",
dataname = "ADQS",
parentname = ifelse(inherits(arm_var, "data_extract_spec"),
teal.transform::datanames_input(arm_var), "ADSL"
),
aval_var = choices_selected(c("AVAL", "CHG"), "AVAL"),
id_var = choices_selected(c("USUBJID", "SUBJID"), "USUBJID"),
arm_var = arm_var,
visit_var = choices_selected(c("AVISIT", "AVISITN"), "AVISIT"),
arm_ref_comp = arm_ref_comp,
paramcd = choices_selected(
choices = value_choices(data[["ADQS"]], "PARAMCD", "PARAM"),
selected = "FKSI-FWB"
),
cov_var = choices_selected(c("BASE", "AGE", "SEX", "BASE:AVISIT"), NULL),
method = teal.transform::choices_selected(c(
"Satterthwaite", "Kenward-Roger",
"Kenward-Roger-Linear"
), "Satterthwaite", keep_order = TRUE),
conf_level = teal.transform::choices_selected(c(0.95, 0.9, 0.8), 0.95,
keep_order =
TRUE
),
plot_height = c(700L, 200L, 2000L),
plot_width = NULL,
total_label = default_total_label(),
pre_output = NULL,
post_output = NULL,
basic_table_args = teal.widgets::basic_table_args(),
ggplot2_args = teal.widgets::ggplot2_args()
teal::init(
data = data,
modules = tm_a_mmrm(
label = "MMRM",
dataname = "ADQS",
parentname = ifelse(inherits(arm_var, "data_extract_spec"),
teal.transform::datanames_input(arm_var), "ADSL"
),
aval_var = choices_selected(c("AVAL", "CHG"), "AVAL"),
id_var = choices_selected(c("USUBJID", "SUBJID"), "USUBJID"),
arm_var = arm_var,
visit_var = choices_selected(c("AVISIT", "AVISITN"), "AVISIT"),
arm_ref_comp = arm_ref_comp,
paramcd = choices_selected(
choices = value_choices(data[["ADQS"]], "PARAMCD", "PARAM"),
selected = "FKSI-FWB"
),
cov_var = choices_selected(c("BASE", "AGE", "SEX", "BASE:AVISIT"), NULL),
method = teal.transform::choices_selected(c(
"Satterthwaite", "Kenward-Roger",
"Kenward-Roger-Linear"
), "Satterthwaite", keep_order = TRUE),
conf_level = teal.transform::choices_selected(c(0.95, 0.9, 0.8), 0.95,
keep_order =
TRUE
),
plot_height = c(700L, 200L, 2000L),
plot_width = NULL,
total_label = default_total_label(),
pre_output = NULL,
post_output = NULL,
basic_table_args = teal.widgets::basic_table_args(),
ggplot2_args = teal.widgets::ggplot2_args()
)
),
timeout = 30000
)
if (fit_model) {
app_driver$click(selector = app_driver$active_module_element("button_start"))
app_driver$click(selector = app_driver$namespaces(TRUE)$module("button_start"))
app_driver$wait_for_idle()
}
app_driver
Expand All @@ -86,7 +88,7 @@ testthat::test_that(
app_driver$expect_no_shiny_error()
app_driver$expect_no_validation_error()

null_text <- app_driver$active_module_element_text("null_input_msg")
null_text <- app_driver$namespaces(TRUE)$module("null_input_msg")

testthat::expect_match(null_text, "Please first specify 'Model Settings' and press 'Fit Model'")

Expand Down Expand Up @@ -168,7 +170,7 @@ testthat::test_that(
skip_if_too_deep(5)
app_driver <- app_driver_tm_a_mmrm()

app_driver$click(selector = app_driver$active_module_element("button_start"))
app_driver$click(selector = app_driver$namespaces(TRUE)$module("button_start"))
app_driver$wait_for_idle()
app_driver$expect_no_validation_error()

Expand All @@ -190,7 +192,7 @@ testthat::test_that(
skip_if_too_deep(5)
app_driver <- app_driver_tm_a_mmrm()

app_driver$click(selector = app_driver$active_module_element("button_start"))
app_driver$click(selector = app_driver$namespaces(TRUE)$module("button_start"))
app_driver$wait_for_idle()
app_driver$expect_no_validation_error()

Expand Down Expand Up @@ -233,7 +235,7 @@ testthat::test_that(
skip_if_too_deep(5)
app_driver <- app_driver_tm_a_mmrm()

app_driver$click(selector = app_driver$active_module_element("button_start"))
app_driver$click(selector = app_driver$namespaces(TRUE)$module("button_start"))
app_driver$wait_for_idle()
app_driver$expect_no_validation_error()

Expand Down Expand Up @@ -278,7 +280,7 @@ for (func in output_functions) {
}

testthat::expect_match(
app_driver$active_module_element_text(
app_driver$namespaces(TRUE)$module(
sprintf(
"%s .shiny-validation-message",
ns_des_input("aval_var", "ADQS", "select_input")
Expand Down Expand Up @@ -314,7 +316,7 @@ for (func in output_functions) {
}

testthat::expect_match(
app_driver$active_module_element_text(
app_driver$namespaces(TRUE)$module(
sprintf(
"%s .shiny-validation-message",
ns_des_input("paramcd", "ADQS", "filter1-vals_input")
Expand Down Expand Up @@ -350,7 +352,7 @@ for (func in output_functions) {
}

testthat::expect_match(
app_driver$active_module_element_text(
app_driver$namespaces(TRUE)$module(
sprintf(
"%s .shiny-validation-message",
ns_des_input("visit_var", "ADQS", "select_input")
Expand Down Expand Up @@ -386,7 +388,7 @@ for (func in output_functions) {
}

testthat::expect_match(
app_driver$active_module_element_text(
app_driver$namespaces(TRUE)$module(
sprintf(
"%s .shiny-validation-message",
ns_des_input("arm_var", "ADSL", "select_input")
Expand Down Expand Up @@ -422,7 +424,7 @@ for (func in output_functions) {
}

testthat::expect_match(
app_driver$active_module_element_text(
app_driver$namespaces(TRUE)$module(
sprintf(
"%s .shiny-validation-message",
ns_des_input("id_var", "ADQS", "select_input")
Expand Down Expand Up @@ -458,7 +460,7 @@ for (func in output_functions) {
}

testthat::expect_match(
app_driver$active_module_element_text(
app_driver$namespaces(TRUE)$module(
sprintf(
"%s .shiny-validation-message",
"conf_level_input"
Expand Down Expand Up @@ -530,7 +532,7 @@ for (func in output_functions) {
}

app_driver$set_active_module_input(input_name, input_list[[input_name]])
app_driver$click(selector = app_driver$active_module_element("button_start"))
app_driver$click(selector = app_driver$namespaces(TRUE)$module("button_start"))
app_driver$wait_for_idle()
app_driver$expect_no_validation_error()

Expand Down
Loading
Loading