diff --git a/R/tm_a_mmrm.R b/R/tm_a_mmrm.R index 02558465b..99b6c9055 100644 --- a/R/tm_a_mmrm.R +++ b/R/tm_a_mmrm.R @@ -1553,6 +1553,5 @@ srv_mmrm <- function(id, set_chunk_dims(pws, reactive({ decorated_objs_q[[obj_ix_r()]]() })) - }) } diff --git a/tests/testthat/test-shinytest2-tm_a_gee.R b/tests/testthat/test-shinytest2-tm_a_gee.R index f8ea8e4ce..aa30b9b75 100644 --- a/tests/testthat/test-shinytest2-tm_a_gee.R +++ b/tests/testthat/test-shinytest2-tm_a_gee.R @@ -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() + ) ) ) } @@ -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() }) @@ -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", @@ -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() @@ -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() @@ -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() @@ -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() @@ -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() @@ -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() diff --git a/tests/testthat/test-shinytest2-tm_a_mmrm.R b/tests/testthat/test-shinytest2-tm_a_mmrm.R index 1e2997e99..c058f1a18 100644 --- a/tests/testthat/test-shinytest2-tm_a_mmrm.R +++ b/tests/testthat/test-shinytest2-tm_a_mmrm.R @@ -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 @@ -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'") @@ -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() @@ -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() @@ -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() @@ -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") @@ -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") @@ -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") @@ -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") @@ -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") @@ -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" @@ -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() diff --git a/tests/testthat/test-shinytest2-tm_g_barchart_simple.R b/tests/testthat/test-shinytest2-tm_g_barchart_simple.R index 31e1d8258..0d19eabce 100644 --- a/tests/testthat/test-shinytest2-tm_g_barchart_simple.R +++ b/tests/testthat/test-shinytest2-tm_g_barchart_simple.R @@ -13,98 +13,100 @@ app_driver_tm_g_barchart_simple <- function() { # nolint: object_length. teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[names(data)] init_teal_app_driver( - data = data, - modules = tm_g_barchart_simple( - label = "ADAE Analysis (e2e)", - x = teal.transform::data_extract_spec( - dataname = "ADSL", - select = teal.transform::select_spec( - choices = teal.transform::variable_choices( - "ADSL", c("ARM", "ACTARM", "SEX", "RACE", "ITTFL", "SAFFL", "STRATA2") - ), - selected = "ACTARM", - multiple = FALSE - ) - ), - fill = list( - teal.transform::data_extract_spec( + teal::init( + data = data, + modules = tm_g_barchart_simple( + label = "ADAE Analysis (e2e)", + x = teal.transform::data_extract_spec( dataname = "ADSL", select = teal.transform::select_spec( choices = teal.transform::variable_choices( "ADSL", c("ARM", "ACTARM", "SEX", "RACE", "ITTFL", "SAFFL", "STRATA2") ), - selected = "SEX", + selected = "ACTARM", multiple = FALSE ) ), - teal.transform::data_extract_spec( - dataname = "ADAE", - select = teal.transform::select_spec( - choices = teal.transform::variable_choices("ADAE", c("AETOXGR", "AESEV", "AESER")), - selected = NULL, - multiple = FALSE - ) - ) - ), - x_facet = list( - teal.transform::data_extract_spec( - dataname = "ADAE", - select = teal.transform::select_spec( - choices = teal.transform::variable_choices("ADAE", c("AETOXGR", "AESEV", "AESER")), - selected = "AETOXGR", - multiple = FALSE + fill = list( + teal.transform::data_extract_spec( + dataname = "ADSL", + select = teal.transform::select_spec( + choices = teal.transform::variable_choices( + "ADSL", c("ARM", "ACTARM", "SEX", "RACE", "ITTFL", "SAFFL", "STRATA2") + ), + selected = "SEX", + multiple = FALSE + ) + ), + teal.transform::data_extract_spec( + dataname = "ADAE", + select = teal.transform::select_spec( + choices = teal.transform::variable_choices("ADAE", c("AETOXGR", "AESEV", "AESER")), + selected = NULL, + multiple = FALSE + ) ) ), - teal.transform::data_extract_spec( - dataname = "ADSL", - select = teal.transform::select_spec( - choices = teal.transform::variable_choices( - "ADSL", - c("ARM", "ACTARM", "SEX", "RACE", "ITTFL", "SAFFL", "STRATA2") - ), - selected = NULL, - multiple = FALSE - ) - ) - ), - y_facet = list( - data_extract_spec( - dataname = "ADAE", - select = teal.transform::select_spec( - choices = teal.transform::variable_choices( - "ADAE", - c("AETOXGR", "AESEV", "AESER") - ), - selected = "AESEV", - multiple = FALSE + x_facet = list( + teal.transform::data_extract_spec( + dataname = "ADAE", + select = teal.transform::select_spec( + choices = teal.transform::variable_choices("ADAE", c("AETOXGR", "AESEV", "AESER")), + selected = "AETOXGR", + multiple = FALSE + ) + ), + teal.transform::data_extract_spec( + dataname = "ADSL", + select = teal.transform::select_spec( + choices = teal.transform::variable_choices( + "ADSL", + c("ARM", "ACTARM", "SEX", "RACE", "ITTFL", "SAFFL", "STRATA2") + ), + selected = NULL, + multiple = FALSE + ) ) ), - data_extract_spec( - dataname = "ADSL", - select = teal.transform::select_spec( - choices = teal.transform::variable_choices( - "ADSL", - c("ARM", "ACTARM", "SEX", "RACE", "ITTFL", "SAFFL", "STRATA2") - ), - selected = NULL, - multiple = FALSE + y_facet = list( + data_extract_spec( + dataname = "ADAE", + select = teal.transform::select_spec( + choices = teal.transform::variable_choices( + "ADAE", + c("AETOXGR", "AESEV", "AESER") + ), + selected = "AESEV", + multiple = FALSE + ) + ), + data_extract_spec( + dataname = "ADSL", + select = teal.transform::select_spec( + choices = teal.transform::variable_choices( + "ADSL", + c("ARM", "ACTARM", "SEX", "RACE", "ITTFL", "SAFFL", "STRATA2") + ), + selected = NULL, + multiple = FALSE + ) ) - ) - ), - plot_options = list( - stacked = TRUE, - label_bars = FALSE, - rotate_bar_labels = TRUE, - rotate_x_label = TRUE, - rotate_y_label = TRUE, - flip_axis = TRUE, - show_n = FALSE - ), - plot_height = c(600L, 200L, 2000L), - plot_width = NULL, - pre_output = NULL, - post_output = NULL, - ggplot2_args = teal.widgets::ggplot2_args() + ), + plot_options = list( + stacked = TRUE, + label_bars = FALSE, + rotate_bar_labels = TRUE, + rotate_x_label = TRUE, + rotate_y_label = TRUE, + flip_axis = TRUE, + show_n = FALSE + ), + plot_height = c(600L, 200L, 2000L), + plot_width = NULL, + pre_output = NULL, + post_output = NULL, + ggplot2_args = teal.widgets::ggplot2_args() + ) ) ) } @@ -119,10 +121,10 @@ testthat::test_that("e2e - tm_g_barchart_simple: Module initializes in teal with app_driver$expect_no_shiny_error() app_driver$expect_no_validation_error() testthat::expect_true( - app_driver$is_visible(app_driver$active_module_element("myplot-plot_out_main")) + app_driver$is_visible(app_driver$namespaces(TRUE)$module("myplot-plot_out_main")) ) - testthat::expect_true(app_driver$is_visible(app_driver$active_module_element("table"))) + testthat::expect_true(app_driver$is_visible(app_driver$namespaces(TRUE)$module("table"))) app_driver$stop() }) @@ -210,7 +212,7 @@ testthat::test_that("e2e - tm_g_barchart_simple: Deselection of 'x' throws valid app_driver$set_active_module_input(ns_des_input("x", "ADSL", "select"), character(0L)) app_driver$expect_validation_error() testthat::expect_match( - app_driver$active_module_element_text( + app_driver$namespaces(TRUE)$module( sprintf( "%s .shiny-validation-message", ns_des_input("x", "ADSL", "select_input") @@ -290,7 +292,7 @@ for (input_id in c("fill", "x_facet", "y_facet")) { app_driver$expect_validation_error() testthat::expect_match( - app_driver$active_module_element_text( + app_driver$namespaces(TRUE)$module( sprintf( "%s .shiny-validation-message", ns_des_input("x", "ADSL", "select_input") @@ -300,7 +302,7 @@ for (input_id in c("fill", "x_facet", "y_facet")) { ) testthat::expect_match( - app_driver$active_module_element_text( + app_driver$namespaces(TRUE)$module( sprintf( "%s .shiny-validation-message", ns_des_input(input_id, "ADSL", "select_input") diff --git a/tests/testthat/test-shinytest2-tm_g_ci.R b/tests/testthat/test-shinytest2-tm_g_ci.R index f57debaba..c38759e5e 100644 --- a/tests/testthat/test-shinytest2-tm_g_ci.R +++ b/tests/testthat/test-shinytest2-tm_g_ci.R @@ -7,66 +7,68 @@ app_driver_tm_g_ci <- function() { teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[names(data)] init_teal_app_driver( - data = data, - modules = tm_g_ci( - label = "Confidence Interval Plot", - x_var = teal.transform::data_extract_spec( - dataname = "ADSL", - select = teal.transform::select_spec( - choices = c("ARMCD", "BMRKR2"), - selected = c("ARMCD"), - multiple = FALSE, - fixed = FALSE - ) - ), - y_var = teal.transform::data_extract_spec( - dataname = "ADLB", - filter = list( - teal.transform::filter_spec( - vars = "PARAMCD", - choices = c("ALT", "CRP", "IGA"), - selected = "ALT", + teal::init( + data = data, + modules = tm_g_ci( + label = "Confidence Interval Plot", + x_var = teal.transform::data_extract_spec( + dataname = "ADSL", + select = teal.transform::select_spec( + choices = c("ARMCD", "BMRKR2"), + selected = c("ARMCD"), multiple = FALSE, - label = "Select lab:" - ), - teal.transform::filter_spec( - vars = "AVISIT", - choices = c( - "SCREENING", "BASELINE", "WEEK 1 DAY 8", "WEEK 2 DAY 15", - "WEEK 3 DAY 22", "WEEK 4 DAY 29", "WEEK 5 DAY 36" + fixed = FALSE + ) + ), + y_var = teal.transform::data_extract_spec( + dataname = "ADLB", + filter = list( + teal.transform::filter_spec( + vars = "PARAMCD", + choices = c("ALT", "CRP", "IGA"), + selected = "ALT", + multiple = FALSE, + label = "Select lab:" ), - selected = "SCREENING", + teal.transform::filter_spec( + vars = "AVISIT", + choices = c( + "SCREENING", "BASELINE", "WEEK 1 DAY 8", "WEEK 2 DAY 15", + "WEEK 3 DAY 22", "WEEK 4 DAY 29", "WEEK 5 DAY 36" + ), + selected = "SCREENING", + multiple = FALSE, + label = "Select visit:" + ) + ), + select = teal.transform::select_spec( + label = "Analyzed Value", + choices = c("AVAL", "CHG", "CHG2"), + selected = "AVAL", multiple = FALSE, - label = "Select visit:" + fixed = FALSE ) ), - select = teal.transform::select_spec( - label = "Analyzed Value", - choices = c("AVAL", "CHG", "CHG2"), - selected = "AVAL", - multiple = FALSE, - fixed = FALSE - ) - ), - color = teal.transform::data_extract_spec( - dataname = "ADSL", - select = teal.transform::select_spec( - label = "Color by variable", - choices = c("SEX", "STRATA1", "STRATA2"), - selected = c("STRATA1"), - multiple = FALSE, - fixed = FALSE - ) - ), - stat = c("mean", "median"), - 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, - pre_output = NULL, - post_output = NULL, - ggplot2_args = teal.widgets::ggplot2_args() + color = teal.transform::data_extract_spec( + dataname = "ADSL", + select = teal.transform::select_spec( + label = "Color by variable", + choices = c("SEX", "STRATA1", "STRATA2"), + selected = c("STRATA1"), + multiple = FALSE, + fixed = FALSE + ) + ), + stat = c("mean", "median"), + 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, + pre_output = NULL, + post_output = NULL, + ggplot2_args = teal.widgets::ggplot2_args() + ) ) ) } @@ -163,7 +165,7 @@ testthat::test_that("e2e - tm_g_ci: Deselecting x_var column throws validation e testthat::expect_identical(app_driver$get_active_module_plot_output("myplot"), character(0)) app_driver$expect_validation_error() testthat::expect_identical( - app_driver$active_module_element_text("x_var-dataset_ADSL_singleextract-select_input > div > span"), + app_driver$namespaces(TRUE)$module("x_var-dataset_ADSL_singleextract-select_input > div > span"), "Select a treatment (x axis)" ) app_driver$stop() @@ -192,7 +194,7 @@ testthat::test_that("e2e - tm_g_ci: Deselecting y_var column throws validation e app_driver$set_active_module_input("y_var-dataset_ADLB_singleextract-select", character(0)) testthat::expect_identical(app_driver$get_active_module_plot_output("myplot"), character(0)) testthat::expect_identical( - app_driver$active_module_element_text("y_var-dataset_ADLB_singleextract-select_input > div > span"), + app_driver$namespaces(TRUE)$module("y_var-dataset_ADLB_singleextract-select_input > div > span"), "Select an analysis value (y axis)" ) app_driver$expect_validation_error() @@ -225,7 +227,7 @@ testthat::test_that("e2e - tm_g_ci: Deselecting PARAMCD filter value throws vali app_driver$set_active_module_input("y_var-dataset_ADLB_singleextract-filter1-vals", character(0)) testthat::expect_identical(app_driver$get_active_module_plot_output("myplot"), character(0)) testthat::expect_identical( - app_driver$active_module_element_text("y_var-dataset_ADLB_singleextract-filter1-vals_input > div > span"), + app_driver$namespaces(TRUE)$module("y_var-dataset_ADLB_singleextract-filter1-vals_input > div > span"), "Please select the filters." ) app_driver$expect_validation_error() @@ -250,7 +252,7 @@ testthat::test_that("e2e - tm_g_ci: Deselecting AVISIT filter value throws valid app_driver$set_active_module_input("y_var-dataset_ADLB_singleextract-filter2-vals", character(0)) testthat::expect_identical(app_driver$get_active_module_plot_output("myplot"), character(0)) testthat::expect_identical( - app_driver$active_module_element_text("y_var-dataset_ADLB_singleextract-filter2-vals_input > div > span"), + app_driver$namespaces(TRUE)$module("y_var-dataset_ADLB_singleextract-filter2-vals_input > div > span"), "Please select the filters." ) app_driver$expect_validation_error() diff --git a/tests/testthat/test-shinytest2-tm_g_forest_rsp.R b/tests/testthat/test-shinytest2-tm_g_forest_rsp.R index cf7b28438..d7ff0f3f5 100644 --- a/tests/testthat/test-shinytest2-tm_g_forest_rsp.R +++ b/tests/testthat/test-shinytest2-tm_g_forest_rsp.R @@ -22,63 +22,65 @@ app_driver_tm_g_forest_rsp <- function() { ) init_teal_app_driver( - data = data, - modules = modules( - tm_g_forest_rsp( - label = "Forest Response", - dataname = "ADRS", - parentname = "ADSL", - arm_var = teal.transform::choices_selected( - teal.transform::variable_choices(data[["ADSL"]], c("ARM", "ARMCD")), - "ARMCD" - ), - arm_ref_comp = arm_ref_comp, - paramcd = teal.transform::choices_selected( - teal.transform::value_choices(data[["ADRS"]], "PARAMCD", "PARAM"), - "INVET" - ), - aval_var = teal.transform::choices_selected( - teal.transform::variable_choices(data[["ADRS"]], "AVALC"), - "AVALC", - fixed = TRUE - ), - subgroup_var = teal.transform::choices_selected( - teal.transform::variable_choices(data[["ADSL"]], names(data[["ADSL"]])), - c("BMRKR2", "SEX") - ), - strata_var = teal.transform::choices_selected( - teal.transform::variable_choices(data[["ADSL"]], c("STRATA1", "STRATA2")), - "STRATA2" - ), - fixed_symbol_size = TRUE, - conf_level = teal.transform::choices_selected(c(0.95, 0.9, 0.8, 2), 0.95, keep_order = TRUE), - plot_height = c(600L, 200L, 2000L), - default_responses = list( - BESRSPI = list( - rsp = c("Stable Disease (SD)", "Not Evaluable (NE)"), - levels = c( - "Complete Response (CR)", "Partial Response (PR)", "Stable Disease (SD)", - "Progressive Disease (PD)", "Not Evaluable (NE)" - ) + teal::init( + data = data, + modules = modules( + tm_g_forest_rsp( + label = "Forest Response", + dataname = "ADRS", + parentname = "ADSL", + arm_var = teal.transform::choices_selected( + teal.transform::variable_choices(data[["ADSL"]], c("ARM", "ARMCD")), + "ARMCD" + ), + arm_ref_comp = arm_ref_comp, + paramcd = teal.transform::choices_selected( + teal.transform::value_choices(data[["ADRS"]], "PARAMCD", "PARAM"), + "INVET" + ), + aval_var = teal.transform::choices_selected( + teal.transform::variable_choices(data[["ADRS"]], "AVALC"), + "AVALC", + fixed = TRUE + ), + subgroup_var = teal.transform::choices_selected( + teal.transform::variable_choices(data[["ADSL"]], names(data[["ADSL"]])), + c("BMRKR2", "SEX") + ), + strata_var = teal.transform::choices_selected( + teal.transform::variable_choices(data[["ADSL"]], c("STRATA1", "STRATA2")), + "STRATA2" ), - INVET = list( - rsp = c("Complete Response (CR)", "Partial Response (PR)"), - levels = c( - "Complete Response (CR)", "Not Evaluable (NE)", "Partial Response (PR)", - "Progressive Disease (PD)", "Stable Disease (SD)" + fixed_symbol_size = TRUE, + conf_level = teal.transform::choices_selected(c(0.95, 0.9, 0.8, 2), 0.95, keep_order = TRUE), + plot_height = c(600L, 200L, 2000L), + default_responses = list( + BESRSPI = list( + rsp = c("Stable Disease (SD)", "Not Evaluable (NE)"), + levels = c( + "Complete Response (CR)", "Partial Response (PR)", "Stable Disease (SD)", + "Progressive Disease (PD)", "Not Evaluable (NE)" + ) + ), + INVET = list( + rsp = c("Complete Response (CR)", "Partial Response (PR)"), + levels = c( + "Complete Response (CR)", "Not Evaluable (NE)", "Partial Response (PR)", + "Progressive Disease (PD)", "Stable Disease (SD)" + ) + ), + OVRINV = list( + rsp = c("Progressive Disease (PD)", "Stable Disease (SD)"), + levels = c("Progressive Disease (PD)", "Stable Disease (SD)", "Not Evaluable (NE)") ) ), - OVRINV = list( - rsp = c("Progressive Disease (PD)", "Stable Disease (SD)"), - levels = c("Progressive Disease (PD)", "Stable Disease (SD)", "Not Evaluable (NE)") - ) - ), - plot_width = c(1500L, 800L, 3000L), - rel_width_forest = c(25L, 0L, 100L), - font_size = c(15L, 1L, 30L), - pre_output = NULL, - post_output = NULL, - ggplot2_args = teal.widgets::ggplot2_args() + plot_width = c(1500L, 800L, 3000L), + rel_width_forest = c(25L, 0L, 100L), + font_size = c(15L, 1L, 30L), + pre_output = NULL, + post_output = NULL, + ggplot2_args = teal.widgets::ggplot2_args() + ) ) ) ) @@ -91,7 +93,7 @@ testthat::test_that("e2e - tm_g_forest_rsp: Module initializes in teal without e app_driver <- app_driver_tm_g_forest_rsp() app_driver$expect_no_shiny_error() app_driver$expect_no_validation_error() - testthat::expect_true(app_driver$is_visible(app_driver$active_module_element("myplot-plot_main"))) + testthat::expect_true(app_driver$is_visible(app_driver$namespaces(TRUE)$module("myplot-plot_main"))) app_driver$stop() }) @@ -175,7 +177,7 @@ testthat::test_that("e2e - tm_g_forest_rsp: Deselecting arm_var throws validatio app_driver$set_active_module_input("arm_var-dataset_ADSL_singleextract-select", NULL) app_driver$expect_validation_error() testthat::expect_match( - app_driver$active_module_element_text("myplot-plot_out_main"), + app_driver$namespaces(TRUE)$module("myplot-plot_out_main"), "Treatment variable must be selected" ) app_driver$stop() @@ -199,7 +201,7 @@ testthat::test_that("e2e - tm_g_forest_rsp: Deselecting paramcd throws validatio app_driver$set_active_module_input("paramcd-dataset_ADRS_singleextract-filter1-vals", NULL) app_driver$expect_validation_error() testthat::expect_match( - app_driver$active_module_element_text("myplot-plot_out_main"), + app_driver$namespaces(TRUE)$module("myplot-plot_out_main"), "Please select Endpoint filter" ) app_driver$stop() @@ -223,7 +225,7 @@ testthat::test_that("e2e - tm_g_forest_rsp: Deselecting responders throws valida app_driver$set_active_module_input("responders", NULL) app_driver$expect_validation_error() testthat::expect_match( - app_driver$active_module_element_text("myplot-plot_out_main"), + app_driver$namespaces(TRUE)$module("myplot-plot_out_main"), "`Responders` field is empty" ) app_driver$stop() @@ -247,7 +249,7 @@ testthat::test_that("e2e - tm_g_forest_rsp: Selecting a non-factors column in su app_driver$set_active_module_input("subgroup_var-dataset_ADSL_singleextract-select", c("SEX", "AGE")) app_driver$expect_validation_error() testthat::expect_match( - app_driver$active_module_element_text("myplot-plot_out_main"), + app_driver$namespaces(TRUE)$module("myplot-plot_out_main"), "Not all subgroup variables are factors" ) app_driver$stop() @@ -304,13 +306,13 @@ testthat::test_that("e2e - tm_g_forest_rsp: Deselecting conf_level or selecting app_driver$set_active_module_input("conf_level", NULL) app_driver$expect_validation_error() testthat::expect_match( - app_driver$active_module_element_text("myplot-plot_out_main"), + app_driver$namespaces(TRUE)$module("myplot-plot_out_main"), "Please choose a confidence level between 0 and 1" ) app_driver$set_active_module_input("conf_level", 2) app_driver$expect_validation_error() testthat::expect_match( - app_driver$active_module_element_text("myplot-plot_out_main"), + app_driver$namespaces(TRUE)$module("myplot-plot_out_main"), "Please choose a confidence level between 0 and 1" ) app_driver$stop() diff --git a/tests/testthat/test-shinytest2-tm_g_forest_tte.R b/tests/testthat/test-shinytest2-tm_g_forest_tte.R index 84e56c212..c767d14e6 100644 --- a/tests/testthat/test-shinytest2-tm_g_forest_tte.R +++ b/tests/testthat/test-shinytest2-tm_g_forest_tte.R @@ -18,55 +18,57 @@ app_driver_tm_g_forest_tte <- function() { ) init_teal_app_driver( - data = data, - modules = tm_g_forest_tte( - label = "Forest Survival (e2e)", - dataname = "ADTTE", - parentname = "ADSL", - arm_var = teal.transform::choices_selected( - teal.transform::variable_choices(data[["ADSL"]], c("ARM", "ARMCD")), - "ARMCD" - ), - arm_ref_comp = arm_ref_comp, - paramcd = teal.transform::choices_selected( - teal.transform::value_choices(data[["ADTTE"]], "PARAMCD", "PARAM"), - "OS" - ), - subgroup_var = teal.transform::choices_selected( - teal.transform::variable_choices(data[["ADSL"]], names(data[["ADSL"]])), - c("BMRKR2", "SEX") - ), - strata_var = teal.transform::choices_selected( - teal.transform::variable_choices(data[["ADSL"]], c("STRATA1", "STRATA2")), - "STRATA2" - ), - aval_var = teal.transform::choices_selected( - teal.transform::variable_choices(data[["ADTTE"]], "AVAL"), - "AVAL", - fixed = TRUE - ), - cnsr_var = teal.transform::choices_selected( - teal.transform::variable_choices(data[["ADTTE"]], "CNSR"), - "CNSR", - fixed = TRUE - ), - conf_level = teal.transform::choices_selected( - c(0.95, 0.9, 0.8), 0.95, - keep_order = TRUE - ), - time_unit_var = teal.transform::choices_selected( - teal.transform::variable_choices(data[["ADTTE"]], "AVALU"), - "AVALU", - fixed = TRUE - ), - fixed_symbol_size = FALSE, - plot_height = c(500L, 300L, 2000L), - plot_width = c(1000L, 700L, 2000L), - rel_width_forest = c(25L, 0L, 100L), - font_size = c(12L, 1L, 30L), - pre_output = NULL, - post_output = NULL, - ggplot2_args = teal.widgets::ggplot2_args() + teal::init( + data = data, + modules = tm_g_forest_tte( + label = "Forest Survival (e2e)", + dataname = "ADTTE", + parentname = "ADSL", + arm_var = teal.transform::choices_selected( + teal.transform::variable_choices(data[["ADSL"]], c("ARM", "ARMCD")), + "ARMCD" + ), + arm_ref_comp = arm_ref_comp, + paramcd = teal.transform::choices_selected( + teal.transform::value_choices(data[["ADTTE"]], "PARAMCD", "PARAM"), + "OS" + ), + subgroup_var = teal.transform::choices_selected( + teal.transform::variable_choices(data[["ADSL"]], names(data[["ADSL"]])), + c("BMRKR2", "SEX") + ), + strata_var = teal.transform::choices_selected( + teal.transform::variable_choices(data[["ADSL"]], c("STRATA1", "STRATA2")), + "STRATA2" + ), + aval_var = teal.transform::choices_selected( + teal.transform::variable_choices(data[["ADTTE"]], "AVAL"), + "AVAL", + fixed = TRUE + ), + cnsr_var = teal.transform::choices_selected( + teal.transform::variable_choices(data[["ADTTE"]], "CNSR"), + "CNSR", + fixed = TRUE + ), + conf_level = teal.transform::choices_selected( + c(0.95, 0.9, 0.8), 0.95, + keep_order = TRUE + ), + time_unit_var = teal.transform::choices_selected( + teal.transform::variable_choices(data[["ADTTE"]], "AVALU"), + "AVALU", + fixed = TRUE + ), + fixed_symbol_size = FALSE, + plot_height = c(500L, 300L, 2000L), + plot_width = c(1000L, 700L, 2000L), + rel_width_forest = c(25L, 0L, 100L), + font_size = c(12L, 1L, 30L), + pre_output = NULL, + post_output = NULL, + ggplot2_args = teal.widgets::ggplot2_args() + ) ) ) } @@ -80,7 +82,7 @@ testthat::test_that("e2e - tm_g_forest_tte: Module initializes in teal without e app_driver$expect_no_shiny_error() app_driver$expect_no_validation_error() testthat::expect_true( - app_driver$is_visible(app_driver$active_module_element("myplot-plot_out_main")) + app_driver$is_visible(app_driver$namespaces(TRUE)$module("myplot-plot_out_main")) ) app_driver$stop() @@ -168,7 +170,7 @@ testthat::test_that("e2e - tm_g_forest_tte: Deselection of paramcd filter throws app_driver$set_active_module_input(input_id, character(0L)) app_driver$expect_validation_error() testthat::expect_match( - app_driver$active_module_element_text( + app_driver$namespaces(TRUE)$module( sprintf( "%s_input .shiny-validation-message", input_id @@ -201,7 +203,7 @@ testthat::test_that("e2e - tm_g_forest_tte: Deselection of paramcd var throws va app_driver$set_active_module_input(input_id, character(0L)) app_driver$expect_validation_error() testthat::expect_match( - app_driver$active_module_element_text( + app_driver$namespaces(TRUE)$module( sprintf( "%s_input .shiny-validation-message", input_id @@ -224,7 +226,7 @@ testthat::test_that( testthat::expect_false(identical(plot_before, app_driver$get_active_module_plot_output("myplot"))) app_driver$expect_validation_error() testthat::expect_match( - app_driver$active_module_element_text( + app_driver$namespaces(TRUE)$module( sprintf("%s_input .shiny-validation-message", input_id) ), "Please choose a confidence level" diff --git a/tests/testthat/test-shinytest2-tm_g_ipp.R b/tests/testthat/test-shinytest2-tm_g_ipp.R index 061bc6724..8055c0d07 100644 --- a/tests/testthat/test-shinytest2-tm_g_ipp.R +++ b/tests/testthat/test-shinytest2-tm_g_ipp.R @@ -13,51 +13,53 @@ app_driver_tm_g_ipp <- function() { teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[names(data)] init_teal_app_driver( - data = data, - modules = tm_g_ipp( - label = "Individual Patient Plot", - dataname = "ADLB", - parentname = "ADSL", - arm_var = teal.transform::choices_selected( - teal.transform::value_choices(data[["ADLB"]], "ARMCD"), - "ARM A" - ), - paramcd = teal.transform::choices_selected( - teal.transform::value_choices(data[["ADLB"]], "PARAMCD"), - "ALT" - ), - aval_var = teal.transform::choices_selected( - teal.transform::variable_choices(data[["ADLB"]], c("AVAL", "CHG")), - "AVAL" - ), - avalu_var = teal.transform::choices_selected( - teal.transform::variable_choices(data[["ADLB"]], c("AVALU")), - "AVALU", - fixed = TRUE - ), - id_var = teal.transform::choices_selected( - teal.transform::variable_choices(data[["ADLB"]], c("USUBJID")), - "USUBJID", - fixed = TRUE - ), - visit_var = teal.transform::choices_selected( - teal.transform::variable_choices(data[["ADLB"]], c("AVISIT", "ATOXGR")), - "AVISIT" - ), - baseline_var = teal.transform::choices_selected( - teal.transform::variable_choices(data[["ADLB"]], c("BASE")), - "BASE", - fixed = TRUE - ), - add_baseline_hline = FALSE, - separate_by_obs = FALSE, - suppress_legend = FALSE, - add_avalu = TRUE, - plot_height = c(1200L, 400L, 5000L), - plot_width = NULL, - pre_output = NULL, - post_output = NULL, - ggplot2_args = teal.widgets::ggplot2_args() + teal::init( + data = data, + modules = tm_g_ipp( + label = "Individual Patient Plot", + dataname = "ADLB", + parentname = "ADSL", + arm_var = teal.transform::choices_selected( + teal.transform::value_choices(data[["ADLB"]], "ARMCD"), + "ARM A" + ), + paramcd = teal.transform::choices_selected( + teal.transform::value_choices(data[["ADLB"]], "PARAMCD"), + "ALT" + ), + aval_var = teal.transform::choices_selected( + teal.transform::variable_choices(data[["ADLB"]], c("AVAL", "CHG")), + "AVAL" + ), + avalu_var = teal.transform::choices_selected( + teal.transform::variable_choices(data[["ADLB"]], c("AVALU")), + "AVALU", + fixed = TRUE + ), + id_var = teal.transform::choices_selected( + teal.transform::variable_choices(data[["ADLB"]], c("USUBJID")), + "USUBJID", + fixed = TRUE + ), + visit_var = teal.transform::choices_selected( + teal.transform::variable_choices(data[["ADLB"]], c("AVISIT", "ATOXGR")), + "AVISIT" + ), + baseline_var = teal.transform::choices_selected( + teal.transform::variable_choices(data[["ADLB"]], c("BASE")), + "BASE", + fixed = TRUE + ), + add_baseline_hline = FALSE, + separate_by_obs = FALSE, + suppress_legend = FALSE, + add_avalu = TRUE, + plot_height = c(1200L, 400L, 5000L), + plot_width = NULL, + pre_output = NULL, + post_output = NULL, + ggplot2_args = teal.widgets::ggplot2_args() + ) ) ) } @@ -154,7 +156,7 @@ testthat::test_that("e2e - tm_g_ipp: Deselecting arm_var column throws validatio app_driver$set_active_module_input("arm_var-dataset_ADSL_singleextract-filter1-vals", NULL) testthat::expect_identical(app_driver$get_active_module_plot_output("myplot"), character(0)) testthat::expect_identical( - app_driver$active_module_element_text("arm_var-dataset_ADSL_singleextract-filter1-vals_input > div > span"), + app_driver$namespaces(TRUE)$module("arm_var-dataset_ADSL_singleextract-filter1-vals_input > div > span"), "Please select Arm filter." ) app_driver$expect_validation_error() @@ -184,7 +186,7 @@ testthat::test_that("e2e - tm_g_ipp: Deselecting paramcd throws validation error app_driver$set_active_module_input("paramcd-dataset_ADLB_singleextract-filter1-vals", NULL) testthat::expect_identical(app_driver$get_active_module_plot_output("myplot"), character(0)) testthat::expect_identical( - app_driver$active_module_element_text("paramcd-dataset_ADLB_singleextract-filter1-vals_input > div > span"), + app_driver$namespaces(TRUE)$module("paramcd-dataset_ADLB_singleextract-filter1-vals_input > div > span"), "Please select Parameter filter." ) app_driver$expect_validation_error() @@ -214,7 +216,7 @@ testthat::test_that("e2e - tm_g_ipp: Deselecting visit_var throws validation err app_driver$set_active_module_input("visit_var-dataset_ADLB_singleextract-select", NULL) testthat::expect_identical(app_driver$get_active_module_plot_output("myplot"), character(0)) testthat::expect_identical( - app_driver$active_module_element_text("visit_var-dataset_ADLB_singleextract-select_input > div > span"), + app_driver$namespaces(TRUE)$module("visit_var-dataset_ADLB_singleextract-select_input > div > span"), "A Timepoint Variable must be selected" ) app_driver$expect_validation_error() @@ -244,7 +246,7 @@ testthat::test_that("e2e - tm_g_ipp: Deselecting aval_var throws validation erro app_driver$set_active_module_input("aval_var-dataset_ADLB_singleextract-select", NULL) testthat::expect_identical(app_driver$get_active_module_plot_output("myplot"), character(0)) testthat::expect_identical( - app_driver$active_module_element_text("aval_var-dataset_ADLB_singleextract-select_input > div > span"), + app_driver$namespaces(TRUE)$module("aval_var-dataset_ADLB_singleextract-select_input > div > span"), "A Parameter values over Time must be selected" ) app_driver$expect_validation_error() diff --git a/tests/testthat/test-shinytest2-tm_g_km.R b/tests/testthat/test-shinytest2-tm_g_km.R index 33f273e6f..a20fb0f11 100644 --- a/tests/testthat/test-shinytest2-tm_g_km.R +++ b/tests/testthat/test-shinytest2-tm_g_km.R @@ -23,54 +23,56 @@ app_driver_tm_g_km <- function() { ) init_teal_app_driver( - data = data, - modules = tm_g_km( - label = "Kaplan-Meier Plot", - dataname = "ADTTE", - parentname = "ADSL", - arm_var = teal.transform::choices_selected( - teal.transform::variable_choices(data[["ADSL"]], c("ARM", "ARMCD", "ACTARMCD")), - "ARM" - ), - paramcd = teal.transform::choices_selected( - teal.transform::value_choices(data[["ADTTE"]], "PARAMCD", "PARAM"), - "OS" - ), - arm_ref_comp = arm_ref_comp, - strata_var = teal.transform::choices_selected( - teal.transform::variable_choices(data[["ADSL"]], c("SEX", "BMRKR2")), - "SEX" - ), - facet_var = teal.transform::choices_selected( - teal.transform::variable_choices(data[["ADSL"]], c("SEX", "BMRKR2")), - NULL - ), - time_unit_var = teal.transform::choices_selected( - teal.transform::variable_choices(data[["ADTTE"]], "VALUE_UNIT"), - "VALUE_UNIT", - fixed = TRUE - ), - aval_var = teal.transform::choices_selected( - teal.transform::variable_choices(data[["ADTTE"]], "ANALYSIS_VAL"), - "ANALYSIS_VAL", - fixed = TRUE - ), - cnsr_var = teal.transform::choices_selected( - teal.transform::variable_choices(data[["ADTTE"]], "CENSORING"), - "CENSORING", - fixed = TRUE - ), - conf_level = teal.transform::choices_selected(c(0.95, 0.9, 0.8, -1), 0.95, keep_order = TRUE), - conf_type = teal.transform::choices_selected(c("plain", "log", "log-log", "none"), "log", keep_order = TRUE), - font_size = c(11L, 1L, 30), - control_annot_surv_med = control_surv_med_annot(), - control_annot_coxph = control_coxph_annot(x = 0.27, y = 0.35, w = 0.3), - legend_pos = c(0.9, 0.5), - rel_height_plot = c(80L, 0L, 100L), - plot_height = c(800L, 400L, 5000L), - plot_width = NULL, - pre_output = NULL, - post_output = NULL + teal::init( + data = data, + modules = tm_g_km( + label = "Kaplan-Meier Plot", + dataname = "ADTTE", + parentname = "ADSL", + arm_var = teal.transform::choices_selected( + teal.transform::variable_choices(data[["ADSL"]], c("ARM", "ARMCD", "ACTARMCD")), + "ARM" + ), + paramcd = teal.transform::choices_selected( + teal.transform::value_choices(data[["ADTTE"]], "PARAMCD", "PARAM"), + "OS" + ), + arm_ref_comp = arm_ref_comp, + strata_var = teal.transform::choices_selected( + teal.transform::variable_choices(data[["ADSL"]], c("SEX", "BMRKR2")), + "SEX" + ), + facet_var = teal.transform::choices_selected( + teal.transform::variable_choices(data[["ADSL"]], c("SEX", "BMRKR2")), + NULL + ), + time_unit_var = teal.transform::choices_selected( + teal.transform::variable_choices(data[["ADTTE"]], "VALUE_UNIT"), + "VALUE_UNIT", + fixed = TRUE + ), + aval_var = teal.transform::choices_selected( + teal.transform::variable_choices(data[["ADTTE"]], "ANALYSIS_VAL"), + "ANALYSIS_VAL", + fixed = TRUE + ), + cnsr_var = teal.transform::choices_selected( + teal.transform::variable_choices(data[["ADTTE"]], "CENSORING"), + "CENSORING", + fixed = TRUE + ), + conf_level = teal.transform::choices_selected(c(0.95, 0.9, 0.8, -1), 0.95, keep_order = TRUE), + conf_type = teal.transform::choices_selected(c("plain", "log", "log-log", "none"), "log", keep_order = TRUE), + font_size = c(11L, 1L, 30), + control_annot_surv_med = control_surv_med_annot(), + control_annot_coxph = control_coxph_annot(x = 0.27, y = 0.35, w = 0.3), + legend_pos = c(0.9, 0.5), + rel_height_plot = c(80L, 0L, 100L), + plot_height = c(800L, 400L, 5000L), + plot_width = NULL, + pre_output = NULL, + post_output = NULL + ) ) ) } @@ -197,13 +199,13 @@ testthat::test_that("e2e - tm_g_km: Deselecting {paramcd} throws validation erro app_driver$set_active_module_input("paramcd-dataset_ADTTE_singleextract-filter1-vals", character(0)) app_driver$expect_validation_error() testthat::expect_match( - app_driver$active_module_element_text( + app_driver$namespaces(TRUE)$module( "paramcd-dataset_ADTTE_singleextract-filter1-vals_input .shiny-validation-message" ), "An endpoint is required" ) testthat::expect_match( - app_driver$active_module_element_text("myplot-plot-with-settings"), + app_driver$namespaces(TRUE)$module("myplot-plot-with-settings"), "An endpoint is required" ) app_driver$stop() @@ -216,7 +218,7 @@ testthat::test_that("e2e - tm_g_km: Deselecting {arm_var} throws validation erro app_driver$set_active_module_input(ns_des_input("arm_var", "ADSL", "select"), character(0)) app_driver$expect_validation_error() testthat::expect_match( - app_driver$active_module_element_text( + app_driver$namespaces(TRUE)$module( "arm_var-dataset_ADSL_singleextract-select_input .shiny-validation-message" ), "Treatment variable must be selected" @@ -270,17 +272,17 @@ testthat::test_that("e2e - tm_g_km: Starts with specified collapsed comparison s skip_if_too_deep(5) app_driver <- app_driver_tm_g_km() - app_driver$is_visible(app_driver$active_module_element("pval_method_coxph")) - app_driver$is_visible(app_driver$active_module_element("ties_coxph")) + app_driver$is_visible(app_driver$namespaces(TRUE)$module("pval_method_coxph")) + app_driver$is_visible(app_driver$namespaces(TRUE)$module("ties_coxph")) testthat::expect_equal(app_driver$get_active_module_input("pval_method_coxph"), "log-rank") testthat::expect_equal( - app_driver$active_module_element_text("pval_method_coxph-label"), + app_driver$namespaces(TRUE)$module("pval_method_coxph-label"), "p-value method for Coxph (Hazard Ratio)" ) testthat::expect_equal(app_driver$get_active_module_input("ties_coxph"), "exact") testthat::expect_equal( - app_driver$active_module_element_text("ties_coxph-label"), + app_driver$namespaces(TRUE)$module("ties_coxph-label"), "Ties for Coxph (Hazard Ratio)" ) @@ -334,14 +336,14 @@ testthat::test_that("e2e - tm_g_km: Starts with specified collapsed additional p skip_if_too_deep(5) app_driver <- app_driver_tm_g_km() - testthat::expect_false(app_driver$is_visible(app_driver$active_module_element("xticks"))) - testthat::expect_false(app_driver$is_visible(app_driver$active_module_element("yval"))) - testthat::expect_false(app_driver$is_visible(app_driver$active_module_element("font_size"))) - testthat::expect_false(app_driver$is_visible(app_driver$active_module_element("rel_height_plot"))) - testthat::expect_false(app_driver$is_visible(app_driver$active_module_element("show_ci_ribbon"))) - testthat::expect_false(app_driver$is_visible(app_driver$active_module_element("show_km_table"))) - testthat::expect_false(app_driver$is_visible(app_driver$active_module_element("conf_level"))) - testthat::expect_false(app_driver$is_visible(app_driver$active_module_element("xlab"))) + testthat::expect_false(app_driver$is_visible(app_driver$namespaces(TRUE)$module("xticks"))) + testthat::expect_false(app_driver$is_visible(app_driver$namespaces(TRUE)$module("yval"))) + testthat::expect_false(app_driver$is_visible(app_driver$namespaces(TRUE)$module("font_size"))) + testthat::expect_false(app_driver$is_visible(app_driver$namespaces(TRUE)$module("rel_height_plot"))) + testthat::expect_false(app_driver$is_visible(app_driver$namespaces(TRUE)$module("show_ci_ribbon"))) + testthat::expect_false(app_driver$is_visible(app_driver$namespaces(TRUE)$module("show_km_table"))) + testthat::expect_false(app_driver$is_visible(app_driver$namespaces(TRUE)$module("conf_level"))) + testthat::expect_false(app_driver$is_visible(app_driver$namespaces(TRUE)$module("xlab"))) testthat::expect_equal(app_driver$get_active_module_input("xticks"), "") testthat::expect_equal(app_driver$get_active_module_input("yval"), "Survival probability") @@ -354,13 +356,13 @@ testthat::test_that("e2e - tm_g_km: Starts with specified collapsed additional p testthat::expect_equal(app_driver$get_active_module_input("xlab"), "Time") testthat::expect_equal( - app_driver$active_module_element_text("xticks-label"), + app_driver$namespaces(TRUE)$module("xticks-label"), "Specify break intervals for x-axis e.g. 0 ; 500" ) - testthat::expect_match(app_driver$active_module_element_text("yval-label"), "Value on y-axis", fixed = FALSE) - testthat::expect_equal(app_driver$active_module_element_text("font_size-label"), "Table Font Size") - testthat::expect_equal(app_driver$active_module_element_text("rel_height_plot-label"), "Relative Height of Plot (%)") - testthat::expect_equal(app_driver$active_module_element_text("xlab-label"), "X-axis label") + testthat::expect_match(app_driver$namespaces(TRUE)$module("yval-label"), "Value on y-axis", fixed = FALSE) + testthat::expect_equal(app_driver$namespaces(TRUE)$module("font_size-label"), "Table Font Size") + testthat::expect_equal(app_driver$namespaces(TRUE)$module("rel_height_plot-label"), "Relative Height of Plot (%)") + testthat::expect_equal(app_driver$namespaces(TRUE)$module("xlab-label"), "X-axis label") app_driver$stop() }) @@ -400,7 +402,7 @@ testthat::test_that("e2e - tm_g_km: Deselecting {conf_level} throws validation e app_driver$set_active_module_input("conf_level", -1) app_driver$expect_validation_error() testthat::expect_match( - app_driver$active_module_element_text("myplot-plot-with-settings"), + app_driver$namespaces(TRUE)$module("myplot-plot-with-settings"), "Confidence level must be between 0 and 1." ) app_driver$stop() diff --git a/tests/testthat/test-shinytest2-tm_g_lineplot.R b/tests/testthat/test-shinytest2-tm_g_lineplot.R index b27df70eb..02d8ae792 100644 --- a/tests/testthat/test-shinytest2-tm_g_lineplot.R +++ b/tests/testthat/test-shinytest2-tm_g_lineplot.R @@ -11,51 +11,53 @@ app_driver_tm_g_lineplot <- function() { teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[names(data)] init_teal_app_driver( - data = data, - modules = tm_g_lineplot( - label = "Line Plot", - dataname = "ADLB", - parentname = "ADSL", - group_var = teal.transform::choices_selected( - teal.transform::variable_choices("ADSL", c("ARM", "ARMCD", "ACTARMCD")), - "ARM" - ), - x = teal.transform::choices_selected(teal.transform::variable_choices( - "ADLB", - "AVISIT" - ), "AVISIT", fixed = TRUE), - y = teal.transform::choices_selected( - teal.transform::variable_choices("ADLB", c("AVAL", "BASE", "CHG", "PCHG")), - "AVAL" - ), - y_unit = teal.transform::choices_selected(teal.transform::variable_choices( - "ADLB", - "AVALU" - ), "AVALU", fixed = TRUE), - paramcd = teal.transform::choices_selected(teal.transform::variable_choices( - "ADLB", - "PARAMCD" - ), "PARAMCD", fixed = TRUE), - param = teal.transform::choices_selected( - teal.transform::value_choices("ADLB", "PARAMCD", "PARAM"), - "ALT" - ), - conf_level = teal.transform::choices_selected(c(0.95, 0.9, 0.8), 0.95, - keep_order = - TRUE - ), - interval = "mean_ci", - mid = "mean", - whiskers = c("mean_ci_lwr", "mean_ci_upr"), - table = c("n", "mean_sd", "median", "range"), - mid_type = "pl", - mid_point_size = c(2, 1, 5), - table_font_size = c(4, 2, 6), - plot_height = c(1000L, 200L, 4000L), - plot_width = NULL, - pre_output = NULL, - post_output = NULL, - ggplot2_args = teal.widgets::ggplot2_args() + teal::init( + data = data, + modules = tm_g_lineplot( + label = "Line Plot", + dataname = "ADLB", + parentname = "ADSL", + group_var = teal.transform::choices_selected( + teal.transform::variable_choices("ADSL", c("ARM", "ARMCD", "ACTARMCD")), + "ARM" + ), + x = teal.transform::choices_selected(teal.transform::variable_choices( + "ADLB", + "AVISIT" + ), "AVISIT", fixed = TRUE), + y = teal.transform::choices_selected( + teal.transform::variable_choices("ADLB", c("AVAL", "BASE", "CHG", "PCHG")), + "AVAL" + ), + y_unit = teal.transform::choices_selected(teal.transform::variable_choices( + "ADLB", + "AVALU" + ), "AVALU", fixed = TRUE), + paramcd = teal.transform::choices_selected(teal.transform::variable_choices( + "ADLB", + "PARAMCD" + ), "PARAMCD", fixed = TRUE), + param = teal.transform::choices_selected( + teal.transform::value_choices("ADLB", "PARAMCD", "PARAM"), + "ALT" + ), + conf_level = teal.transform::choices_selected(c(0.95, 0.9, 0.8), 0.95, + keep_order = + TRUE + ), + interval = "mean_ci", + mid = "mean", + whiskers = c("mean_ci_lwr", "mean_ci_upr"), + table = c("n", "mean_sd", "median", "range"), + mid_type = "pl", + mid_point_size = c(2, 1, 5), + table_font_size = c(4, 2, 6), + plot_height = c(1000L, 200L, 4000L), + plot_width = NULL, + pre_output = NULL, + post_output = NULL, + ggplot2_args = teal.widgets::ggplot2_args() + ) ), timeout = 30000 ) @@ -70,7 +72,7 @@ testthat::test_that("e2e - tm_g_lineplot: Module initializes in teal without err app_driver$expect_no_validation_error() testthat::expect_true( - app_driver$is_visible(app_driver$active_module_element("myplot-plot_main")) + app_driver$is_visible(app_driver$namespaces(TRUE)$module("myplot-plot_main")) ) app_driver$stop() @@ -133,7 +135,7 @@ testthat::test_that("e2e - tm_g_lineplot: Deselecting param throws validation er app_driver$set_active_module_input("param-dataset_ADLB_singleextract-filter1-vals", NULL) testthat::expect_identical(app_driver$get_active_module_plot_output("myplot"), character(0)) testthat::expect_identical( - app_driver$active_module_element_text("param-dataset_ADLB_singleextract-filter1-vals_input > div > span"), + app_driver$namespaces(TRUE)$module("param-dataset_ADLB_singleextract-filter1-vals_input > div > span"), "Please select Biomarker filter." ) app_driver$expect_validation_error() @@ -166,7 +168,7 @@ testthat::test_that("e2e - tm_g_lineplot: Deselecting group_var throws validatio app_driver$set_active_module_input("group_var-dataset_ADSL_singleextract-select", NULL) testthat::expect_identical(app_driver$get_active_module_plot_output("myplot"), character(0)) testthat::expect_identical( - app_driver$active_module_element_text( + app_driver$namespaces(TRUE)$module( "group_var-dataset_ADSL_singleextract-select_input > div > span" ), "Please select a treatment variable" @@ -198,7 +200,7 @@ testthat::test_that("e2e - tm_g_lineplot: Deselecting y throws validation error. app_driver$set_active_module_input("y-dataset_ADLB_singleextract-select", NULL) testthat::expect_identical(app_driver$get_active_module_plot_output("myplot"), character(0)) testthat::expect_identical( - app_driver$active_module_element_text( + app_driver$namespaces(TRUE)$module( "y-dataset_ADLB_singleextract-select_input > div > span" ), "Please select an analysis variable" @@ -230,7 +232,7 @@ testthat::test_that("e2e - tm_g_lineplot: Deselecting conf_level validation erro app_driver$set_active_module_input("conf_level", NULL) testthat::expect_identical(app_driver$get_active_module_plot_output("myplot"), character(0)) testthat::expect_identical( - 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$expect_validation_error() diff --git a/tests/testthat/test-shinytest2-tm_g_pp_adverse_events.R b/tests/testthat/test-shinytest2-tm_g_pp_adverse_events.R index 0673136c0..1710eb134 100644 --- a/tests/testthat/test-shinytest2-tm_g_pp_adverse_events.R +++ b/tests/testthat/test-shinytest2-tm_g_pp_adverse_events.R @@ -9,43 +9,45 @@ app_driver_tm_g_pp_adverse_events <- function() { # nolint: object_length. teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[names(data)] init_teal_app_driver( - data = data, - modules = tm_g_pp_adverse_events( - label = "Adverse Events", - dataname = "ADAE", - parentname = "ADSL", - patient_col = "USUBJID", - plot_height = c(600L, 200L, 2000L), - aeterm = choices_selected( - choices = variable_choices(data[["ADAE"]], c("AETERM", "AGEU")), - selected = "AETERM" - ), - tox_grade = choices_selected( - choices = variable_choices(data[["ADAE"]], c("AETOXGR", "COUNTRY")), - selected = "AETOXGR" - ), - causality = choices_selected( - choices = variable_choices(data[["ADAE"]], c("AEREL", "ACTARM")), - selected = "AEREL" - ), - outcome = choices_selected( - choices = variable_choices(data[["ADAE"]], c("AEOUT", "SITEID")), - selected = "AEOUT" - ), - action = choices_selected( - choices = variable_choices(data[["ADAE"]], c("AEACN", "SMQ01NAM")), - selected = "AEACN" - ), - time = choices_selected( - choices = variable_choices(data[["ADAE"]], c("ASTDY", "AGE")), - selected = "ASTDY" - ), - decod = NULL, - font_size = c(12L, 12L, 25L), - plot_width = NULL, - pre_output = NULL, - post_output = NULL, - ggplot2_args = teal.widgets::ggplot2_args() + teal::init( + data = data, + modules = tm_g_pp_adverse_events( + label = "Adverse Events", + dataname = "ADAE", + parentname = "ADSL", + patient_col = "USUBJID", + plot_height = c(600L, 200L, 2000L), + aeterm = choices_selected( + choices = variable_choices(data[["ADAE"]], c("AETERM", "AGEU")), + selected = "AETERM" + ), + tox_grade = choices_selected( + choices = variable_choices(data[["ADAE"]], c("AETOXGR", "COUNTRY")), + selected = "AETOXGR" + ), + causality = choices_selected( + choices = variable_choices(data[["ADAE"]], c("AEREL", "ACTARM")), + selected = "AEREL" + ), + outcome = choices_selected( + choices = variable_choices(data[["ADAE"]], c("AEOUT", "SITEID")), + selected = "AEOUT" + ), + action = choices_selected( + choices = variable_choices(data[["ADAE"]], c("AEACN", "SMQ01NAM")), + selected = "AEACN" + ), + time = choices_selected( + choices = variable_choices(data[["ADAE"]], c("ASTDY", "AGE")), + selected = "ASTDY" + ), + decod = NULL, + font_size = c(12L, 12L, 25L), + plot_width = NULL, + pre_output = NULL, + post_output = NULL, + ggplot2_args = teal.widgets::ggplot2_args() + ) ) ) } @@ -60,7 +62,7 @@ testthat::test_that( app_driver$expect_no_validation_error() testthat::expect_match(app_driver$get_active_module_plot_output("chart"), "data:image/png;base64,") testthat::expect_true( - app_driver$is_visible(app_driver$active_module_element("table")) + app_driver$is_visible(app_driver$namespaces(TRUE)$module("table")) ) app_driver$stop() } @@ -157,7 +159,7 @@ testthat::test_that( app_driver$set_active_module_input(input_id, "") app_driver$expect_validation_error() testthat::expect_identical( - app_driver$active_module_element_text(sprintf("%s_input .shiny-validation-message", input_id)), + app_driver$namespaces(TRUE)$module(sprintf("%s_input .shiny-validation-message", input_id)), "Please select a patient" ) app_driver$stop() @@ -201,7 +203,7 @@ testthat::test_that( app_driver$set_active_module_input(input_id, "") app_driver$expect_validation_error() testthat::expect_identical( - app_driver$active_module_element_text(sprintf("%s_input .shiny-validation-message", input_id)), + app_driver$namespaces(TRUE)$module(sprintf("%s_input .shiny-validation-message", input_id)), "Please select AETERM variable." ) app_driver$stop() @@ -245,7 +247,7 @@ testthat::test_that( app_driver$set_active_module_input(input_id, "") app_driver$expect_validation_error() testthat::expect_identical( - app_driver$active_module_element_text(sprintf("%s_input .shiny-validation-message", input_id)), + app_driver$namespaces(TRUE)$module(sprintf("%s_input .shiny-validation-message", input_id)), "Please select AETOXGR variable." ) app_driver$stop() @@ -289,7 +291,7 @@ testthat::test_that( app_driver$set_active_module_input(input_id, "") app_driver$expect_validation_error() testthat::expect_identical( - app_driver$active_module_element_text(sprintf("%s_input .shiny-validation-message", input_id)), + app_driver$namespaces(TRUE)$module(sprintf("%s_input .shiny-validation-message", input_id)), "Please select AEREL variable." ) app_driver$stop() @@ -333,7 +335,7 @@ testthat::test_that( app_driver$set_active_module_input(input_id, "") app_driver$expect_validation_error() testthat::expect_identical( - app_driver$active_module_element_text(sprintf("%s_input .shiny-validation-message", input_id)), + app_driver$namespaces(TRUE)$module(sprintf("%s_input .shiny-validation-message", input_id)), "Please select AEOUT variable." ) app_driver$stop() @@ -377,7 +379,7 @@ testthat::test_that( app_driver$set_active_module_input(input_id, "") app_driver$expect_validation_error() testthat::expect_identical( - app_driver$active_module_element_text(sprintf("%s_input .shiny-validation-message", input_id)), + app_driver$namespaces(TRUE)$module(sprintf("%s_input .shiny-validation-message", input_id)), "Please select AEACN variable." ) app_driver$stop() @@ -421,7 +423,7 @@ testthat::test_that( app_driver$set_active_module_input(input_id, "") app_driver$expect_validation_error() testthat::expect_identical( - app_driver$active_module_element_text(sprintf("%s_input .shiny-validation-message", input_id)), + app_driver$namespaces(TRUE)$module(sprintf("%s_input .shiny-validation-message", input_id)), "Please select ASTDY variable." ) app_driver$stop() diff --git a/tests/testthat/test-shinytest2-tm_g_pp_patient_timeline.R b/tests/testthat/test-shinytest2-tm_g_pp_patient_timeline.R index 42c04978a..adc77e528 100644 --- a/tests/testthat/test-shinytest2-tm_g_pp_patient_timeline.R +++ b/tests/testthat/test-shinytest2-tm_g_pp_patient_timeline.R @@ -27,59 +27,61 @@ app_driver_tm_g_pp_patient_timeline <- function() { # nolint object_length. teal.data::join_keys(data)["ADAE", "ADCM"] <- c("STUDYID", "USUBJID") init_teal_app_driver( - data = data, - modules = tm_g_pp_patient_timeline( - label = "Patient Timeline", - dataname_adae = "ADAE", - dataname_adcm = "ADCM", - parentname = "ADSL", - patient_col = "USUBJID", - plot_height = c(600L, 200L, 2000L), - cmdecod = teal.transform::choices_selected( - choices = teal.transform::variable_choices(data[["ADCM"]], c("CMDECOD", "CMCAT")), - selected = "CMDECOD" - ), - aeterm = teal.transform::choices_selected( - choices = teal.transform::variable_choices(data[["ADAE"]], c("AETERM", "AESOC")), - selected = "AETERM" - ), - aetime_start = teal.transform::choices_selected( - choices = teal.transform::variable_choices(data[["ADAE"]], c("ASTDTM", "TRTSDTM")), - selected = "ASTDTM" - ), - aetime_end = teal.transform::choices_selected( - choices = teal.transform::variable_choices(data[["ADAE"]], c("AENDTM", "EOSDT")), - selected = "AENDTM" - ), - dstime_start = teal.transform::choices_selected( - choices = teal.transform::variable_choices(data[["ADCM"]], c("CMASTDTM", "TRTEDTM")), - selected = "CMASTDTM" - ), - dstime_end = teal.transform::choices_selected( - choices = teal.transform::variable_choices(data[["ADCM"]], c("CMAENDTM", "TRTEDTM")), - selected = "CMAENDTM" - ), - aerelday_start = teal.transform::choices_selected( - choices = teal.transform::variable_choices(data[["ADAE"]], c("ASTDY", "AENDY")), - selected = "ASTDY" - ), - aerelday_end = teal.transform::choices_selected( - choices = teal.transform::variable_choices(data[["ADAE"]], c("AENDY", "ASTDY")), - selected = "AENDY" - ), - dsrelday_start = teal.transform::choices_selected( - choices = teal.transform::variable_choices(data[["ADCM"]], c("ASTDY", "AENDY")), - selected = "ASTDY" - ), - dsrelday_end = teal.transform::choices_selected( - choices = teal.transform::variable_choices(data[["ADCM"]], c("AENDY", "ASTDY")), - selected = "AENDY" - ), - font_size = c(12L, 12L, 25L), - plot_width = NULL, - pre_output = NULL, - post_output = NULL, - ggplot2_args = teal.widgets::ggplot2_args() + teal::init( + data = data, + modules = tm_g_pp_patient_timeline( + label = "Patient Timeline", + dataname_adae = "ADAE", + dataname_adcm = "ADCM", + parentname = "ADSL", + patient_col = "USUBJID", + plot_height = c(600L, 200L, 2000L), + cmdecod = teal.transform::choices_selected( + choices = teal.transform::variable_choices(data[["ADCM"]], c("CMDECOD", "CMCAT")), + selected = "CMDECOD" + ), + aeterm = teal.transform::choices_selected( + choices = teal.transform::variable_choices(data[["ADAE"]], c("AETERM", "AESOC")), + selected = "AETERM" + ), + aetime_start = teal.transform::choices_selected( + choices = teal.transform::variable_choices(data[["ADAE"]], c("ASTDTM", "TRTSDTM")), + selected = "ASTDTM" + ), + aetime_end = teal.transform::choices_selected( + choices = teal.transform::variable_choices(data[["ADAE"]], c("AENDTM", "EOSDT")), + selected = "AENDTM" + ), + dstime_start = teal.transform::choices_selected( + choices = teal.transform::variable_choices(data[["ADCM"]], c("CMASTDTM", "TRTEDTM")), + selected = "CMASTDTM" + ), + dstime_end = teal.transform::choices_selected( + choices = teal.transform::variable_choices(data[["ADCM"]], c("CMAENDTM", "TRTEDTM")), + selected = "CMAENDTM" + ), + aerelday_start = teal.transform::choices_selected( + choices = teal.transform::variable_choices(data[["ADAE"]], c("ASTDY", "AENDY")), + selected = "ASTDY" + ), + aerelday_end = teal.transform::choices_selected( + choices = teal.transform::variable_choices(data[["ADAE"]], c("AENDY", "ASTDY")), + selected = "AENDY" + ), + dsrelday_start = teal.transform::choices_selected( + choices = teal.transform::variable_choices(data[["ADCM"]], c("ASTDY", "AENDY")), + selected = "ASTDY" + ), + dsrelday_end = teal.transform::choices_selected( + choices = teal.transform::variable_choices(data[["ADCM"]], c("AENDY", "ASTDY")), + selected = "AENDY" + ), + font_size = c(12L, 12L, 25L), + plot_width = NULL, + pre_output = NULL, + post_output = NULL, + ggplot2_args = teal.widgets::ggplot2_args() + ) ) ) } @@ -178,10 +180,10 @@ testthat::test_that( testthat::expect_true( all( - app_driver$is_visible(app_driver$active_module_element("aerelday_start-dataset_ADAE_singleextract-select")), - app_driver$is_visible(app_driver$active_module_element("aerelday_end-dataset_ADAE_singleextract-select")), - app_driver$is_visible(app_driver$active_module_element("dsrelday_start-dataset_ADCM_singleextract-select")), - app_driver$is_visible(app_driver$active_module_element("dsrelday_end-dataset_ADCM_singleextract-select")) + app_driver$is_visible(app_driver$namespaces(TRUE)$module("aerelday_start-dataset_ADAE_singleextract-select")), + app_driver$is_visible(app_driver$namespaces(TRUE)$module("aerelday_end-dataset_ADAE_singleextract-select")), + app_driver$is_visible(app_driver$namespaces(TRUE)$module("dsrelday_start-dataset_ADCM_singleextract-select")), + app_driver$is_visible(app_driver$namespaces(TRUE)$module("dsrelday_end-dataset_ADCM_singleextract-select")) ) ) @@ -189,10 +191,10 @@ testthat::test_that( testthat::expect_false( any( - app_driver$is_visible(app_driver$active_module_element("aerelday_start-dataset_ADAE_singleextract-select")), - app_driver$is_visible(app_driver$active_module_element("aerelday_end-dataset_ADAE_singleextract-select")), - app_driver$is_visible(app_driver$active_module_element("dsrelday_start-dataset_ADCM_singleextract-select")), - app_driver$is_visible(app_driver$active_module_element("dsrelday_end-dataset_ADCM_singleextract-select")) + app_driver$is_visible(app_driver$namespaces(TRUE)$module("aerelday_start-dataset_ADAE_singleextract-select")), + app_driver$is_visible(app_driver$namespaces(TRUE)$module("aerelday_end-dataset_ADAE_singleextract-select")), + app_driver$is_visible(app_driver$namespaces(TRUE)$module("dsrelday_start-dataset_ADCM_singleextract-select")), + app_driver$is_visible(app_driver$namespaces(TRUE)$module("dsrelday_end-dataset_ADCM_singleextract-select")) ) ) @@ -210,10 +212,10 @@ testthat::test_that( testthat::expect_false( any( - app_driver$is_visible(app_driver$active_module_element("aetime_start-dataset_ADAE_singleextract-select")), - app_driver$is_visible(app_driver$active_module_element("aetime_end-dataset_ADAE_singleextract-select")), - app_driver$is_visible(app_driver$active_module_element("dstime_start-dataset_ADCM_singleextract-select")), - app_driver$is_visible(app_driver$active_module_element("dstime_end-dataset_ADCM_singleextract-select")) + app_driver$is_visible(app_driver$namespaces(TRUE)$module("aetime_start-dataset_ADAE_singleextract-select")), + app_driver$is_visible(app_driver$namespaces(TRUE)$module("aetime_end-dataset_ADAE_singleextract-select")), + app_driver$is_visible(app_driver$namespaces(TRUE)$module("dstime_start-dataset_ADCM_singleextract-select")), + app_driver$is_visible(app_driver$namespaces(TRUE)$module("dstime_end-dataset_ADCM_singleextract-select")) ) ) @@ -221,10 +223,10 @@ testthat::test_that( testthat::expect_true( all( - app_driver$is_visible(app_driver$active_module_element("aetime_start-dataset_ADAE_singleextract-select")), - app_driver$is_visible(app_driver$active_module_element("aetime_end-dataset_ADAE_singleextract-select")), - app_driver$is_visible(app_driver$active_module_element("dstime_start-dataset_ADCM_singleextract-select")), - app_driver$is_visible(app_driver$active_module_element("dstime_end-dataset_ADCM_singleextract-select")) + app_driver$is_visible(app_driver$namespaces(TRUE)$module("aetime_start-dataset_ADAE_singleextract-select")), + app_driver$is_visible(app_driver$namespaces(TRUE)$module("aetime_end-dataset_ADAE_singleextract-select")), + app_driver$is_visible(app_driver$namespaces(TRUE)$module("dstime_start-dataset_ADCM_singleextract-select")), + app_driver$is_visible(app_driver$namespaces(TRUE)$module("dstime_end-dataset_ADCM_singleextract-select")) ) ) @@ -258,7 +260,7 @@ testthat::test_that("e2e - tm_g_pp_patient_timeline: Deselecting patient_id colu app_driver$set_active_module_input("patient_id", NULL) testthat::expect_identical(app_driver$get_active_module_plot_output("patient_timeline_plot"), character(0)) testthat::expect_identical( - app_driver$active_module_element_text("patient_id_input > div > span"), + app_driver$namespaces(TRUE)$module("patient_id_input > div > span"), "Please select a patient" ) app_driver$expect_validation_error() @@ -361,7 +363,7 @@ testthat::test_that( app_driver$set_active_module_input("aetime_start-dataset_ADAE_singleextract-select", NULL) testthat::expect_identical(app_driver$get_active_module_plot_output("myplot"), character(0)) testthat::expect_identical( - app_driver$active_module_element_text("aetime_start-dataset_ADAE_singleextract-select_input > div > span"), + app_driver$namespaces(TRUE)$module("aetime_start-dataset_ADAE_singleextract-select_input > div > span"), "Please add AE start date." ) app_driver$expect_validation_error() @@ -399,7 +401,7 @@ testthat::test_that( app_driver$set_active_module_input("aetime_end-dataset_ADAE_singleextract-select", NULL) testthat::expect_identical(app_driver$get_active_module_plot_output("myplot"), character(0)) testthat::expect_identical( - app_driver$active_module_element_text("aetime_end-dataset_ADAE_singleextract-select_input > div > span"), + app_driver$namespaces(TRUE)$module("aetime_end-dataset_ADAE_singleextract-select_input > div > span"), "Please add AE end date." ) app_driver$expect_validation_error() @@ -435,7 +437,7 @@ testthat::test_that( app_driver$set_active_module_input("aerelday_start-dataset_ADAE_singleextract-select", NULL) testthat::expect_identical(app_driver$get_active_module_plot_output("myplot"), character(0)) testthat::expect_identical( - app_driver$active_module_element_text("aerelday_start-dataset_ADAE_singleextract-select_input > div > span"), + app_driver$namespaces(TRUE)$module("aerelday_start-dataset_ADAE_singleextract-select_input > div > span"), "Please add AE start date." ) app_driver$expect_validation_error() @@ -471,7 +473,7 @@ testthat::test_that( app_driver$set_active_module_input("aerelday_end-dataset_ADAE_singleextract-select", NULL) testthat::expect_identical(app_driver$get_active_module_plot_output("myplot"), character(0)) testthat::expect_identical( - app_driver$active_module_element_text("aerelday_end-dataset_ADAE_singleextract-select_input > div > span"), + app_driver$namespaces(TRUE)$module("aerelday_end-dataset_ADAE_singleextract-select_input > div > span"), "Please add AE end date." ) app_driver$expect_validation_error() @@ -509,7 +511,7 @@ testthat::test_that( app_driver$set_active_module_input("dstime_start-dataset_ADCM_singleextract-select", NULL) testthat::expect_identical(app_driver$get_active_module_plot_output("myplot"), character(0)) testthat::expect_identical( - app_driver$active_module_element_text("dstime_start-dataset_ADCM_singleextract-select_input > div > span"), + app_driver$namespaces(TRUE)$module("dstime_start-dataset_ADCM_singleextract-select_input > div > span"), "Please add Medication start date." ) app_driver$expect_validation_error() @@ -547,7 +549,7 @@ testthat::test_that( app_driver$set_active_module_input("dstime_end-dataset_ADCM_singleextract-select", NULL) testthat::expect_identical(app_driver$get_active_module_plot_output("myplot"), character(0)) testthat::expect_identical( - app_driver$active_module_element_text("dstime_end-dataset_ADCM_singleextract-select_input > div > span"), + app_driver$namespaces(TRUE)$module("dstime_end-dataset_ADCM_singleextract-select_input > div > span"), "Please add Medication end date." ) app_driver$expect_validation_error() @@ -583,7 +585,7 @@ testthat::test_that( app_driver$set_active_module_input("dsrelday_start-dataset_ADCM_singleextract-select", NULL) testthat::expect_identical(app_driver$get_active_module_plot_output("myplot"), character(0)) testthat::expect_identical( - app_driver$active_module_element_text("dsrelday_start-dataset_ADCM_singleextract-select_input > div > span"), + app_driver$namespaces(TRUE)$module("dsrelday_start-dataset_ADCM_singleextract-select_input > div > span"), "Please add Medication start date." ) app_driver$expect_validation_error() @@ -619,7 +621,7 @@ testthat::test_that( app_driver$set_active_module_input("dsrelday_end-dataset_ADCM_singleextract-select", NULL) testthat::expect_identical(app_driver$get_active_module_plot_output("myplot"), character(0)) testthat::expect_identical( - app_driver$active_module_element_text("dsrelday_end-dataset_ADCM_singleextract-select_input > div > span"), + app_driver$namespaces(TRUE)$module("dsrelday_end-dataset_ADCM_singleextract-select_input > div > span"), "Please add Medication end date." ) app_driver$expect_validation_error() diff --git a/tests/testthat/test-shinytest2-tm_g_pp_therapy.R b/tests/testthat/test-shinytest2-tm_g_pp_therapy.R index 7b164683c..fdce00290 100644 --- a/tests/testthat/test-shinytest2-tm_g_pp_therapy.R +++ b/tests/testthat/test-shinytest2-tm_g_pp_therapy.R @@ -28,58 +28,60 @@ app_driver_tm_g_pp_therapy <- function() { teal.data::join_keys(data)["ADCM", "ADCM"] <- adcm_keys init_teal_app_driver( - data = data, - modules = tm_g_pp_therapy( - label = "Therapy (e2e)", - dataname = "ADCM", - parentname = "ADSL", - patient_col = "USUBJID", - atirel = choices_selected( - choices = variable_choices("ADCM", c("ATIREL", "ATIREL2")), - selected = "ATIREL2" - ), - cmdecod = choices_selected( - choices = variable_choices("ADCM", c("CMDECOD", "CMDECOD2")), - selected = "CMDECOD2" - ), - cmindc = choices_selected( - choices = variable_choices("ADCM", c("CMINDC", "CMINDC2")), - selected = "CMINDC2" - ), - cmdose = choices_selected( - choices = variable_choices("ADCM", c("CMDOSE", "CMDOSE2")), - selected = "CMDOSE2" - ), - cmtrt = choices_selected( - choices = variable_choices("ADCM", c("CMTRT", "CMTRT2")), - selected = "CMTRT" - ), - cmdosu = choices_selected( - choices = variable_choices("ADCM", c("CMDOSU", "CMDOSU2")), - selected = "CMDOSU2" - ), - cmroute = choices_selected( - choices = variable_choices("ADCM", c("CMROUTE", "CMROUTE2")), - selected = "CMROUTE2" - ), - cmdosfrq = choices_selected( - choices = variable_choices("ADCM", c("CMDOSFRQ", "CMDOSFRQ2")), - selected = "CMDOSFRQ2" - ), - cmstdy = choices_selected( - choices = variable_choices("ADCM", c("ASTDY", "ASTDY2")), - selected = "ASTDY2" - ), - cmendy = choices_selected( - choices = variable_choices("ADCM", c("AENDY", "AENDY2")), - selected = "AENDY2" - ), - font_size = c(12L, 1L, 30L), - plot_height = c(500L, 300L, 2000L), - plot_width = c(1000L, 700L, 2000L), - pre_output = NULL, - post_output = NULL, - ggplot2_args = teal.widgets::ggplot2_args() + teal::init( + data = data, + modules = tm_g_pp_therapy( + label = "Therapy (e2e)", + dataname = "ADCM", + parentname = "ADSL", + patient_col = "USUBJID", + atirel = choices_selected( + choices = variable_choices("ADCM", c("ATIREL", "ATIREL2")), + selected = "ATIREL2" + ), + cmdecod = choices_selected( + choices = variable_choices("ADCM", c("CMDECOD", "CMDECOD2")), + selected = "CMDECOD2" + ), + cmindc = choices_selected( + choices = variable_choices("ADCM", c("CMINDC", "CMINDC2")), + selected = "CMINDC2" + ), + cmdose = choices_selected( + choices = variable_choices("ADCM", c("CMDOSE", "CMDOSE2")), + selected = "CMDOSE2" + ), + cmtrt = choices_selected( + choices = variable_choices("ADCM", c("CMTRT", "CMTRT2")), + selected = "CMTRT" + ), + cmdosu = choices_selected( + choices = variable_choices("ADCM", c("CMDOSU", "CMDOSU2")), + selected = "CMDOSU2" + ), + cmroute = choices_selected( + choices = variable_choices("ADCM", c("CMROUTE", "CMROUTE2")), + selected = "CMROUTE2" + ), + cmdosfrq = choices_selected( + choices = variable_choices("ADCM", c("CMDOSFRQ", "CMDOSFRQ2")), + selected = "CMDOSFRQ2" + ), + cmstdy = choices_selected( + choices = variable_choices("ADCM", c("ASTDY", "ASTDY2")), + selected = "ASTDY2" + ), + cmendy = choices_selected( + choices = variable_choices("ADCM", c("AENDY", "AENDY2")), + selected = "AENDY2" + ), + font_size = c(12L, 1L, 30L), + plot_height = c(500L, 300L, 2000L), + plot_width = c(1000L, 700L, 2000L), + pre_output = NULL, + post_output = NULL, + ggplot2_args = teal.widgets::ggplot2_args() + ) ) ) } @@ -95,10 +97,10 @@ testthat::test_that("e2e - tm_g_pp_therapy: Module initializes in teal without e app_driver$expect_no_validation_error() testthat::expect_true( - app_driver$is_visible(app_driver$active_module_element("therapy_plot-plot_out_main")) + app_driver$is_visible(app_driver$namespaces(TRUE)$module("therapy_plot-plot_out_main")) ) testthat::expect_true( - app_driver$is_visible(app_driver$active_module_element("therapy_table")) + app_driver$is_visible(app_driver$namespaces(TRUE)$module("therapy_table")) ) app_driver$stop() @@ -156,7 +158,7 @@ test_different_selection <- function(input_name, input_id, new_value) { app_driver <- app_driver_tm_g_pp_therapy() plot_before <- list( app_driver$get_active_module_plot_output("therapy_plot"), - app_driver$active_module_element_text("therapy_table") + app_driver$namespaces(TRUE)$module("therapy_table") ) app_driver$set_active_module_input(input_id, new_value) testthat::expect_false( @@ -164,7 +166,7 @@ test_different_selection <- function(input_name, input_id, new_value) { plot_before, list( app_driver$get_active_module_plot_output("therapy_plot"), - app_driver$active_module_element_text("therapy_table") + app_driver$namespaces(TRUE)$module("therapy_table") ) ) ) @@ -214,7 +216,7 @@ test_delection_validation <- function(input_name, input_id, deselect_message) { app_driver$set_active_module_input(input_id, NULL) app_driver$expect_validation_error() testthat::expect_equal( - app_driver$active_module_element_text( + app_driver$namespaces(TRUE)$module( sprintf( "%s_input .shiny-validation-message", input_id diff --git a/tests/testthat/test-shinytest2-tm_g_pp_vitals.R b/tests/testthat/test-shinytest2-tm_g_pp_vitals.R index f28b0e232..d13bb5a20 100644 --- a/tests/testthat/test-shinytest2-tm_g_pp_vitals.R +++ b/tests/testthat/test-shinytest2-tm_g_pp_vitals.R @@ -6,29 +6,31 @@ app_driver_tm_g_pp_vitals <- function() { teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[names(data)] init_teal_app_driver( - data = data, - modules = tm_g_pp_vitals( - label = "Vitals", - dataname = "ADVS", - parentname = "ADSL", - patient_col = "USUBJID", - plot_height = c(600L, 200L, 2000L), - paramcd = teal.transform::choices_selected( - choices = teal.transform::variable_choices(data[["ADVS"]], c("PARAMCD", "PARAM")), - selected = "PARAMCD" - ), - xaxis = teal.transform::choices_selected( - choices = teal.transform::variable_choices(data[["ADVS"]], c("ADY", "BMRKR1")), - selected = "ADY" - ), - aval_var = teal.transform::choices_selected( - choices = teal.transform::variable_choices(data[["ADVS"]], c("AVAL", "BASE2")), - selected = "AVAL" - ), - plot_width = NULL, - pre_output = NULL, - post_output = NULL, - ggplot2_args = teal.widgets::ggplot2_args() + teal::init( + data = data, + modules = tm_g_pp_vitals( + label = "Vitals", + dataname = "ADVS", + parentname = "ADSL", + patient_col = "USUBJID", + plot_height = c(600L, 200L, 2000L), + paramcd = teal.transform::choices_selected( + choices = teal.transform::variable_choices(data[["ADVS"]], c("PARAMCD", "PARAM")), + selected = "PARAMCD" + ), + xaxis = teal.transform::choices_selected( + choices = teal.transform::variable_choices(data[["ADVS"]], c("ADY", "BMRKR1")), + selected = "ADY" + ), + aval_var = teal.transform::choices_selected( + choices = teal.transform::variable_choices(data[["ADVS"]], c("AVAL", "BASE2")), + selected = "AVAL" + ), + plot_width = NULL, + pre_output = NULL, + post_output = NULL, + ggplot2_args = teal.widgets::ggplot2_args() + ) ) ) } @@ -42,7 +44,7 @@ testthat::test_that("e2e - tm_g_pp_vitals: Module initializes in teal without er testthat::expect_match( app_driver$get_attr( - app_driver$active_module_element("vitals_plot-plot_main > img"), + app_driver$namespaces(TRUE)$module("vitals_plot-plot_main > img"), "src" ), "data:image/png;base64," @@ -113,7 +115,7 @@ testthat::test_that("e2e - tm_g_pp_vitals: Deselecting patient_id column throws app_driver$set_active_module_input("patient_id", NULL) testthat::expect_identical(app_driver$get_active_module_plot_output("vitals_plot"), character(0)) testthat::expect_identical( - app_driver$active_module_element_text("patient_id_input > div > span"), + app_driver$namespaces(TRUE)$module("patient_id_input > div > span"), "Please select a patient." ) app_driver$expect_validation_error() @@ -135,7 +137,7 @@ testthat::test_that( # Expecting validation error on empty PARAMCD levels input app_driver$expect_validation_error() testthat::expect_identical( - app_driver$active_module_element_text("paramcd_levels > div > span"), + app_driver$namespaces(TRUE)$module("paramcd_levels > div > span"), "Please select PARAMCD variable levels." ) @@ -167,7 +169,7 @@ testthat::test_that("e2e - tm_g_pp_vitals: Deselecting paramcd throws validation app_driver$set_active_module_input("paramcd-dataset_ADVS_singleextract-select", NULL) testthat::expect_identical(app_driver$get_active_module_plot_output("vitals_plot"), character(0)) testthat::expect_identical( - app_driver$active_module_element_text("paramcd-dataset_ADVS_singleextract-select_input > div > span"), + app_driver$namespaces(TRUE)$module("paramcd-dataset_ADVS_singleextract-select_input > div > span"), "Please select PARAMCD variable." ) app_driver$expect_validation_error() @@ -197,7 +199,7 @@ testthat::test_that("e2e - tm_g_pp_vitals: Deselecting xaxis column throws valid app_driver$set_active_module_input("xaxis-dataset_ADVS_singleextract-select", NULL) testthat::expect_identical(app_driver$get_active_module_plot_output("vitals_plot"), character(0)) testthat::expect_identical( - app_driver$active_module_element_text("xaxis-dataset_ADVS_singleextract-select_input > div > span"), + app_driver$namespaces(TRUE)$module("xaxis-dataset_ADVS_singleextract-select_input > div > span"), "Please select Vitals x-axis variable." ) app_driver$expect_validation_error() @@ -227,7 +229,7 @@ testthat::test_that("e2e - tm_g_pp_vitals: Deselecting aval_var column throws va app_driver$set_active_module_input("aval_var-dataset_ADVS_singleextract-select", NULL) testthat::expect_identical(app_driver$get_active_module_plot_output("vitals_plot"), character(0)) testthat::expect_identical( - app_driver$active_module_element_text("aval_var-dataset_ADVS_singleextract-select_input > div > span"), + app_driver$namespaces(TRUE)$module("aval_var-dataset_ADVS_singleextract-select_input > div > span"), "Please select AVAL variable." ) app_driver$expect_validation_error() diff --git a/tests/testthat/test-shinytest2-tm_t_abnormality.R b/tests/testthat/test-shinytest2-tm_t_abnormality.R index 0f3ae2660..4af5871f1 100644 --- a/tests/testthat/test-shinytest2-tm_t_abnormality.R +++ b/tests/testthat/test-shinytest2-tm_t_abnormality.R @@ -15,47 +15,49 @@ app_driver_tm_t_abnormality <- function() { teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[names(data)] init_teal_app_driver( - data = data, - modules = tm_t_abnormality( - label = "Abnormality Table", - dataname = "ADLB", - parentname = "ADSL", - arm_var = teal.transform::choices_selected( - choices = teal.transform::variable_choices(data[["ADSL"]], subset = c("ARM", "ARMCD")), - selected = "ARM" - ), - add_total = FALSE, - by_vars = teal.transform::choices_selected( - choices = teal.transform::variable_choices(data[["ADLB"]], subset = c("LBCAT", "PARAM", "AVISIT")), - selected = c("LBCAT", "PARAM"), - keep_order = TRUE - ), - baseline_var = teal.transform::choices_selected( - teal.transform::variable_choices(data[["ADLB"]], subset = "BNRIND"), - selected = "BNRIND", fixed = TRUE - ), - grade = teal.transform::choices_selected( - choices = teal.transform::variable_choices(data[["ADLB"]], subset = "ANRIND"), - selected = "ANRIND", - fixed = TRUE - ), - abnormal = list(low = "LOW", high = "HIGH"), - id_var = teal.transform::choices_selected( - teal.transform::variable_choices(data[["ADLB"]], subset = "USUBJID"), - selected = "USUBJID", fixed = TRUE - ), - exclude_base_abn = FALSE, - treatment_flag_var = teal.transform::choices_selected( - teal.transform::variable_choices(data[["ADLB"]], subset = "ONTRTFL"), - selected = "ONTRTFL", fixed = TRUE - ), - treatment_flag = teal.transform::choices_selected("Y"), - total_label = default_total_label(), - drop_arm_levels = TRUE, - pre_output = NULL, - post_output = NULL, - na_level = default_na_str(), - basic_table_args = teal.widgets::basic_table_args() + teal::init( + data = data, + modules = tm_t_abnormality( + label = "Abnormality Table", + dataname = "ADLB", + parentname = "ADSL", + arm_var = teal.transform::choices_selected( + choices = teal.transform::variable_choices(data[["ADSL"]], subset = c("ARM", "ARMCD")), + selected = "ARM" + ), + add_total = FALSE, + by_vars = teal.transform::choices_selected( + choices = teal.transform::variable_choices(data[["ADLB"]], subset = c("LBCAT", "PARAM", "AVISIT")), + selected = c("LBCAT", "PARAM"), + keep_order = TRUE + ), + baseline_var = teal.transform::choices_selected( + teal.transform::variable_choices(data[["ADLB"]], subset = "BNRIND"), + selected = "BNRIND", fixed = TRUE + ), + grade = teal.transform::choices_selected( + choices = teal.transform::variable_choices(data[["ADLB"]], subset = "ANRIND"), + selected = "ANRIND", + fixed = TRUE + ), + abnormal = list(low = "LOW", high = "HIGH"), + id_var = teal.transform::choices_selected( + teal.transform::variable_choices(data[["ADLB"]], subset = "USUBJID"), + selected = "USUBJID", fixed = TRUE + ), + exclude_base_abn = FALSE, + treatment_flag_var = teal.transform::choices_selected( + teal.transform::variable_choices(data[["ADLB"]], subset = "ONTRTFL"), + selected = "ONTRTFL", fixed = TRUE + ), + treatment_flag = teal.transform::choices_selected("Y"), + total_label = default_total_label(), + drop_arm_levels = TRUE, + pre_output = NULL, + post_output = NULL, + na_level = default_na_str(), + basic_table_args = teal.widgets::basic_table_args() + ) ) ) } @@ -68,7 +70,7 @@ testthat::test_that("e2e - tm_t_abnormality: Module initializes in teal without app_driver$expect_no_validation_error() testthat::expect_true( - app_driver$is_visible(app_driver$active_module_element("table-table-with-settings")) + app_driver$is_visible(app_driver$namespaces(TRUE)$module("table-table-with-settings")) ) app_driver$stop() }) @@ -135,7 +137,7 @@ testthat::test_that("e2e - arm_var: Deselection of arm_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("arm_var-dataset_ADSL_singleextract-select_input .shiny-validation-message"), + app_driver$namespaces(TRUE)$module("arm_var-dataset_ADSL_singleextract-select_input .shiny-validation-message"), "Please select a treatment variable." ) app_driver$stop() @@ -168,7 +170,7 @@ testthat::test_that("e2e - tm_t_abnormality: Deselection of by_vars throws valid 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("by_vars-dataset_ADLB_singleextract-select_input .shiny-validation-message"), + app_driver$namespaces(TRUE)$module("by_vars-dataset_ADLB_singleextract-select_input .shiny-validation-message"), "Please select a Row By Variable." ) app_driver$stop() diff --git a/tests/testthat/test-shinytest2-tm_t_abnormality_by_worst_grade.R b/tests/testthat/test-shinytest2-tm_t_abnormality_by_worst_grade.R index 01814b4bf..b5401fba8 100644 --- a/tests/testthat/test-shinytest2-tm_t_abnormality_by_worst_grade.R +++ b/tests/testthat/test-shinytest2-tm_t_abnormality_by_worst_grade.R @@ -9,46 +9,48 @@ app_driver_tm_t_abnormality_by_worst_grade <- function() { # nolint: object_leng teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[names(data)] init_teal_app_driver( - data = data, - modules = tm_t_abnormality_by_worst_grade( - label = "Laboratory Test Results with Highest Grade Post-Baseline", - dataname = "ADLB", - parentname = "ADSL", - arm_var = teal.transform::choices_selected( - choices = teal.transform::variable_choices(data[["ADSL"]], subset = c("ARM", "ARMCD")), - selected = "ARM" + teal::init( + data = data, + modules = tm_t_abnormality_by_worst_grade( + label = "Laboratory Test Results with Highest Grade Post-Baseline", + dataname = "ADLB", + parentname = "ADSL", + arm_var = teal.transform::choices_selected( + choices = teal.transform::variable_choices(data[["ADSL"]], subset = c("ARM", "ARMCD")), + selected = "ARM" + ), + id_var = teal.transform::choices_selected( + teal.transform::variable_choices(data[["ADLB"]], subset = "USUBJID"), + selected = "USUBJID", fixed = TRUE + ), + paramcd = teal.transform::choices_selected( + choices = teal.transform::value_choices(data[["ADLB"]], "PARAMCD", "PARAM"), + selected = c("ALT", "CRP", "IGA") + ), + add_total = FALSE, + atoxgr_var = teal.transform::choices_selected( + teal.transform::variable_choices(data[["ADLB"]], subset = "ATOXGR"), + selected = "ATOXGR", fixed = TRUE + ), + worst_high_flag_var = teal.transform::choices_selected( + teal.transform::variable_choices(data[["ADLB"]], subset = "WGRHIFL"), + selected = "WGRHIFL", fixed = TRUE + ), + worst_low_flag_var = teal.transform::choices_selected( + teal.transform::variable_choices(data[["ADLB"]], subset = "WGRLOFL"), + selected = "WGRLOFL", fixed = TRUE + ), + worst_flag_indicator = teal.transform::choices_selected("Y"), + total_label = default_total_label(), + drop_arm_levels = TRUE, + pre_output = NULL, + post_output = NULL, + basic_table_args = teal.widgets::basic_table_args() ), - id_var = teal.transform::choices_selected( - teal.transform::variable_choices(data[["ADLB"]], subset = "USUBJID"), - selected = "USUBJID", fixed = TRUE - ), - paramcd = teal.transform::choices_selected( - choices = teal.transform::value_choices(data[["ADLB"]], "PARAMCD", "PARAM"), - selected = c("ALT", "CRP", "IGA") - ), - add_total = FALSE, - atoxgr_var = teal.transform::choices_selected( - teal.transform::variable_choices(data[["ADLB"]], subset = "ATOXGR"), - selected = "ATOXGR", fixed = TRUE - ), - worst_high_flag_var = teal.transform::choices_selected( - teal.transform::variable_choices(data[["ADLB"]], subset = "WGRHIFL"), - selected = "WGRHIFL", fixed = TRUE - ), - worst_low_flag_var = teal.transform::choices_selected( - teal.transform::variable_choices(data[["ADLB"]], subset = "WGRLOFL"), - selected = "WGRLOFL", fixed = TRUE - ), - worst_flag_indicator = teal.transform::choices_selected("Y"), - total_label = default_total_label(), - drop_arm_levels = TRUE, - pre_output = NULL, - post_output = NULL, - basic_table_args = teal.widgets::basic_table_args() - ), - filter = teal::teal_slices( - teal_slice("ADSL", "SAFFL", selected = "Y"), - teal_slice("ADLB", "ONTRTFL", selected = "Y") + filter = teal::teal_slices( + teal_slice("ADSL", "SAFFL", selected = "Y"), + teal_slice("ADLB", "ONTRTFL", selected = "Y") + ) ) ) } @@ -63,7 +65,7 @@ testthat::test_that( app_driver$expect_no_validation_error() testthat::expect_true( - app_driver$is_visible(app_driver$active_module_element("table-table-with-settings")) + app_driver$is_visible(app_driver$namespaces(TRUE)$module("table-table-with-settings")) ) app_driver$stop() } @@ -161,7 +163,7 @@ testthat::test_that("e2e - tm_t_abnormality_by_worst_grade: Deselection of arm_v 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 .shiny-validation-message"), + app_driver$namespaces(TRUE)$module("arm_var-dataset_ADSL_singleextract-select_input .shiny-validation-message"), "Please select a treatment variable." ) app_driver$stop() @@ -175,7 +177,7 @@ testthat::test_that("e2e - tm_t_abnormality_by_worst_grade: Deselection of param 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( + app_driver$namespaces(TRUE)$module( "paramcd-dataset_ADLB_singleextract-filter1-vals_input .shiny-validation-message" ), "Please select at least one Laboratory parameter." diff --git a/tests/testthat/test-shinytest2-tm_t_ancova.R b/tests/testthat/test-shinytest2-tm_t_ancova.R index 4d109c4c9..4d80f8cfe 100644 --- a/tests/testthat/test-shinytest2-tm_t_ancova.R +++ b/tests/testthat/test-shinytest2-tm_t_ancova.R @@ -17,42 +17,44 @@ app_driver_tm_t_ancova <- function() { ) init_teal_app_driver( - data = data, - modules = tm_t_ancova( - label = "ANCOVA Table", - dataname = "ADQS", - parentname = "ADSL", - avisit = teal.transform::choices_selected( - choices = teal.transform::value_choices(data[["ADQS"]], "AVISIT"), - selected = "WEEK 1 DAY 8" - ), - arm_var = teal.transform::choices_selected( - choices = teal.transform::variable_choices(data[["ADSL"]], c("ARM", "ACTARMCD", "ARMCD")), - selected = "ARMCD" - ), - arm_ref_comp = arm_ref_comp, - aval_var = teal.transform::choices_selected( - choices = teal.transform::variable_choices(data[["ADQS"]], c("CHG", "AVAL")), - selected = "CHG" - ), - cov_var = teal.transform::choices_selected( - choices = teal.transform::variable_choices(data[["ADQS"]], c("BASE", "STRATA1", "SEX")), - selected = "STRATA1" - ), - paramcd = teal.transform::choices_selected( - choices = teal.transform::value_choices(data[["ADQS"]], "PARAMCD", "PARAM"), - selected = "FKSI-FWB" - ), - interact_var = teal.transform::choices_selected( - choices = teal.transform::variable_choices(data[["ADQS"]], c("BASE", "STRATA1", "SEX")), - selected = "STRATA1" - ), - conf_level = teal.transform::choices_selected(c(2, 0.95, 0.9, 0.8), 0.95, keep_order = TRUE), - include_interact = FALSE, - interact_y = FALSE, - pre_output = NULL, - post_output = NULL, - basic_table_args = teal.widgets::basic_table_args() + teal::init( + data = data, + modules = tm_t_ancova( + label = "ANCOVA Table", + dataname = "ADQS", + parentname = "ADSL", + avisit = teal.transform::choices_selected( + choices = teal.transform::value_choices(data[["ADQS"]], "AVISIT"), + selected = "WEEK 1 DAY 8" + ), + arm_var = teal.transform::choices_selected( + choices = teal.transform::variable_choices(data[["ADSL"]], c("ARM", "ACTARMCD", "ARMCD")), + selected = "ARMCD" + ), + arm_ref_comp = arm_ref_comp, + aval_var = teal.transform::choices_selected( + choices = teal.transform::variable_choices(data[["ADQS"]], c("CHG", "AVAL")), + selected = "CHG" + ), + cov_var = teal.transform::choices_selected( + choices = teal.transform::variable_choices(data[["ADQS"]], c("BASE", "STRATA1", "SEX")), + selected = "STRATA1" + ), + paramcd = teal.transform::choices_selected( + choices = teal.transform::value_choices(data[["ADQS"]], "PARAMCD", "PARAM"), + selected = "FKSI-FWB" + ), + interact_var = teal.transform::choices_selected( + choices = teal.transform::variable_choices(data[["ADQS"]], c("BASE", "STRATA1", "SEX")), + selected = "STRATA1" + ), + conf_level = teal.transform::choices_selected(c(2, 0.95, 0.9, 0.8), 0.95, keep_order = TRUE), + include_interact = FALSE, + interact_y = FALSE, + pre_output = NULL, + post_output = NULL, + basic_table_args = teal.widgets::basic_table_args() + ) ) ) } @@ -64,7 +66,7 @@ testthat::test_that("e2e - tm_t_ancova: Module initializes in teal without error 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")) + app_driver$is_visible(app_driver$namespaces(TRUE)$module("table-table-with-settings")) ) app_driver$stop() }) @@ -156,7 +158,7 @@ testthat::test_that("e2e - tm_t_ancova: Deselection of avisit 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( + app_driver$namespaces(TRUE)$module( "avisit-dataset_ADQS_singleextract-filter1-vals_input .shiny-validation-message" ), "`Analysis Visit` field cannot be empty." @@ -191,7 +193,7 @@ testthat::test_that("e2e - tm_t_ancova: Deselection of paramcd 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( + app_driver$namespaces(TRUE)$module( "paramcd-dataset_ADQS_singleextract-filter1-vals_input .shiny-validation-message" ), "`Select Endpoint` is not selected." @@ -226,7 +228,7 @@ testthat::test_that("e2e - tm_t_ancova: Deselection of aval_var throws validatio 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("aval_var-dataset_ADQS_singleextract-select_input .shiny-validation-message"), + app_driver$namespaces(TRUE)$module("aval_var-dataset_ADQS_singleextract-select_input .shiny-validation-message"), "Analysis variable cannot be empty." ) app_driver$stop() @@ -259,7 +261,7 @@ testthat::test_that("e2e - tm_t_ancova: Deselection of arm_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("arm_var-dataset_ADSL_singleextract-select_input .shiny-validation-message"), + app_driver$namespaces(TRUE)$module("arm_var-dataset_ADSL_singleextract-select_input .shiny-validation-message"), "Treatment variable must be selected" ) app_driver$stop() diff --git a/tests/testthat/test-shinytest2-tm_t_binary_outcome.R b/tests/testthat/test-shinytest2-tm_t_binary_outcome.R index 58ef2f22d..f903ab367 100644 --- a/tests/testthat/test-shinytest2-tm_t_binary_outcome.R +++ b/tests/testthat/test-shinytest2-tm_t_binary_outcome.R @@ -17,72 +17,74 @@ app_driver_tm_t_binary_outcome <- function() { ) init_teal_app_driver( - data = data, - modules = tm_t_binary_outcome( - label = "Responders", - dataname = "ADRS", - parentname = "ADSL", - arm_var = teal.transform::choices_selected( - choices = teal.transform::variable_choices(data[["ADRS"]], c("ARM", "ARMCD", "ACTARMCD")), - selected = "ARM" - ), - arm_ref_comp = arm_ref_comp, - paramcd = teal.transform::choices_selected( - choices = teal.transform::value_choices(data[["ADRS"]], "PARAMCD", "PARAM"), - selected = "BESRSPI" - ), - strata_var = teal.transform::choices_selected( - choices = teal.transform::variable_choices(data[["ADRS"]], c("SEX", "BMRKR2", "RACE")), - selected = "RACE" - ), - aval_var = teal.transform::choices_selected( - choices = teal.transform::variable_choices( - data[["ADRS"]], c("AVALC", "SEX") + teal::init( + data = data, + modules = tm_t_binary_outcome( + label = "Responders", + dataname = "ADRS", + parentname = "ADSL", + arm_var = teal.transform::choices_selected( + choices = teal.transform::variable_choices(data[["ADRS"]], c("ARM", "ARMCD", "ACTARMCD")), + selected = "ARM" ), - selected = "AVALC", - fixed = FALSE - ), - conf_level = teal.transform::choices_selected( - c(2, 0.95, 0.9, 0.8), 0.95, - keep_order = TRUE - ), - default_responses = list( - BESRSPI = list( - rsp = c("Complete Response (CR)", "Partial Response (PR)"), - levels = c( - "Complete Response (CR)", "Partial Response (PR)", - "Stable Disease (SD)", "Progressive Disease (PD)" - ) + arm_ref_comp = arm_ref_comp, + paramcd = teal.transform::choices_selected( + choices = teal.transform::value_choices(data[["ADRS"]], "PARAMCD", "PARAM"), + selected = "BESRSPI" + ), + strata_var = teal.transform::choices_selected( + choices = teal.transform::variable_choices(data[["ADRS"]], c("SEX", "BMRKR2", "RACE")), + selected = "RACE" + ), + aval_var = teal.transform::choices_selected( + choices = teal.transform::variable_choices( + data[["ADRS"]], c("AVALC", "SEX") + ), + selected = "AVALC", + fixed = FALSE ), - INVET = list( - rsp = c("Stable Disease (SD)", "Not Evaluable (NE)"), - levels = c( - "Complete Response (CR)", "Not Evaluable (NE)", "Partial Response (PR)", - "Progressive Disease (PD)", "Stable Disease (SD)" + conf_level = teal.transform::choices_selected( + c(2, 0.95, 0.9, 0.8), 0.95, + keep_order = TRUE + ), + default_responses = list( + BESRSPI = list( + rsp = c("Complete Response (CR)", "Partial Response (PR)"), + levels = c( + "Complete Response (CR)", "Partial Response (PR)", + "Stable Disease (SD)", "Progressive Disease (PD)" + ) + ), + INVET = list( + rsp = c("Stable Disease (SD)", "Not Evaluable (NE)"), + levels = c( + "Complete Response (CR)", "Not Evaluable (NE)", "Partial Response (PR)", + "Progressive Disease (PD)", "Stable Disease (SD)" + ) + ), + OVRINV = list( + rsp = c("Progressive Disease (PD)", "Stable Disease (SD)"), + levels = c("Progressive Disease (PD)", "Stable Disease (SD)", "Not Evaluable (NE)") ) ), - OVRINV = list( - rsp = c("Progressive Disease (PD)", "Stable Disease (SD)"), - levels = c("Progressive Disease (PD)", "Stable Disease (SD)", "Not Evaluable (NE)") - ) - ), - rsp_table = FALSE, - control = list(global = list( - method = "waldcc", - conf_level = 0.95 - ), unstrat = list( - method_ci = "waldcc", - method_test = "schouten", odds = TRUE - ), strat = list( - method_ci = "cmh", method_test = - "cmh" - )), - add_total = FALSE, - total_label = default_total_label(), - na_level = default_na_str(), - pre_output = NULL, - post_output = NULL, - basic_table_args = teal.widgets::basic_table_args() + rsp_table = FALSE, + control = list(global = list( + method = "waldcc", + conf_level = 0.95 + ), unstrat = list( + method_ci = "waldcc", + method_test = "schouten", odds = TRUE + ), strat = list( + method_ci = "cmh", method_test = + "cmh" + )), + add_total = FALSE, + total_label = default_total_label(), + na_level = default_na_str(), + pre_output = NULL, + post_output = NULL, + basic_table_args = teal.widgets::basic_table_args() + ) ) ) } @@ -94,7 +96,7 @@ testthat::test_that("e2e - tm_t_binary_outcome: Module initializes in teal witho 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")) + app_driver$is_visible(app_driver$namespaces(TRUE)$module("table-table-with-settings")) ) app_driver$stop() }) @@ -194,7 +196,7 @@ testthat::test_that("e2e - tm_t_binary_outcome: Deselection of paramcd throws va 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( + app_driver$namespaces(TRUE)$module( "paramcd-dataset_ADRS_singleextract-filter1-vals_input .shiny-validation-message" ), "Please select a filter." @@ -262,7 +264,7 @@ testthat::test_that("e2e - tm_t_binary_outcome: Deselection of arm_var throws va 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 .shiny-validation-message"), + app_driver$namespaces(TRUE)$module("arm_var-dataset_ADSL_singleextract-select_input .shiny-validation-message"), "Treatment variable must be selected" ) app_driver$stop() diff --git a/tests/testthat/test-shinytest2-tm_t_coxreg.R b/tests/testthat/test-shinytest2-tm_t_coxreg.R index 6b4303b5c..37713278e 100644 --- a/tests/testthat/test-shinytest2-tm_t_coxreg.R +++ b/tests/testthat/test-shinytest2-tm_t_coxreg.R @@ -19,39 +19,41 @@ app_driver_tm_t_coxreg <- function() { ) init_teal_app_driver( - data = data, - modules = tm_t_coxreg( - label = "Cox Reg.", - dataname = "ADTTE", - parentname = "ADSL", - arm_var = teal.transform::choices_selected(c("ARM", "ARMCD", "ACTARMCD"), "ARM"), - arm_ref_comp = arm_ref_comp, - paramcd = teal.transform::choices_selected( - teal.transform::value_choices(data[["ADTTE"]], "PARAMCD", "PARAM"), "OS" - ), - strata_var = teal.transform::choices_selected( - c("COUNTRY", "STRATA1", "STRATA2"), "STRATA1" - ), - cov_var = teal.transform::choices_selected( - c("AGE", "BMRKR1", "BMRKR2", "REGION1"), "AGE" - ), - multivariate = TRUE, - aval_var = teal.transform::choices_selected( - teal.transform::variable_choices(data[["ADTTE"]], "AVAL"), "AVAL", - fixed = TRUE - ), - cnsr_var = teal.transform::choices_selected( - teal.transform::variable_choices(data[["ADTTE"]], "CNSR"), "CNSR", - fixed = TRUE - ), - na_level = default_na_str(), - conf_level = teal.transform::choices_selected(c(0.95, 0.9, 0.8), 0.95, - keep_order = - TRUE - ), - pre_output = NULL, - post_output = NULL, - basic_table_args = teal.widgets::basic_table_args() + teal::init( + data = data, + modules = tm_t_coxreg( + label = "Cox Reg.", + dataname = "ADTTE", + parentname = "ADSL", + arm_var = teal.transform::choices_selected(c("ARM", "ARMCD", "ACTARMCD"), "ARM"), + arm_ref_comp = arm_ref_comp, + paramcd = teal.transform::choices_selected( + teal.transform::value_choices(data[["ADTTE"]], "PARAMCD", "PARAM"), "OS" + ), + strata_var = teal.transform::choices_selected( + c("COUNTRY", "STRATA1", "STRATA2"), "STRATA1" + ), + cov_var = teal.transform::choices_selected( + c("AGE", "BMRKR1", "BMRKR2", "REGION1"), "AGE" + ), + multivariate = TRUE, + aval_var = teal.transform::choices_selected( + teal.transform::variable_choices(data[["ADTTE"]], "AVAL"), "AVAL", + fixed = TRUE + ), + cnsr_var = teal.transform::choices_selected( + teal.transform::variable_choices(data[["ADTTE"]], "CNSR"), "CNSR", + fixed = TRUE + ), + na_level = default_na_str(), + conf_level = teal.transform::choices_selected(c(0.95, 0.9, 0.8), 0.95, + keep_order = + TRUE + ), + pre_output = NULL, + post_output = NULL, + basic_table_args = teal.widgets::basic_table_args() + ) ) ) } @@ -63,7 +65,7 @@ testthat::test_that("e2e - tm_t_coxreg: Module initializes in teal without error 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")) + app_driver$is_visible(app_driver$namespaces(TRUE)$module("table-table-with-settings")) ) app_driver$stop() }) @@ -150,7 +152,7 @@ testthat::test_that("e2e - tm_t_coxreg: Deselection of paramcd 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( + app_driver$namespaces(TRUE)$module( "paramcd-dataset_ADTTE_singleextract-filter1-vals_input .shiny-validation-message" ), "An endpoint is required" @@ -185,7 +187,7 @@ testthat::test_that("e2e - tm_t_coxreg: Deselection of arm_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("arm_var-dataset_ADSL_singleextract-select_input .shiny-validation-message"), + app_driver$namespaces(TRUE)$module("arm_var-dataset_ADSL_singleextract-select_input .shiny-validation-message"), "Treatment variable must be selected" ) app_driver$stop() diff --git a/tests/testthat/test-shinytest2-tm_t_events.R b/tests/testthat/test-shinytest2-tm_t_events.R index 38398ae82..e79edd2af 100644 --- a/tests/testthat/test-shinytest2-tm_t_events.R +++ b/tests/testthat/test-shinytest2-tm_t_events.R @@ -7,33 +7,35 @@ app_driver_tm_t_events <- function() { teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[names(data)] init_teal_app_driver( - data = data, - modules = tm_t_events( - label = "Adverse Event Table", - dataname = "ADAE", - parentname = "ADSL", - arm_var = teal.transform::choices_selected(c("ARM", "ARMCD"), "ARM"), - llt = teal.transform::choices_selected( - choices = teal.transform::variable_choices(data[["ADAE"]], c("AETERM", "AEDECOD")), - selected = c("AEDECOD") - ), - hlt = teal.transform::choices_selected( - choices = teal.transform::variable_choices(data[["ADAE"]], c("AEBODSYS", "AESOC")), - selected = "AEBODSYS" - ), - add_total = TRUE, - event_type = "adverse event", - total_label = default_total_label(), - na_level = default_na_str(), - sort_criteria = c("freq_desc", "alpha"), - sort_freq_col = default_total_label(), - prune_freq = 0, - prune_diff = 0, - drop_arm_levels = TRUE, - incl_overall_sum = TRUE, - pre_output = NULL, - post_output = NULL, - basic_table_args = teal.widgets::basic_table_args() + teal::init( + data = data, + modules = tm_t_events( + label = "Adverse Event Table", + dataname = "ADAE", + parentname = "ADSL", + arm_var = teal.transform::choices_selected(c("ARM", "ARMCD"), "ARM"), + llt = teal.transform::choices_selected( + choices = teal.transform::variable_choices(data[["ADAE"]], c("AETERM", "AEDECOD")), + selected = c("AEDECOD") + ), + hlt = teal.transform::choices_selected( + choices = teal.transform::variable_choices(data[["ADAE"]], c("AEBODSYS", "AESOC")), + selected = "AEBODSYS" + ), + add_total = TRUE, + event_type = "adverse event", + total_label = default_total_label(), + na_level = default_na_str(), + sort_criteria = c("freq_desc", "alpha"), + sort_freq_col = default_total_label(), + prune_freq = 0, + prune_diff = 0, + drop_arm_levels = TRUE, + incl_overall_sum = TRUE, + pre_output = NULL, + post_output = NULL, + basic_table_args = teal.widgets::basic_table_args() + ) ) ) } @@ -45,7 +47,7 @@ testthat::test_that("e2e - tm_t_events: Module initializes in teal without error 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")) + app_driver$is_visible(app_driver$namespaces(TRUE)$module("table-table-with-settings")) ) app_driver$stop() }) @@ -119,7 +121,7 @@ testthat::test_that("e2e - tm_t_events: Deselection of arm_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("arm_var-dataset_ADSL_singleextract-select_input .shiny-validation-message"), + app_driver$namespaces(TRUE)$module("arm_var-dataset_ADSL_singleextract-select_input .shiny-validation-message"), "Please select 1 or 2 treatment variable values" ) app_driver$stop() diff --git a/tests/testthat/test-shinytest2-tm_t_events_by_grade.R b/tests/testthat/test-shinytest2-tm_t_events_by_grade.R index 444232bbf..85ab617e3 100644 --- a/tests/testthat/test-shinytest2-tm_t_events_by_grade.R +++ b/tests/testthat/test-shinytest2-tm_t_events_by_grade.R @@ -12,38 +12,40 @@ app_driver_tm_t_events_by_grade <- function() { # nolint: object_length. teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[names(data)] init_teal_app_driver( - data = data, - modules = tm_t_events_by_grade( - label = "Adverse Events by Grade Table", - dataname = "ADAE", - parentname = "ADSL", - arm_var = teal.transform::choices_selected(c("ARM", "ARMCD"), "ARM"), - llt = teal.transform::choices_selected( - choices = teal.transform::variable_choices(data[["ADAE"]], c("AETERM", "AEDECOD")), - selected = c("AEDECOD") - ), - hlt = teal.transform::choices_selected( - choices = teal.transform::variable_choices(data[["ADAE"]], c("AEBODSYS", "AESOC")), - selected = "AEBODSYS" - ), - grade = teal.transform::choices_selected( - choices = teal.transform::variable_choices(data[["ADAE"]], c("AETOXGR", "AESEV")), - selected = "AETOXGR" - ), - grading_groups = list( - `Any Grade (%)` = c("1", "2", "3", "4", "5"), `Grade 1-2 (%)` = - c("1", "2"), `Grade 3-4 (%)` = c("3", "4"), `Grade 5 (%)` = "5" - ), - col_by_grade = FALSE, - prune_freq = 0, - prune_diff = 0, - add_total = TRUE, - total_label = default_total_label(), - na_level = default_na_str(), - drop_arm_levels = TRUE, - pre_output = NULL, - post_output = NULL, - basic_table_args = teal.widgets::basic_table_args() + teal::init( + data = data, + modules = tm_t_events_by_grade( + label = "Adverse Events by Grade Table", + dataname = "ADAE", + parentname = "ADSL", + arm_var = teal.transform::choices_selected(c("ARM", "ARMCD"), "ARM"), + llt = teal.transform::choices_selected( + choices = teal.transform::variable_choices(data[["ADAE"]], c("AETERM", "AEDECOD")), + selected = c("AEDECOD") + ), + hlt = teal.transform::choices_selected( + choices = teal.transform::variable_choices(data[["ADAE"]], c("AEBODSYS", "AESOC")), + selected = "AEBODSYS" + ), + grade = teal.transform::choices_selected( + choices = teal.transform::variable_choices(data[["ADAE"]], c("AETOXGR", "AESEV")), + selected = "AETOXGR" + ), + grading_groups = list( + `Any Grade (%)` = c("1", "2", "3", "4", "5"), `Grade 1-2 (%)` = + c("1", "2"), `Grade 3-4 (%)` = c("3", "4"), `Grade 5 (%)` = "5" + ), + col_by_grade = FALSE, + prune_freq = 0, + prune_diff = 0, + add_total = TRUE, + total_label = default_total_label(), + na_level = default_na_str(), + drop_arm_levels = TRUE, + pre_output = NULL, + post_output = NULL, + basic_table_args = teal.widgets::basic_table_args() + ) ) ) } @@ -57,7 +59,7 @@ testthat::test_that( 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")) + app_driver$is_visible(app_driver$namespaces(TRUE)$module("table-table-with-settings")) ) app_driver$stop() } @@ -132,7 +134,7 @@ testthat::test_that("e2e - tm_t_events_by_grade: Deselection of arm_var throws v 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 .shiny-validation-message"), + app_driver$namespaces(TRUE)$module("arm_var-dataset_ADSL_singleextract-select_input .shiny-validation-message"), "A treatment variable is required" ) app_driver$stop() @@ -241,7 +243,7 @@ testthat::test_that("e2e - tm_t_events_by_grade: Deselection of grade throws val 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("grade-dataset_ADAE_singleextract-select_input .shiny-validation-message"), + app_driver$namespaces(TRUE)$module("grade-dataset_ADAE_singleextract-select_input .shiny-validation-message"), "An event grade is required" ) app_driver$stop() diff --git a/tests/testthat/test-shinytest2-tm_t_events_patyear.R b/tests/testthat/test-shinytest2-tm_t_events_patyear.R index 1cbf7fec5..aed20ea48 100644 --- a/tests/testthat/test-shinytest2-tm_t_events_patyear.R +++ b/tests/testthat/test-shinytest2-tm_t_events_patyear.R @@ -11,43 +11,45 @@ app_driver_tm_t_events_patyear <- function() { teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[names(data)] init_teal_app_driver( - data = data, - modules = tm_t_events_patyear( - label = "AE Rate Adjusted for Patient-Years At Risk Table", - dataname = "ADAETTE", - parentname = "ADSL", - arm_var = teal.transform::choices_selected( - choices = teal.transform::variable_choices(data[["ADSL"]], c("ARM", "ARMCD", "SEX")), - selected = "ARMCD" - ), - add_total = TRUE, - events_var = teal.transform::choices_selected( - choices = teal.transform::variable_choices(data[["ADAETTE"]], "n_events"), - selected = "n_events", - fixed = TRUE - ), - paramcd = teal.transform::choices_selected( - choices = teal.transform::value_choices(data[["ADAETTE"]], "PARAMCD", "PARAM"), - selected = "AETTE1" - ), - conf_level = teal.transform::choices_selected( - c(2, 0.95, 0.9, 0.8), 0.95, - keep_order = TRUE - ), - aval_var = teal.transform::choices_selected( - choices = teal.transform::variable_choices(data[["ADAETTE"]], "AVAL"), - selected = "AVAL", fixed = TRUE - ), - avalu_var = teal.transform::choices_selected( - choices = teal.transform::variable_choices(data[["ADAETTE"]], "AVALU"), - selected = "AVALU", fixed = TRUE - ), - total_label = default_total_label(), - na_level = default_na_str(), - drop_arm_levels = TRUE, - pre_output = NULL, - post_output = NULL, - basic_table_args = teal.widgets::basic_table_args() + teal::init( + data = data, + modules = tm_t_events_patyear( + label = "AE Rate Adjusted for Patient-Years At Risk Table", + dataname = "ADAETTE", + parentname = "ADSL", + arm_var = teal.transform::choices_selected( + choices = teal.transform::variable_choices(data[["ADSL"]], c("ARM", "ARMCD", "SEX")), + selected = "ARMCD" + ), + add_total = TRUE, + events_var = teal.transform::choices_selected( + choices = teal.transform::variable_choices(data[["ADAETTE"]], "n_events"), + selected = "n_events", + fixed = TRUE + ), + paramcd = teal.transform::choices_selected( + choices = teal.transform::value_choices(data[["ADAETTE"]], "PARAMCD", "PARAM"), + selected = "AETTE1" + ), + conf_level = teal.transform::choices_selected( + c(2, 0.95, 0.9, 0.8), 0.95, + keep_order = TRUE + ), + aval_var = teal.transform::choices_selected( + choices = teal.transform::variable_choices(data[["ADAETTE"]], "AVAL"), + selected = "AVAL", fixed = TRUE + ), + avalu_var = teal.transform::choices_selected( + choices = teal.transform::variable_choices(data[["ADAETTE"]], "AVALU"), + selected = "AVALU", fixed = TRUE + ), + total_label = default_total_label(), + na_level = default_na_str(), + drop_arm_levels = TRUE, + pre_output = NULL, + post_output = NULL, + basic_table_args = teal.widgets::basic_table_args() + ) ) ) } @@ -59,7 +61,7 @@ testthat::test_that("e2e - tm_t_events_patyear: Module initializes in teal witho app_driver$expect_no_shiny_error() app_driver$expect_no_validation_error() testthat::expect_true( - app_driver$is_visible(app_driver$active_module_element("patyear_table-table-with-settings")) + app_driver$is_visible(app_driver$namespaces(TRUE)$module("patyear_table-table-with-settings")) ) app_driver$stop() }) @@ -135,7 +137,7 @@ testthat::test_that("e2e - tm_t_events_patyear: Deselection of paramcd throws va ) app_driver$expect_validation_error() testthat::expect_equal( - app_driver$active_module_element_text( + app_driver$namespaces(TRUE)$module( "paramcd-dataset_ADAETTE_singleextract-filter1-vals_input .shiny-validation-message" ), "A Event Type Parameter is required" @@ -173,7 +175,7 @@ testthat::test_that("e2e - tm_t_events_patyear: Deselection of arm_var throws va ) app_driver$expect_validation_error() testthat::expect_equal( - app_driver$active_module_element_text("arm_var-dataset_ADSL_singleextract-select_input .shiny-validation-message"), + app_driver$namespaces(TRUE)$module("arm_var-dataset_ADSL_singleextract-select_input .shiny-validation-message"), "Please select exactly 1 or 2 treatment variables" ) app_driver$stop() diff --git a/tests/testthat/test-shinytest2-tm_t_events_summary.R b/tests/testthat/test-shinytest2-tm_t_events_summary.R index e56e21b47..a3a08f3f7 100644 --- a/tests/testthat/test-shinytest2-tm_t_events_summary.R +++ b/tests/testthat/test-shinytest2-tm_t_events_summary.R @@ -41,52 +41,54 @@ app_driver_tm_t_events_summary <- function() { teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[names(data)] init_teal_app_driver( - data = data, - modules = tm_t_events_summary( - label = "Adverse Events Summary", - dataname = "ADAE", - parentname = "ADSL", - arm_var = teal.transform::choices_selected( - choices = teal.transform::variable_choices("ADSL", c("ARM", "ARMCD")), - selected = "ARM" - ), - flag_var_anl = teal.transform::choices_selected( - choices = teal.transform::variable_choices("ADAE", data[[".ae_anl_vars"]]), - selected = data[[".ae_anl_vars"]][1], - keep_order = TRUE, - fixed = FALSE - ), - flag_var_aesi = teal.transform::choices_selected( - choices = teal.transform::variable_choices("ADAE", data[[".aesi_vars"]]), - selected = data[[".aesi_vars"]][1], - keep_order = TRUE, - fixed = FALSE - ), - dthfl_var = teal.transform::choices_selected( - choices = teal.transform::variable_choices(data[["ADSL"]], "DTHFL"), - selected = "DTHFL", fixed = TRUE - ), - dcsreas_var = teal.transform::choices_selected( - choices = teal.transform::variable_choices(data[["ADSL"]], "DCSREAS"), - selected = "DCSREAS", fixed = TRUE - ), - llt = teal.transform::choices_selected( - choices = teal.transform::variable_choices(data[["ADAE"]], "AEDECOD"), - selected = "AEDECOD", fixed = TRUE - ), - aeseq_var = teal.transform::choices_selected( - choices = teal.transform::variable_choices(data[["ADAE"]], "AESEQ"), - selected = "AESEQ", fixed = TRUE - ), - add_total = TRUE, - total_label = default_total_label(), - na_level = default_na_str(), - count_subj = TRUE, - count_pt = TRUE, - count_events = TRUE, - pre_output = NULL, - post_output = NULL, - basic_table_args = teal.widgets::basic_table_args() + teal::init( + data = data, + modules = tm_t_events_summary( + label = "Adverse Events Summary", + dataname = "ADAE", + parentname = "ADSL", + arm_var = teal.transform::choices_selected( + choices = teal.transform::variable_choices("ADSL", c("ARM", "ARMCD")), + selected = "ARM" + ), + flag_var_anl = teal.transform::choices_selected( + choices = teal.transform::variable_choices("ADAE", data[[".ae_anl_vars"]]), + selected = data[[".ae_anl_vars"]][1], + keep_order = TRUE, + fixed = FALSE + ), + flag_var_aesi = teal.transform::choices_selected( + choices = teal.transform::variable_choices("ADAE", data[[".aesi_vars"]]), + selected = data[[".aesi_vars"]][1], + keep_order = TRUE, + fixed = FALSE + ), + dthfl_var = teal.transform::choices_selected( + choices = teal.transform::variable_choices(data[["ADSL"]], "DTHFL"), + selected = "DTHFL", fixed = TRUE + ), + dcsreas_var = teal.transform::choices_selected( + choices = teal.transform::variable_choices(data[["ADSL"]], "DCSREAS"), + selected = "DCSREAS", fixed = TRUE + ), + llt = teal.transform::choices_selected( + choices = teal.transform::variable_choices(data[["ADAE"]], "AEDECOD"), + selected = "AEDECOD", fixed = TRUE + ), + aeseq_var = teal.transform::choices_selected( + choices = teal.transform::variable_choices(data[["ADAE"]], "AESEQ"), + selected = "AESEQ", fixed = TRUE + ), + add_total = TRUE, + total_label = default_total_label(), + na_level = default_na_str(), + count_subj = TRUE, + count_pt = TRUE, + count_events = TRUE, + pre_output = NULL, + post_output = NULL, + basic_table_args = teal.widgets::basic_table_args() + ) ) ) } @@ -98,7 +100,7 @@ testthat::test_that("e2e - tm_t_events_summary: Module initializes in teal witho 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")) + app_driver$is_visible(app_driver$namespaces(TRUE)$module("table-table-with-settings")) ) app_driver$stop() }) @@ -161,7 +163,7 @@ testthat::test_that("e2e - tm_t_events_summary: Deselection of arm_var throws va 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 .shiny-validation-message"), + app_driver$namespaces(TRUE)$module("arm_var-dataset_ADSL_singleextract-select_input .shiny-validation-message"), "Please select exactly 1 or 2 treatment variables" ) app_driver$stop() diff --git a/tests/testthat/test-shinytest2-tm_t_exposure.R b/tests/testthat/test-shinytest2-tm_t_exposure.R index 16add7ab3..c6a82894d 100644 --- a/tests/testthat/test-shinytest2-tm_t_exposure.R +++ b/tests/testthat/test-shinytest2-tm_t_exposure.R @@ -21,50 +21,52 @@ app_driver_tm_t_exposure <- function() { teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[names(data)] init_teal_app_driver( - data = data, - modules = tm_t_exposure( - label = "Duration of Exposure Table", - dataname = "ADEX", - parentname = "ADSL", - paramcd = teal.transform::choices_selected( - choices = teal.transform::value_choices(data[["ADEX"]], "PARAMCD", "PARAM"), - selected = "TDURD" + teal::init( + data = data, + modules = tm_t_exposure( + label = "Duration of Exposure Table", + dataname = "ADEX", + parentname = "ADSL", + paramcd = teal.transform::choices_selected( + choices = teal.transform::value_choices(data[["ADEX"]], "PARAMCD", "PARAM"), + selected = "TDURD" + ), + col_by_var = teal.transform::choices_selected( + choices = teal.transform::variable_choices(data[["ADEX"]], subset = c("SEX", "ARM")), + selected = "SEX" + ), + row_by_var = teal.transform::choices_selected( + choices = teal.transform::variable_choices(data[["ADEX"]], subset = c("RACE", "REGION1", "STRATA1", "SEX")), + selected = "RACE" + ), + parcat = teal.transform::choices_selected( + choices = teal.transform::value_choices(data[["ADEX"]], "PARCAT2"), + selected = "Drug A" + ), + add_total = FALSE, + paramcd_label = "PARAM", + id_var = teal.transform::choices_selected( + teal.transform::variable_choices(data[["ADEX"]], subset = "USUBJID"), + selected = "USUBJID", fixed = TRUE + ), + aval_var = teal.transform::choices_selected( + teal.transform::variable_choices(data[["ADEX"]], subset = "AVAL"), + selected = "AVAL", fixed = TRUE + ), + avalu_var = teal.transform::choices_selected( + teal.transform::variable_choices(data[["ADEX"]], subset = "AVALU"), + selected = "AVALU", fixed = TRUE + ), + total_label = default_total_label(), + add_total_row = TRUE, + total_row_label = "Total number of patients and patient time*", + na_level = default_na_str(), + pre_output = NULL, + post_output = NULL, + basic_table_args = teal.widgets::basic_table_args() ), - col_by_var = teal.transform::choices_selected( - choices = teal.transform::variable_choices(data[["ADEX"]], subset = c("SEX", "ARM")), - selected = "SEX" - ), - row_by_var = teal.transform::choices_selected( - choices = teal.transform::variable_choices(data[["ADEX"]], subset = c("RACE", "REGION1", "STRATA1", "SEX")), - selected = "RACE" - ), - parcat = teal.transform::choices_selected( - choices = teal.transform::value_choices(data[["ADEX"]], "PARCAT2"), - selected = "Drug A" - ), - add_total = FALSE, - paramcd_label = "PARAM", - id_var = teal.transform::choices_selected( - teal.transform::variable_choices(data[["ADEX"]], subset = "USUBJID"), - selected = "USUBJID", fixed = TRUE - ), - aval_var = teal.transform::choices_selected( - teal.transform::variable_choices(data[["ADEX"]], subset = "AVAL"), - selected = "AVAL", fixed = TRUE - ), - avalu_var = teal.transform::choices_selected( - teal.transform::variable_choices(data[["ADEX"]], subset = "AVALU"), - selected = "AVALU", fixed = TRUE - ), - total_label = default_total_label(), - add_total_row = TRUE, - total_row_label = "Total number of patients and patient time*", - na_level = default_na_str(), - pre_output = NULL, - post_output = NULL, - basic_table_args = teal.widgets::basic_table_args() - ), - filter = teal::teal_slices(teal_slice("ADSL", "SAFFL", selected = "Y")), + filter = teal::teal_slices(teal_slice("ADSL", "SAFFL", selected = "Y")), + ) ) } @@ -75,7 +77,7 @@ testthat::test_that("e2e - tm_t_exposure: Module initializes in teal without err 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")) + app_driver$is_visible(app_driver$namespaces(TRUE)$module("table-table-with-settings")) ) app_driver$stop() }) @@ -140,7 +142,7 @@ testthat::test_that("e2e - tm_t_exposure: Deselection of paramcd throws validati 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( + app_driver$namespaces(TRUE)$module( "paramcd-dataset_ADEX_singleextract-filter1-vals_input .shiny-validation-message" ), "Please select a parameter value." @@ -175,7 +177,7 @@ testthat::test_that("e2e - tm_t_exposure: Deselection of parcat throws validatio 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( + app_driver$namespaces(TRUE)$module( "parcat-dataset_ADEX_singleextract-filter1-vals_input .shiny-validation-message" ), "Please select a parameter category value." @@ -248,7 +250,7 @@ testthat::test_that("e2e - tm_t_exposure: Deselection of row_by_var throws valid 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( + app_driver$namespaces(TRUE)$module( "row_by_var-dataset_ADEX_singleextract-select_input .shiny-validation-message" ), "Please select a row by variable." diff --git a/tests/testthat/test-shinytest2-tm_t_logistic.R b/tests/testthat/test-shinytest2-tm_t_logistic.R index 44e63021d..89da853d5 100644 --- a/tests/testthat/test-shinytest2-tm_t_logistic.R +++ b/tests/testthat/test-shinytest2-tm_t_logistic.R @@ -20,32 +20,34 @@ app_driver_tm_t_logistic <- function() { ) init_teal_app_driver( - data = data, - modules = tm_t_logistic( - label = "Logistic Regression", - parentname = "ADSL", - dataname = "ADRS", - arm_var = teal.transform::choices_selected( - choices = teal.transform::variable_choices(data[["ADRS"]], c("ARM", "ARMCD")), - selected = "ARM" - ), - arm_ref_comp = arm_ref_comp, - paramcd = teal.transform::choices_selected( - choices = teal.transform::value_choices(data[["ADRS"]], "PARAMCD", "PARAM"), - selected = "BESRSPI" - ), - cov_var = teal.transform::choices_selected( - choices = c("SEX", "AGE", "BMRKR1", "BMRKR2"), - selected = "SEX" - ), - conf_level = teal.transform::choices_selected(c(2, 0.95, 0.9, 0.8), 0.95, keep_order = TRUE), - avalc_var = teal.transform::choices_selected(teal.transform::variable_choices( - data[["ADRS"]], - "AVALC" - ), "AVALC", fixed = TRUE), - pre_output = NULL, - post_output = NULL, - basic_table_args = teal.widgets::basic_table_args() + teal::init( + data = data, + modules = tm_t_logistic( + label = "Logistic Regression", + parentname = "ADSL", + dataname = "ADRS", + arm_var = teal.transform::choices_selected( + choices = teal.transform::variable_choices(data[["ADRS"]], c("ARM", "ARMCD")), + selected = "ARM" + ), + arm_ref_comp = arm_ref_comp, + paramcd = teal.transform::choices_selected( + choices = teal.transform::value_choices(data[["ADRS"]], "PARAMCD", "PARAM"), + selected = "BESRSPI" + ), + cov_var = teal.transform::choices_selected( + choices = c("SEX", "AGE", "BMRKR1", "BMRKR2"), + selected = "SEX" + ), + conf_level = teal.transform::choices_selected(c(2, 0.95, 0.9, 0.8), 0.95, keep_order = TRUE), + avalc_var = teal.transform::choices_selected(teal.transform::variable_choices( + data[["ADRS"]], + "AVALC" + ), "AVALC", fixed = TRUE), + pre_output = NULL, + post_output = NULL, + basic_table_args = teal.widgets::basic_table_args() + ) ) ) } @@ -57,7 +59,7 @@ testthat::test_that("e2e - tm_t_logistic: Module initializes in teal without err 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")) + app_driver$is_visible(app_driver$namespaces(TRUE)$module("table-table-with-settings")) ) app_driver$stop() }) @@ -133,7 +135,7 @@ testthat::test_that("e2e - tm_t_logistic: Deselection of paramcd throws validati 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( + app_driver$namespaces(TRUE)$module( "paramcd-dataset_ADRS_singleextract-filter1-vals_input .shiny-validation-message" ), "`Select Endpoint` field is empty" @@ -168,7 +170,7 @@ testthat::test_that("e2e - tm_t_logistic: Deselection of arm_var throws validati 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 .shiny-validation-message"), + app_driver$namespaces(TRUE)$module("arm_var-dataset_ADSL_singleextract-select_input .shiny-validation-message"), "Treatment variable must be selected" ) app_driver$stop() @@ -201,7 +203,7 @@ testthat::test_that("e2e - tm_t_logistic: Deselection of cov_var throws validati 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("cov_var-dataset_ADRS_singleextract-select_input .shiny-validation-message"), + app_driver$namespaces(TRUE)$module("cov_var-dataset_ADRS_singleextract-select_input .shiny-validation-message"), "`Covariates` field is empty" ) app_driver$stop() diff --git a/tests/testthat/test-shinytest2-tm_t_mult_events.R b/tests/testthat/test-shinytest2-tm_t_mult_events.R index 0e36b00e1..8a06f2dc2 100644 --- a/tests/testthat/test-shinytest2-tm_t_mult_events.R +++ b/tests/testthat/test-shinytest2-tm_t_mult_events.R @@ -9,30 +9,32 @@ app_driver_tm_t_mult_events <- function() { teal.data::join_keys(data) <- keys init_teal_app_driver( - data = data, - modules = tm_t_mult_events( - label = "Concomitant Medications by Medication Class and Preferred Name", - dataname = "ADCM", - parentname = "ADSL", - arm_var = teal.transform::choices_selected(c("ARM", "ARMCD"), "ARM"), - seq_var = teal.transform::choices_selected("CMSEQ", selected = "CMSEQ", fixed = TRUE), - hlt = teal.transform::choices_selected( - choices = teal.transform::variable_choices(data[["ADCM"]], c("ATC1", "ATC2", "ATC3", "ATC4")), - selected = c("ATC1", "ATC2", "ATC3", "ATC4") - ), - llt = teal.transform::choices_selected( - choices = teal.transform::variable_choices(data[["ADCM"]], c("CMDECOD")), - selected = c("CMDECOD") - ), - add_total = TRUE, - event_type = "treatment", - title_text = "Concom. Meds", - total_label = default_total_label(), - na_level = default_na_str(), - drop_arm_levels = TRUE, - pre_output = NULL, - post_output = NULL, - basic_table_args = teal.widgets::basic_table_args() + teal::init( + data = data, + modules = tm_t_mult_events( + label = "Concomitant Medications by Medication Class and Preferred Name", + dataname = "ADCM", + parentname = "ADSL", + arm_var = teal.transform::choices_selected(c("ARM", "ARMCD"), "ARM"), + seq_var = teal.transform::choices_selected("CMSEQ", selected = "CMSEQ", fixed = TRUE), + hlt = teal.transform::choices_selected( + choices = teal.transform::variable_choices(data[["ADCM"]], c("ATC1", "ATC2", "ATC3", "ATC4")), + selected = c("ATC1", "ATC2", "ATC3", "ATC4") + ), + llt = teal.transform::choices_selected( + choices = teal.transform::variable_choices(data[["ADCM"]], c("CMDECOD")), + selected = c("CMDECOD") + ), + add_total = TRUE, + event_type = "treatment", + title_text = "Concom. Meds", + total_label = default_total_label(), + na_level = default_na_str(), + drop_arm_levels = TRUE, + pre_output = NULL, + post_output = NULL, + basic_table_args = teal.widgets::basic_table_args() + ) ) ) } @@ -44,7 +46,7 @@ testthat::test_that("e2e - tm_t_mult_events: Module initializes in teal without 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")) + app_driver$is_visible(app_driver$namespaces(TRUE)$module("table-table-with-settings")) ) app_driver$stop() }) @@ -104,7 +106,7 @@ testthat::test_that("e2e - tm_t_mult_events: Deselection of arm_var throws valid 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 .shiny-validation-message"), + app_driver$namespaces(TRUE)$module("arm_var-dataset_ADSL_singleextract-select_input .shiny-validation-message"), "Please select a treatment variable" ) app_driver$stop() @@ -155,7 +157,7 @@ testthat::test_that("e2e - tm_t_mult_events: Deselection of llt throws validatio app_driver$set_active_module_input("llt-dataset_ADCM_singleextract-select", NULL) app_driver$expect_validation_error() testthat::expect_equal( - app_driver$active_module_element_text("llt-dataset_ADCM_singleextract-select_input .shiny-validation-message"), + app_driver$namespaces(TRUE)$module("llt-dataset_ADCM_singleextract-select_input .shiny-validation-message"), "Please select a \"LOW LEVEL TERM\" variable" ) app_driver$stop() diff --git a/tests/testthat/test-shinytest2-tm_t_pp_basic_info.R b/tests/testthat/test-shinytest2-tm_t_pp_basic_info.R index a96812ba5..2b4608512 100644 --- a/tests/testthat/test-shinytest2-tm_t_pp_basic_info.R +++ b/tests/testthat/test-shinytest2-tm_t_pp_basic_info.R @@ -6,17 +6,19 @@ app_driver_tm_t_pp_basic_info <- function() { teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[names(data)] init_teal_app_driver( - data = data, - modules = tm_t_pp_basic_info( - label = "Basic Info", - dataname = "ADSL", - patient_col = "USUBJID", - vars = teal.transform::choices_selected( - choices = teal.transform::variable_choices(data[["ADSL"]]), - selected = c("ARM", "AGE", "SEX", "COUNTRY", "RACE", "EOSSTT") - ), - pre_output = NULL, - post_output = NULL + teal::init( + data = data, + modules = tm_t_pp_basic_info( + label = "Basic Info", + dataname = "ADSL", + patient_col = "USUBJID", + vars = teal.transform::choices_selected( + choices = teal.transform::variable_choices(data[["ADSL"]]), + selected = c("ARM", "AGE", "SEX", "COUNTRY", "RACE", "EOSSTT") + ), + pre_output = NULL, + post_output = NULL + ) ) ) } @@ -28,7 +30,7 @@ testthat::test_that("e2e - tm_t_pp_basic_info: Module initializes in teal withou app_driver$expect_no_shiny_error() app_driver$expect_no_validation_error() testthat::expect_true( - app_driver$is_visible(app_driver$active_module_element("basic_info_table")) + app_driver$is_visible(app_driver$namespaces(TRUE)$module("basic_info_table")) ) app_driver$stop() }) @@ -80,13 +82,13 @@ testthat::test_that( app_driver$set_active_module_input("patient_id", NULL) testthat::expect_false( app_driver$is_visible( - app_driver$active_module_element("basic_info_table"), + app_driver$namespaces(TRUE)$module("basic_info_table"), visibility_property = TRUE ) ) app_driver$expect_validation_error() testthat::expect_equal( - app_driver$active_module_element_text("patient_id_input .shiny-validation-message"), + app_driver$namespaces(TRUE)$module("patient_id_input .shiny-validation-message"), "Please select a patient" ) app_driver$stop() @@ -122,13 +124,13 @@ testthat::test_that("e2e - tm_t_pp_basic_info: Deselection of cov_var throws val app_driver$set_active_module_input("vars-dataset_ADSL_singleextract-select", NULL) testthat::expect_false( app_driver$is_visible( - app_driver$active_module_element("basic_info_table"), + app_driver$namespaces(TRUE)$module("basic_info_table"), visibility_property = TRUE ) ) app_driver$expect_validation_error() testthat::expect_equal( - app_driver$active_module_element_text("vars-dataset_ADSL_singleextract-select_input .shiny-validation-message"), + app_driver$namespaces(TRUE)$module("vars-dataset_ADSL_singleextract-select_input .shiny-validation-message"), "Please select basic info variables" ) app_driver$stop() diff --git a/tests/testthat/test-shinytest2-tm_t_pp_laboratory.R b/tests/testthat/test-shinytest2-tm_t_pp_laboratory.R index 52e94afc9..46a2b0140 100644 --- a/tests/testthat/test-shinytest2-tm_t_pp_laboratory.R +++ b/tests/testthat/test-shinytest2-tm_t_pp_laboratory.R @@ -7,38 +7,40 @@ app_driver_tm_t_pp_laboratory <- function() { teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[names(data)] init_teal_app_driver( - data = data, - modules = tm_t_pp_laboratory( - label = "Vitals", - dataname = "ADLB", - parentname = "ADSL", - patient_col = "USUBJID", - paramcd = teal.transform::choices_selected( - choices = teal.transform::variable_choices(data[["ADLB"]], c("PARAMCD", "STUDYID")), - selected = "PARAMCD" - ), - param = teal.transform::choices_selected( - choices = teal.transform::variable_choices(data[["ADLB"]], c("PARAM", "SEX")), - selected = "PARAM" - ), - timepoints = teal.transform::choices_selected( - choices = teal.transform::variable_choices(data[["ADLB"]], c("ADY", "AGE")), - selected = "ADY" - ), - anrind = teal.transform::choices_selected( - choices = teal.transform::variable_choices(data[["ADLB"]], c("ANRIND", "AGEU")), - selected = "ANRIND" - ), - aval_var = teal.transform::choices_selected( - choices = teal.transform::variable_choices(data[["ADLB"]], c("AVAL", "AGE")), - selected = "AVAL" - ), - avalu_var = teal.transform::choices_selected( - choices = teal.transform::variable_choices(data[["ADLB"]], c("AVALU", "SEX")), - selected = "AVALU" - ), - pre_output = NULL, - post_output = NULL + teal::init( + data = data, + modules = tm_t_pp_laboratory( + label = "Vitals", + dataname = "ADLB", + parentname = "ADSL", + patient_col = "USUBJID", + paramcd = teal.transform::choices_selected( + choices = teal.transform::variable_choices(data[["ADLB"]], c("PARAMCD", "STUDYID")), + selected = "PARAMCD" + ), + param = teal.transform::choices_selected( + choices = teal.transform::variable_choices(data[["ADLB"]], c("PARAM", "SEX")), + selected = "PARAM" + ), + timepoints = teal.transform::choices_selected( + choices = teal.transform::variable_choices(data[["ADLB"]], c("ADY", "AGE")), + selected = "ADY" + ), + anrind = teal.transform::choices_selected( + choices = teal.transform::variable_choices(data[["ADLB"]], c("ANRIND", "AGEU")), + selected = "ANRIND" + ), + aval_var = teal.transform::choices_selected( + choices = teal.transform::variable_choices(data[["ADLB"]], c("AVAL", "AGE")), + selected = "AVAL" + ), + avalu_var = teal.transform::choices_selected( + choices = teal.transform::variable_choices(data[["ADLB"]], c("AVALU", "SEX")), + selected = "AVALU" + ), + pre_output = NULL, + post_output = NULL + ) ) ) } @@ -50,7 +52,7 @@ testthat::test_that("e2e - tm_t_pp_laboratory: Module initializes in teal withou app_driver$expect_no_shiny_error() app_driver$expect_no_validation_error() testthat::expect_true( - app_driver$is_visible(app_driver$active_module_element("lab_values_table")) + app_driver$is_visible(app_driver$namespaces(TRUE)$module("lab_values_table")) ) app_driver$stop() }) @@ -129,13 +131,13 @@ testthat::test_that("e2e - tm_t_pp_laboratory: Deselection of patient_id throws app_driver$set_active_module_input("patient_id", NULL) testthat::expect_false( app_driver$is_visible( - app_driver$active_module_element("lab_values_table"), + app_driver$namespaces(TRUE)$module("lab_values_table"), visibility_property = TRUE ) ) app_driver$expect_validation_error() testthat::expect_equal( - app_driver$active_module_element_text("patient_id_input .shiny-validation-message"), + app_driver$namespaces(TRUE)$module("patient_id_input .shiny-validation-message"), "Please select a patient" ) app_driver$stop() @@ -168,13 +170,13 @@ testthat::test_that("e2e - tm_t_pp_laboratory: Deselection of paramcd throws val app_driver$set_active_module_input("paramcd-dataset_ADLB_singleextract-select", NULL) testthat::expect_false( app_driver$is_visible( - app_driver$active_module_element("lab_values_table"), + app_driver$namespaces(TRUE)$module("lab_values_table"), visibility_property = TRUE ) ) app_driver$expect_validation_error() testthat::expect_equal( - app_driver$active_module_element_text("paramcd-dataset_ADLB_singleextract-select_input .shiny-validation-message"), + app_driver$namespaces(TRUE)$module("paramcd-dataset_ADLB_singleextract-select_input .shiny-validation-message"), "Please select PARAMCD variable." ) app_driver$stop() @@ -209,13 +211,13 @@ testthat::test_that( app_driver$set_active_module_input("param-dataset_ADLB_singleextract-select", NULL) testthat::expect_false( app_driver$is_visible( - app_driver$active_module_element("lab_values_table"), + app_driver$namespaces(TRUE)$module("lab_values_table"), visibility_property = TRUE ) ) app_driver$expect_validation_error() testthat::expect_equal( - app_driver$active_module_element_text("param-dataset_ADLB_singleextract-select_input .shiny-validation-message"), + app_driver$namespaces(TRUE)$module("param-dataset_ADLB_singleextract-select_input .shiny-validation-message"), "Please select PARAM variable." ) app_driver$stop() @@ -249,13 +251,13 @@ testthat::test_that("e2e - tm_t_pp_laboratory: Deselection of timepoints throws app_driver$set_active_module_input("timepoints-dataset_ADLB_singleextract-select", NULL) testthat::expect_false( app_driver$is_visible( - app_driver$active_module_element("lab_values_table"), + app_driver$namespaces(TRUE)$module("lab_values_table"), visibility_property = TRUE ) ) app_driver$expect_validation_error() testthat::expect_equal( - app_driver$active_module_element_text( + app_driver$namespaces(TRUE)$module( "timepoints-dataset_ADLB_singleextract-select_input .shiny-validation-message" ), "Please select timepoints variable." @@ -290,13 +292,13 @@ testthat::test_that("e2e - tm_t_pp_laboratory: Deselection of avalu throws valid app_driver$set_active_module_input("avalu_var-dataset_ADLB_singleextract-select", NULL) testthat::expect_false( app_driver$is_visible( - app_driver$active_module_element("lab_values_table"), + app_driver$namespaces(TRUE)$module("lab_values_table"), visibility_property = TRUE ) ) app_driver$expect_validation_error() testthat::expect_equal( - app_driver$active_module_element_text( + app_driver$namespaces(TRUE)$module( "avalu_var-dataset_ADLB_singleextract-select_input .shiny-validation-message" ), "Please select AVALU variable." @@ -331,13 +333,13 @@ testthat::test_that("e2e - tm_t_pp_laboratory: Deselection of aval_var throws va app_driver$set_active_module_input("aval_var-dataset_ADLB_singleextract-select", NULL) testthat::expect_false( app_driver$is_visible( - app_driver$active_module_element("lab_values_table"), + app_driver$namespaces(TRUE)$module("lab_values_table"), visibility_property = TRUE ) ) app_driver$expect_validation_error() testthat::expect_equal( - app_driver$active_module_element_text("aval_var-dataset_ADLB_singleextract-select_input .shiny-validation-message"), + app_driver$namespaces(TRUE)$module("aval_var-dataset_ADLB_singleextract-select_input .shiny-validation-message"), "Please select AVAL variable." ) app_driver$stop() @@ -370,13 +372,13 @@ testthat::test_that("e2e - tm_t_pp_laboratory: Deselection of arind throws valid app_driver$set_active_module_input("anrind-dataset_ADLB_singleextract-select", NULL) testthat::expect_false( app_driver$is_visible( - app_driver$active_module_element("lab_values_table"), + app_driver$namespaces(TRUE)$module("lab_values_table"), visibility_property = TRUE ) ) app_driver$expect_validation_error() testthat::expect_equal( - app_driver$active_module_element_text("anrind-dataset_ADLB_singleextract-select_input .shiny-validation-message"), + app_driver$namespaces(TRUE)$module("anrind-dataset_ADLB_singleextract-select_input .shiny-validation-message"), "Please select ANRIND variable." ) app_driver$stop() diff --git a/tests/testthat/test-shinytest2-tm_t_pp_medical_history.R b/tests/testthat/test-shinytest2-tm_t_pp_medical_history.R index 41b085111..fc06bffbd 100644 --- a/tests/testthat/test-shinytest2-tm_t_pp_medical_history.R +++ b/tests/testthat/test-shinytest2-tm_t_pp_medical_history.R @@ -7,26 +7,28 @@ app_driver_tm_t_pp_medical_history <- function() { # nolint: object_length. teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[names(data)] init_teal_app_driver( - data = data, - modules = tm_t_pp_medical_history( - label = "Medical History", - dataname = "ADMH", - parentname = "ADSL", - patient_col = "USUBJID", - mhterm = teal.transform::choices_selected( - choices = teal.transform::variable_choices(data[["ADMH"]], c("MHTERM", "STUDYID")), - selected = "MHTERM" - ), - mhbodsys = teal.transform::choices_selected( - choices = teal.transform::variable_choices(data[["ADMH"]], c("MHBODSYS", "EOSSTT")), - selected = "MHBODSYS" - ), - mhdistat = teal.transform::choices_selected( - choices = teal.transform::variable_choices(data[["ADMH"]], c("MHDISTAT", "STUDYID")), - selected = "MHDISTAT" - ), - pre_output = NULL, - post_output = NULL + teal::init( + data = data, + modules = tm_t_pp_medical_history( + label = "Medical History", + dataname = "ADMH", + parentname = "ADSL", + patient_col = "USUBJID", + mhterm = teal.transform::choices_selected( + choices = teal.transform::variable_choices(data[["ADMH"]], c("MHTERM", "STUDYID")), + selected = "MHTERM" + ), + mhbodsys = teal.transform::choices_selected( + choices = teal.transform::variable_choices(data[["ADMH"]], c("MHBODSYS", "EOSSTT")), + selected = "MHBODSYS" + ), + mhdistat = teal.transform::choices_selected( + choices = teal.transform::variable_choices(data[["ADMH"]], c("MHDISTAT", "STUDYID")), + selected = "MHDISTAT" + ), + pre_output = NULL, + post_output = NULL + ) ) ) } @@ -40,7 +42,7 @@ testthat::test_that( 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")) + app_driver$is_visible(app_driver$namespaces(TRUE)$module("table-table-with-settings")) ) app_driver$stop() } @@ -104,7 +106,7 @@ testthat::test_that("e2e - tm_t_pp_medical_history: Deselection of patient_id th 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("patient_id_input .shiny-validation-message"), + app_driver$namespaces(TRUE)$module("patient_id_input .shiny-validation-message"), "Please select a patient" ) app_driver$stop() @@ -137,7 +139,7 @@ testthat::test_that("e2e - tm_t_pp_medical_history: Deselection of mhterm throws 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("mhterm-dataset_ADMH_singleextract-select_input .shiny-validation-message"), + app_driver$namespaces(TRUE)$module("mhterm-dataset_ADMH_singleextract-select_input .shiny-validation-message"), "Please select MHTERM variable." ) app_driver$stop() @@ -170,7 +172,7 @@ testthat::test_that("e2e - tm_t_pp_medical_history: Deselection of mhbodsys thro 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("mhbodsys-dataset_ADMH_singleextract-select_input .shiny-validation-message"), + app_driver$namespaces(TRUE)$module("mhbodsys-dataset_ADMH_singleextract-select_input .shiny-validation-message"), "Please select MHBODSYS variable." ) app_driver$stop() @@ -203,7 +205,7 @@ testthat::test_that("e2e - tm_t_pp_medical_history: Deselection of mhdistat thro 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("mhdistat-dataset_ADMH_singleextract-select_input .shiny-validation-message"), + app_driver$namespaces(TRUE)$module("mhdistat-dataset_ADMH_singleextract-select_input .shiny-validation-message"), "Please select MHDISTAT variable." ) app_driver$stop() diff --git a/tests/testthat/test-shinytest2-tm_t_pp_prior_medication.R b/tests/testthat/test-shinytest2-tm_t_pp_prior_medication.R index d315e5213..f36f4a651 100644 --- a/tests/testthat/test-shinytest2-tm_t_pp_prior_medication.R +++ b/tests/testthat/test-shinytest2-tm_t_pp_prior_medication.R @@ -13,30 +13,32 @@ app_driver_tm_t_pp_prior_medication <- function() { # nolint: object_length. teal.data::join_keys(data) <- keys init_teal_app_driver( - data = data, - modules = tm_t_pp_prior_medication( - label = "Prior Medication", - dataname = "ADCM", - parentname = "ADSL", - patient_col = "USUBJID", - atirel = teal.transform::choices_selected( - choices = teal.transform::variable_choices(data[["ADCM"]], c("ATIREL", "SEX")), - selected = "ATIREL" - ), - cmdecod = teal.transform::choices_selected( - choices = teal.transform::variable_choices(data[["ADCM"]], c("CMDECOD", "RACE")), - selected = "CMDECOD" - ), - cmindc = teal.transform::choices_selected( - choices = teal.transform::variable_choices(data[["ADCM"]], c("CMINDC", "SEX")), - selected = "CMINDC" - ), - cmstdy = teal.transform::choices_selected( - choices = teal.transform::variable_choices(data[["ADCM"]], c("ASTDY", "AGE")), - selected = "ASTDY" - ), - pre_output = NULL, - post_output = NULL + teal::init( + data = data, + modules = tm_t_pp_prior_medication( + label = "Prior Medication", + dataname = "ADCM", + parentname = "ADSL", + patient_col = "USUBJID", + atirel = teal.transform::choices_selected( + choices = teal.transform::variable_choices(data[["ADCM"]], c("ATIREL", "SEX")), + selected = "ATIREL" + ), + cmdecod = teal.transform::choices_selected( + choices = teal.transform::variable_choices(data[["ADCM"]], c("CMDECOD", "RACE")), + selected = "CMDECOD" + ), + cmindc = teal.transform::choices_selected( + choices = teal.transform::variable_choices(data[["ADCM"]], c("CMINDC", "SEX")), + selected = "CMINDC" + ), + cmstdy = teal.transform::choices_selected( + choices = teal.transform::variable_choices(data[["ADCM"]], c("ASTDY", "AGE")), + selected = "ASTDY" + ), + pre_output = NULL, + post_output = NULL + ) ) ) } @@ -50,7 +52,7 @@ testthat::test_that( app_driver$expect_no_shiny_error() app_driver$expect_no_validation_error() testthat::expect_true( - app_driver$is_visible(app_driver$active_module_element("prior_medication_table")) + app_driver$is_visible(app_driver$namespaces(TRUE)$module("prior_medication_table")) ) app_driver$stop() } @@ -116,7 +118,7 @@ testthat::test_that("e2e - tm_t_pp_prior_medication: Deselection of patient_id t app_driver$set_active_module_input("patient_id", NULL) app_driver$expect_validation_error() testthat::expect_equal( - app_driver$active_module_element_text("patient_id_input .shiny-validation-message"), + app_driver$namespaces(TRUE)$module("patient_id_input .shiny-validation-message"), "Please select patient id" ) app_driver$stop() @@ -148,7 +150,7 @@ testthat::test_that("e2e - tm_t_pp_prior_medication: Deselection of cmdecod thro app_driver$set_active_module_input("cmdecod-dataset_ADCM_singleextract-select", NULL) app_driver$expect_validation_error() testthat::expect_equal( - app_driver$active_module_element_text("cmdecod-dataset_ADCM_singleextract-select_input .shiny-validation-message"), + app_driver$namespaces(TRUE)$module("cmdecod-dataset_ADCM_singleextract-select_input .shiny-validation-message"), "A medication decoding variable is required" ) app_driver$stop() @@ -180,7 +182,7 @@ testthat::test_that("e2e - tm_t_pp_prior_medication: Deselection of atirel throw app_driver$set_active_module_input("atirel-dataset_ADCM_singleextract-select", NULL) app_driver$expect_validation_error() testthat::expect_equal( - app_driver$active_module_element_text("atirel-dataset_ADCM_singleextract-select_input .shiny-validation-message"), + app_driver$namespaces(TRUE)$module("atirel-dataset_ADCM_singleextract-select_input .shiny-validation-message"), "An ATIREL variable is required" ) app_driver$stop() @@ -212,7 +214,7 @@ testthat::test_that("e2e - tm_t_pp_prior_medication: Deselection of cmindc throw app_driver$set_active_module_input("cmindc-dataset_ADCM_singleextract-select", NULL) app_driver$expect_validation_error() testthat::expect_equal( - app_driver$active_module_element_text("cmindc-dataset_ADCM_singleextract-select_input .shiny-validation-message"), + app_driver$namespaces(TRUE)$module("cmindc-dataset_ADCM_singleextract-select_input .shiny-validation-message"), "A CMINDC variable is required" ) app_driver$stop() @@ -244,7 +246,7 @@ testthat::test_that("e2e - tm_t_pp_prior_medication: Deselection of cmstdy throw app_driver$set_active_module_input("cmstdy-dataset_ADCM_singleextract-select", NULL) app_driver$expect_validation_error() testthat::expect_equal( - app_driver$active_module_element_text("cmstdy-dataset_ADCM_singleextract-select_input .shiny-validation-message"), + app_driver$namespaces(TRUE)$module("cmstdy-dataset_ADCM_singleextract-select_input .shiny-validation-message"), "A CMSTDY variable is required" ) app_driver$stop() diff --git a/tests/testthat/test-shinytest2-tm_t_shift_by_arm.R b/tests/testthat/test-shinytest2-tm_t_shift_by_arm.R index e0b471c69..209533c12 100644 --- a/tests/testthat/test-shinytest2-tm_t_shift_by_arm.R +++ b/tests/testthat/test-shinytest2-tm_t_shift_by_arm.R @@ -7,43 +7,45 @@ app_driver_tm_t_shift_by_arm <- function() { teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[names(data)] init_teal_app_driver( - data = data, - modules = tm_t_shift_by_arm( - label = "Shift by Arm Table", - dataname = "ADEG", - parentname = "ADSL", - arm_var = teal.transform::choices_selected( - teal.transform::variable_choices(data[["ADSL"]], subset = c("ARM", "ARMCD")), - selected = "ARM" - ), - paramcd = teal.transform::choices_selected( - teal.transform::value_choices(data[["ADEG"]], "PARAMCD"), - selected = "HR" - ), - visit_var = teal.transform::choices_selected( - teal.transform::value_choices(data[["ADEG"]], "AVISIT"), - selected = "POST-BASELINE MINIMUM" - ), - aval_var = teal.transform::choices_selected( - teal.transform::variable_choices(data[["ADEG"]], subset = "ANRIND"), - selected = "ANRIND", fixed = TRUE - ), - baseline_var = teal.transform::choices_selected( - teal.transform::variable_choices(data[["ADEG"]], subset = "BNRIND"), - selected = "BNRIND", fixed = TRUE - ), - useNA = "ifany", - treatment_flag_var = teal.transform::choices_selected( - teal.transform::variable_choices(data[["ADEG"]], subset = "ONTRTFL"), - selected = "ONTRTFL" - ), - treatment_flag = teal.transform::choices_selected("Y"), - na_level = default_na_str(), - add_total = FALSE, - total_label = default_total_label(), - pre_output = NULL, - post_output = NULL, - basic_table_args = teal.widgets::basic_table_args() + teal::init( + data = data, + modules = tm_t_shift_by_arm( + label = "Shift by Arm Table", + dataname = "ADEG", + parentname = "ADSL", + arm_var = teal.transform::choices_selected( + teal.transform::variable_choices(data[["ADSL"]], subset = c("ARM", "ARMCD")), + selected = "ARM" + ), + paramcd = teal.transform::choices_selected( + teal.transform::value_choices(data[["ADEG"]], "PARAMCD"), + selected = "HR" + ), + visit_var = teal.transform::choices_selected( + teal.transform::value_choices(data[["ADEG"]], "AVISIT"), + selected = "POST-BASELINE MINIMUM" + ), + aval_var = teal.transform::choices_selected( + teal.transform::variable_choices(data[["ADEG"]], subset = "ANRIND"), + selected = "ANRIND", fixed = TRUE + ), + baseline_var = teal.transform::choices_selected( + teal.transform::variable_choices(data[["ADEG"]], subset = "BNRIND"), + selected = "BNRIND", fixed = TRUE + ), + useNA = "ifany", + treatment_flag_var = teal.transform::choices_selected( + teal.transform::variable_choices(data[["ADEG"]], subset = "ONTRTFL"), + selected = "ONTRTFL" + ), + treatment_flag = teal.transform::choices_selected("Y"), + na_level = default_na_str(), + add_total = FALSE, + total_label = default_total_label(), + pre_output = NULL, + post_output = NULL, + basic_table_args = teal.widgets::basic_table_args() + ) ) ) } @@ -55,7 +57,7 @@ testthat::test_that("e2e - tm_t_shift_by_arm: Module initializes in teal without 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")) + app_driver$is_visible(app_driver$namespaces(TRUE)$module("table-table-with-settings")) ) app_driver$stop() }) @@ -123,7 +125,7 @@ testthat::test_that("e2e - tm_t_shift_by_arm: Deselection of arm_var throws vali 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 .shiny-validation-message"), + app_driver$namespaces(TRUE)$module("arm_var-dataset_ADSL_singleextract-select_input .shiny-validation-message"), "A treatment variable is required" ) app_driver$stop() @@ -156,7 +158,7 @@ testthat::test_that("e2e - tm_t_shift_by_arm: Deselection of paramcd throws vali 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( + app_driver$namespaces(TRUE)$module( "paramcd-dataset_ADEG_singleextract-filter1-vals_input .shiny-validation-message" ), "An endpoint is required" @@ -191,7 +193,7 @@ testthat::test_that("e2e - tm_t_shift_by_arm: Deselection of visit_var throws va 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( + app_driver$namespaces(TRUE)$module( "visit_var-dataset_ADEG_singleextract-filter1-vals_input .shiny-validation-message" ), "A visit is required" diff --git a/tests/testthat/test-shinytest2-tm_t_shift_by_arm_by_worst.R b/tests/testthat/test-shinytest2-tm_t_shift_by_arm_by_worst.R index 4154edaa9..2744d965f 100644 --- a/tests/testthat/test-shinytest2-tm_t_shift_by_arm_by_worst.R +++ b/tests/testthat/test-shinytest2-tm_t_shift_by_arm_by_worst.R @@ -7,43 +7,45 @@ app_driver_tm_t_shift_by_arm_by_worst <- function() { # nolint: object_length. teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[names(data)] init_teal_app_driver( - data = data, - modules = tm_t_shift_by_arm_by_worst( - label = "Shift by Arm Table", - dataname = "ADEG", - parentname = "ADSL", - arm_var = teal.transform::choices_selected( - teal.transform::variable_choices(data[["ADSL"]], subset = c("ARM", "ARMCD")), - selected = "ARM" - ), - paramcd = teal.transform::choices_selected( - teal.transform::value_choices(data[["ADEG"]], "PARAMCD"), - selected = "ECGINTP" - ), - worst_flag_var = teal.transform::choices_selected( - teal.transform::variable_choices(data[["ADEG"]], c("WORS02FL", "WORS01FL")), - selected = "WORS02FL" - ), - worst_flag = teal.transform::choices_selected( - teal.transform::value_choices(data[["ADEG"]], "WORS02FL"), - selected = "Y", fixed = TRUE - ), - aval_var = teal.transform::choices_selected( - teal.transform::variable_choices(data[["ADEG"]], c("REGION1", "AVALC")), - selected = "REGION1" - ), - baseline_var = teal.transform::choices_selected( - teal.transform::variable_choices(data[["ADEG"]], c("AVISIT", "BASEC")), - selected = "AVISIT" - ), - useNA = "ifany", - treatment_flag = teal.transform::choices_selected("Y"), - na_level = default_na_str(), - add_total = FALSE, - total_label = default_total_label(), - pre_output = NULL, - post_output = NULL, - basic_table_args = teal.widgets::basic_table_args() + teal::init( + data = data, + modules = tm_t_shift_by_arm_by_worst( + label = "Shift by Arm Table", + dataname = "ADEG", + parentname = "ADSL", + arm_var = teal.transform::choices_selected( + teal.transform::variable_choices(data[["ADSL"]], subset = c("ARM", "ARMCD")), + selected = "ARM" + ), + paramcd = teal.transform::choices_selected( + teal.transform::value_choices(data[["ADEG"]], "PARAMCD"), + selected = "ECGINTP" + ), + worst_flag_var = teal.transform::choices_selected( + teal.transform::variable_choices(data[["ADEG"]], c("WORS02FL", "WORS01FL")), + selected = "WORS02FL" + ), + worst_flag = teal.transform::choices_selected( + teal.transform::value_choices(data[["ADEG"]], "WORS02FL"), + selected = "Y", fixed = TRUE + ), + aval_var = teal.transform::choices_selected( + teal.transform::variable_choices(data[["ADEG"]], c("REGION1", "AVALC")), + selected = "REGION1" + ), + baseline_var = teal.transform::choices_selected( + teal.transform::variable_choices(data[["ADEG"]], c("AVISIT", "BASEC")), + selected = "AVISIT" + ), + useNA = "ifany", + treatment_flag = teal.transform::choices_selected("Y"), + na_level = default_na_str(), + add_total = FALSE, + total_label = default_total_label(), + pre_output = NULL, + post_output = NULL, + basic_table_args = teal.widgets::basic_table_args() + ) ) ) } @@ -57,7 +59,7 @@ testthat::test_that( 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")) + app_driver$is_visible(app_driver$namespaces(TRUE)$module("table-table-with-settings")) ) app_driver$stop() } @@ -136,7 +138,7 @@ testthat::test_that("e2e - tm_t_shift_by_arm_by_worst: Deselection of arm_var th 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 .shiny-validation-message"), + app_driver$namespaces(TRUE)$module("arm_var-dataset_ADSL_singleextract-select_input .shiny-validation-message"), "A treatment variable is required" ) app_driver$stop() @@ -169,7 +171,7 @@ testthat::test_that("e2e - tm_t_shift_by_arm_by_worst: Deselection of paramcd th 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( + app_driver$namespaces(TRUE)$module( "paramcd-dataset_ADEG_singleextract-filter1-vals_input .shiny-validation-message" ), "An endpoint is required" @@ -205,7 +207,7 @@ testthat::test_that("e2e - tm_t_shift_by_arm_by_worst: Deselection of worst_flag 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( + app_driver$namespaces(TRUE)$module( "worst_flag_var-dataset_ADEG_singleextract-select_input .shiny-validation-message" ), "A worst flag variable is required" @@ -241,7 +243,7 @@ testthat::test_that("e2e - tm_t_shift_by_arm_by_worst: Deselection of aval_var t 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("aval_var-dataset_ADEG_singleextract-select_input .shiny-validation-message"), + app_driver$namespaces(TRUE)$module("aval_var-dataset_ADEG_singleextract-select_input .shiny-validation-message"), "An analysis range indicator required" ) app_driver$stop() @@ -275,7 +277,7 @@ testthat::test_that("e2e - tm_t_shift_by_arm_by_worst: Deselection of baseline_v 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( + app_driver$namespaces(TRUE)$module( "baseline_var-dataset_ADEG_singleextract-select_input .shiny-validation-message" ), "A baseline reference range indicator is required" diff --git a/tests/testthat/test-shinytest2-tm_t_shift_by_grade.R b/tests/testthat/test-shinytest2-tm_t_shift_by_grade.R index fe2f0f583..2aeff80a7 100644 --- a/tests/testthat/test-shinytest2-tm_t_shift_by_grade.R +++ b/tests/testthat/test-shinytest2-tm_t_shift_by_grade.R @@ -7,58 +7,60 @@ app_driver_tm_t_shift_by_grade <- function() { teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[names(data)] init_teal_app_driver( - data = data, - modules = tm_t_shift_by_grade( - label = "Grade Laboratory Abnormality Table", - dataname = "ADLB", - parentname = "ADSL", - visit_var = teal.transform::choices_selected( - teal.transform::variable_choices(data[["ADLB"]], subset = "AVISIT"), - selected = "AVISIT", fixed = TRUE - ), - arm_var = teal.transform::choices_selected( - choices = teal.transform::variable_choices(data[["ADLB"]], subset = c("ARM", "ARMCD")), - selected = "ARM" - ), - paramcd = teal.transform::choices_selected( - choices = teal.transform::value_choices(data[["ADLB"]], "PARAMCD", "PARAM"), - selected = "ALT" - ), - worst_flag_var = teal.transform::choices_selected( - choices = teal.transform::variable_choices( - data[["ADLB"]], - subset = c("WGRLOVFL", "WGRLOFL", "WGRHIVFL", "WGRHIFL") + teal::init( + data = data, + modules = tm_t_shift_by_grade( + label = "Grade Laboratory Abnormality Table", + dataname = "ADLB", + parentname = "ADSL", + visit_var = teal.transform::choices_selected( + teal.transform::variable_choices(data[["ADLB"]], subset = "AVISIT"), + selected = "AVISIT", fixed = TRUE ), - selected = c("WGRLOVFL") - ), - worst_flag_indicator = teal.transform::choices_selected( - teal.transform::value_choices(data[["ADLB"]], "WGRLOVFL"), - selected = "Y", fixed = TRUE - ), - anl_toxgrade_var = teal.transform::choices_selected( - choices = teal.transform::variable_choices(data[["ADLB"]], subset = c("ATOXGR")), - selected = c("ATOXGR"), - fixed = TRUE - ), - base_toxgrade_var = teal.transform::choices_selected( - choices = teal.transform::variable_choices(data[["ADLB"]], subset = c("BTOXGR")), - selected = c("BTOXGR"), - fixed = TRUE - ), - id_var = teal.transform::choices_selected( - teal.transform::variable_choices(data[["ADLB"]], subset = "USUBJID"), - selected = "USUBJID", fixed = TRUE + arm_var = teal.transform::choices_selected( + choices = teal.transform::variable_choices(data[["ADLB"]], subset = c("ARM", "ARMCD")), + selected = "ARM" + ), + paramcd = teal.transform::choices_selected( + choices = teal.transform::value_choices(data[["ADLB"]], "PARAMCD", "PARAM"), + selected = "ALT" + ), + worst_flag_var = teal.transform::choices_selected( + choices = teal.transform::variable_choices( + data[["ADLB"]], + subset = c("WGRLOVFL", "WGRLOFL", "WGRHIVFL", "WGRHIFL") + ), + selected = c("WGRLOVFL") + ), + worst_flag_indicator = teal.transform::choices_selected( + teal.transform::value_choices(data[["ADLB"]], "WGRLOVFL"), + selected = "Y", fixed = TRUE + ), + anl_toxgrade_var = teal.transform::choices_selected( + choices = teal.transform::variable_choices(data[["ADLB"]], subset = c("ATOXGR")), + selected = c("ATOXGR"), + fixed = TRUE + ), + base_toxgrade_var = teal.transform::choices_selected( + choices = teal.transform::variable_choices(data[["ADLB"]], subset = c("BTOXGR")), + selected = c("BTOXGR"), + fixed = TRUE + ), + id_var = teal.transform::choices_selected( + teal.transform::variable_choices(data[["ADLB"]], subset = "USUBJID"), + selected = "USUBJID", fixed = TRUE + ), + add_total = FALSE, + total_label = default_total_label(), + drop_arm_levels = TRUE, + pre_output = NULL, + post_output = NULL, + na_level = default_na_str(), + code_missing_baseline = FALSE, + basic_table_args = teal.widgets::basic_table_args() ), - add_total = FALSE, - total_label = default_total_label(), - drop_arm_levels = TRUE, - pre_output = NULL, - post_output = NULL, - na_level = default_na_str(), - code_missing_baseline = FALSE, - basic_table_args = teal.widgets::basic_table_args() - ), - filter = teal::teal_slices(teal_slice("ADSL", "SAFFL", selected = "Y")) + filter = teal::teal_slices(teal_slice("ADSL", "SAFFL", selected = "Y")) + ) ) } @@ -71,7 +73,7 @@ testthat::test_that( 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")) + app_driver$is_visible(app_driver$namespaces(TRUE)$module("table-table-with-settings")) ) app_driver$stop() } @@ -146,7 +148,7 @@ testthat::test_that("e2e - tm_t_shift_by_grade: Deselection of arm_var throws va 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 .shiny-validation-message"), + app_driver$namespaces(TRUE)$module("arm_var-dataset_ADSL_singleextract-select_input .shiny-validation-message"), "A treatment variable is required" ) app_driver$stop() @@ -179,7 +181,7 @@ testthat::test_that("e2e - tm_t_shift_by_grade: Deselection of paramcd throws va 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( + app_driver$namespaces(TRUE)$module( "paramcd-dataset_ADLB_singleextract-filter1-vals_input .shiny-validation-message" ), "A laboratory parameter is required" @@ -214,7 +216,7 @@ testthat::test_that("e2e - tm_t_shift_by_grade: Deselection of worst_flag throws 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( + app_driver$namespaces(TRUE)$module( "worst_flag_var-dataset_ADLB_singleextract-select_input .shiny-validation-message" ), "A worst treatment flag is required" @@ -235,41 +237,43 @@ app_driver_tm_t_shift_by_grade_invalid_data <- function() { # nolint: object_len ADLB <- data[["ADLB"]] init_teal_app_driver( - data = data, - modules = modules( - tm_t_shift_by_grade( - label = "Grade Laboratory Abnormality Table", - dataname = "ADLB", - arm_var = teal.transform::choices_selected( - choices = teal.transform::variable_choices(ADSL, subset = c("ARM", "ARMCD")), - selected = "ARM" - ), - paramcd = teal.transform::choices_selected( - choices = teal.transform::value_choices(ADLB, "PARAMCD", "PARAM"), - selected = "ALT" - ), - worst_flag_var = teal.transform::choices_selected( - choices = teal.transform::variable_choices(ADLB, subset = c("WGRLOVFL", "WGRLOFL", "WGRHIVFL", "WGRHIFL")), - selected = "WGRLOFL" - ), - worst_flag_indicator = teal.transform::choices_selected( - teal.transform::value_choices(ADLB, "WGRLOVFL"), - selected = "Y", fixed = TRUE - ), - anl_toxgrade_var = teal.transform::choices_selected( - choices = teal.transform::variable_choices(ADLB, subset = c("ATOXGR")), - selected = c("ATOXGR"), - fixed = TRUE - ), - base_toxgrade_var = teal.transform::choices_selected( - choices = teal.transform::variable_choices(ADLB, subset = c("BTOXGR")), - selected = c("BTOXGR"), - fixed = TRUE - ), - add_total = FALSE - ) - ), - filter = teal::teal_slices(teal_slice("ADSL", "SAFFL", selected = "Y")) + teal::init( + data = data, + modules = modules( + tm_t_shift_by_grade( + label = "Grade Laboratory Abnormality Table", + dataname = "ADLB", + arm_var = teal.transform::choices_selected( + choices = teal.transform::variable_choices(ADSL, subset = c("ARM", "ARMCD")), + selected = "ARM" + ), + paramcd = teal.transform::choices_selected( + choices = teal.transform::value_choices(ADLB, "PARAMCD", "PARAM"), + selected = "ALT" + ), + worst_flag_var = teal.transform::choices_selected( + choices = teal.transform::variable_choices(ADLB, subset = c("WGRLOVFL", "WGRLOFL", "WGRHIVFL", "WGRHIFL")), + selected = "WGRLOFL" + ), + worst_flag_indicator = teal.transform::choices_selected( + teal.transform::value_choices(ADLB, "WGRLOVFL"), + selected = "Y", fixed = TRUE + ), + anl_toxgrade_var = teal.transform::choices_selected( + choices = teal.transform::variable_choices(ADLB, subset = c("ATOXGR")), + selected = c("ATOXGR"), + fixed = TRUE + ), + base_toxgrade_var = teal.transform::choices_selected( + choices = teal.transform::variable_choices(ADLB, subset = c("BTOXGR")), + selected = c("BTOXGR"), + fixed = TRUE + ), + add_total = FALSE + ) + ), + filter = teal::teal_slices(teal_slice("ADSL", "SAFFL", selected = "Y")) + ) ) } diff --git a/tests/testthat/test-shinytest2-tm_t_smq.R b/tests/testthat/test-shinytest2-tm_t_smq.R index efc3566a4..526d4193f 100644 --- a/tests/testthat/test-shinytest2-tm_t_smq.R +++ b/tests/testthat/test-shinytest2-tm_t_smq.R @@ -21,34 +21,36 @@ app_driver_tm_t_smq <- function() { teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[names(data)] init_teal_app_driver( - data = data, - modules = tm_t_smq( - label = "Adverse Events by SMQ Table", - dataname = "ADAE", - parentname = "ADSL", - arm_var = teal.transform::choices_selected( - choices = teal.transform::variable_choices(data[["ADSL"]], subset = c("ARM", "SEX")), - selected = "ARM" - ), - id_var = teal.transform::choices_selected( - teal.transform::variable_choices(data[["ADSL"]], subset = "USUBJID"), - selected = "USUBJID", fixed = TRUE - ), - add_total = FALSE, - total_label = default_total_label(), - sort_criteria = c("freq_desc", "alpha"), - drop_arm_levels = TRUE, - na_level = default_na_str(), - smq_varlabel = "Standardized MedDRA Query", - baskets = data[[".cs_baskets"]], - scopes = data[[".cs_scopes"]], - llt = teal.transform::choices_selected( - choices = teal.transform::variable_choices(data[["ADAE"]], subset = c("AEDECOD", "SEX")), - selected = "AEDECOD" - ), - pre_output = NULL, - post_output = NULL, - basic_table_args = teal.widgets::basic_table_args() + teal::init( + data = data, + modules = tm_t_smq( + label = "Adverse Events by SMQ Table", + dataname = "ADAE", + parentname = "ADSL", + arm_var = teal.transform::choices_selected( + choices = teal.transform::variable_choices(data[["ADSL"]], subset = c("ARM", "SEX")), + selected = "ARM" + ), + id_var = teal.transform::choices_selected( + teal.transform::variable_choices(data[["ADSL"]], subset = "USUBJID"), + selected = "USUBJID", fixed = TRUE + ), + add_total = FALSE, + total_label = default_total_label(), + sort_criteria = c("freq_desc", "alpha"), + drop_arm_levels = TRUE, + na_level = default_na_str(), + smq_varlabel = "Standardized MedDRA Query", + baskets = data[[".cs_baskets"]], + scopes = data[[".cs_scopes"]], + llt = teal.transform::choices_selected( + choices = teal.transform::variable_choices(data[["ADAE"]], subset = c("AEDECOD", "SEX")), + selected = "AEDECOD" + ), + pre_output = NULL, + post_output = NULL, + basic_table_args = teal.widgets::basic_table_args() + ) ) ) } @@ -60,7 +62,7 @@ testthat::test_that("e2e - tm_t_smq: Module initializes in teal without errors a 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")) + app_driver$is_visible(app_driver$namespaces(TRUE)$module("table-table-with-settings")) ) app_driver$stop() }) @@ -124,7 +126,7 @@ testthat::test_that("e2e - tm_t_smq: 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 .shiny-validation-message"), + app_driver$namespaces(TRUE)$module("arm_var-dataset_ADSL_singleextract-select_input .shiny-validation-message"), "At least one treatment variable is required" ) app_driver$stop() @@ -154,7 +156,7 @@ testthat::test_that("e2e - tm_t_smq: 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("llt-dataset_ADAE_singleextract-select_input .shiny-validation-message"), + app_driver$namespaces(TRUE)$module("llt-dataset_ADAE_singleextract-select_input .shiny-validation-message"), "A low level term variable is required" ) app_driver$stop() @@ -187,7 +189,7 @@ testthat::test_that("e2e - tm_t_smq: Deselection of worst_flag 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("baskets-dataset_ADAE_singleextract-select_input .shiny-validation-message"), + app_driver$namespaces(TRUE)$module("baskets-dataset_ADAE_singleextract-select_input .shiny-validation-message"), "At least one basket is required" ) app_driver$stop() diff --git a/tests/testthat/test-shinytest2-tm_t_summary.R b/tests/testthat/test-shinytest2-tm_t_summary.R index c95bd3ced..e61afae38 100644 --- a/tests/testthat/test-shinytest2-tm_t_summary.R +++ b/tests/testthat/test-shinytest2-tm_t_summary.R @@ -6,29 +6,31 @@ app_driver_tm_t_summary <- function() { teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[names(data)] init_teal_app_driver( - data = data, - modules = tm_t_summary( - label = "Demographic Table", - dataname = "ADSL", - arm_var = teal.transform::choices_selected(c("ARM", "ARMCD"), "ARM"), - add_total = TRUE, - summarize_vars = teal.transform::choices_selected( - c("SEX", "RACE", "BMRKR2", "EOSDY", "DCSREAS", "AGE"), - c("SEX", "RACE") - ), - useNA = "ifany", - parentname = "ADSL", - total_label = default_total_label(), - na_level = default_na_str(), - numeric_stats = c( - "n", "mean_sd", "mean_ci", "median", "median_ci", "quantiles", - "range", "geom_mean" - ), - denominator = c("N", "n", "omit"), - drop_arm_levels = TRUE, - pre_output = NULL, - post_output = NULL, - basic_table_args = teal.widgets::basic_table_args() + teal::init( + data = data, + modules = tm_t_summary( + label = "Demographic Table", + dataname = "ADSL", + arm_var = teal.transform::choices_selected(c("ARM", "ARMCD"), "ARM"), + add_total = TRUE, + summarize_vars = teal.transform::choices_selected( + c("SEX", "RACE", "BMRKR2", "EOSDY", "DCSREAS", "AGE"), + c("SEX", "RACE") + ), + useNA = "ifany", + parentname = "ADSL", + total_label = default_total_label(), + na_level = default_na_str(), + numeric_stats = c( + "n", "mean_sd", "mean_ci", "median", "median_ci", "quantiles", + "range", "geom_mean" + ), + denominator = c("N", "n", "omit"), + drop_arm_levels = TRUE, + pre_output = NULL, + post_output = NULL, + basic_table_args = teal.widgets::basic_table_args() + ) ) ) } @@ -40,7 +42,7 @@ testthat::test_that("e2e - tm_t_summary: Module initializes in teal without erro 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")) + app_driver$is_visible(app_driver$namespaces(TRUE)$module("table-table-with-settings")) ) app_driver$stop() }) @@ -99,7 +101,7 @@ testthat::test_that("e2e - tm_t_summary: Deselection of arm_var throws validatio 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 .shiny-validation-message"), + app_driver$namespaces(TRUE)$module("arm_var-dataset_ADSL_singleextract-select_input .shiny-validation-message"), "Please select 1 or 2 column variables" ) app_driver$stop() @@ -132,7 +134,7 @@ testthat::test_that("e2e - tm_t_summary: Deselection of summarize_vars throws va 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( + app_driver$namespaces(TRUE)$module( "summarize_vars-dataset_ADSL_singleextract-select_input .shiny-validation-message" ), "Please select a summarize variable" diff --git a/tests/testthat/test-shinytest2-tm_t_summary_by.R b/tests/testthat/test-shinytest2-tm_t_summary_by.R index a22dbaf97..baac22536 100644 --- a/tests/testthat/test-shinytest2-tm_t_summary_by.R +++ b/tests/testthat/test-shinytest2-tm_t_summary_by.R @@ -7,46 +7,48 @@ app_driver_tm_t_summary_by <- function() { teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[names(data)] init_teal_app_driver( - data = data, - modules = tm_t_summary_by( - label = "Summary by Row Groups Table", - dataname = "ADLB", - parentname = "ADSL", - arm_var = teal.transform::choices_selected( - choices = teal.transform::variable_choices(data[["ADSL"]], c("ARM", "ARMCD")), - selected = "ARM" - ), - add_total = TRUE, - by_vars = teal.transform::choices_selected( - choices = teal.transform::variable_choices(data[["ADLB"]], c("PARAM", "AVISIT")), - selected = c("AVISIT") - ), - summarize_vars = teal.transform::choices_selected( - choices = teal.transform::variable_choices(data[["ADLB"]], c("AVAL", "CHG")), - selected = c("AVAL") - ), - useNA = "ifany", - paramcd = teal.transform::choices_selected( - choices = teal.transform::value_choices(data[["ADLB"]], "PARAMCD", "PARAM"), - selected = "ALT" - ), - id_var = teal.transform::choices_selected( - teal.transform::variable_choices(data[["ADLB"]], subset = "USUBJID"), - selected = "USUBJID", fixed = TRUE - ), - total_label = default_total_label(), - parallel_vars = FALSE, - row_groups = FALSE, - na_level = default_na_str(), - numeric_stats = c("n", "mean_sd", "median", "range"), - denominator = teal.transform::choices_selected(c("n", "N", "omit"), "omit", - fixed = TRUE - ), - drop_arm_levels = TRUE, - drop_zero_levels = TRUE, - pre_output = NULL, - post_output = NULL, - basic_table_args = teal.widgets::basic_table_args() + teal::init( + data = data, + modules = tm_t_summary_by( + label = "Summary by Row Groups Table", + dataname = "ADLB", + parentname = "ADSL", + arm_var = teal.transform::choices_selected( + choices = teal.transform::variable_choices(data[["ADSL"]], c("ARM", "ARMCD")), + selected = "ARM" + ), + add_total = TRUE, + by_vars = teal.transform::choices_selected( + choices = teal.transform::variable_choices(data[["ADLB"]], c("PARAM", "AVISIT")), + selected = c("AVISIT") + ), + summarize_vars = teal.transform::choices_selected( + choices = teal.transform::variable_choices(data[["ADLB"]], c("AVAL", "CHG")), + selected = c("AVAL") + ), + useNA = "ifany", + paramcd = teal.transform::choices_selected( + choices = teal.transform::value_choices(data[["ADLB"]], "PARAMCD", "PARAM"), + selected = "ALT" + ), + id_var = teal.transform::choices_selected( + teal.transform::variable_choices(data[["ADLB"]], subset = "USUBJID"), + selected = "USUBJID", fixed = TRUE + ), + total_label = default_total_label(), + parallel_vars = FALSE, + row_groups = FALSE, + na_level = default_na_str(), + numeric_stats = c("n", "mean_sd", "median", "range"), + denominator = teal.transform::choices_selected(c("n", "N", "omit"), "omit", + fixed = TRUE + ), + drop_arm_levels = TRUE, + drop_zero_levels = TRUE, + pre_output = NULL, + post_output = NULL, + basic_table_args = teal.widgets::basic_table_args() + ) ) ) } @@ -58,7 +60,7 @@ testthat::test_that("e2e - tm_t_summary_by: Module initializes in teal without e 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")) + app_driver$is_visible(app_driver$namespaces(TRUE)$module("table-table-with-settings")) ) app_driver$stop() }) @@ -133,7 +135,7 @@ testthat::test_that("e2e - tm_t_summary_by: Deselection of arm_var throws valida 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 .shiny-validation-message"), + app_driver$namespaces(TRUE)$module("arm_var-dataset_ADSL_singleextract-select_input .shiny-validation-message"), "Please select 1 or 2 column variables" ) app_driver$stop() @@ -166,7 +168,7 @@ testthat::test_that("e2e - tm_t_summary_by: Deselection of arm_var throws valida 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( + app_driver$namespaces(TRUE)$module( "paramcd-dataset_ADLB_singleextract-filter1-vals_input .shiny-validation-message" ), "Please select a filter." @@ -239,7 +241,7 @@ testthat::test_that("e2e - tm_t_summary_by: Deselection of summarize_vars throws 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( + app_driver$namespaces(TRUE)$module( "summarize_vars-dataset_ADLB_singleextract-select_input .shiny-validation-message" ), "Please select a summarize variable." diff --git a/tests/testthat/test-shinytest2-tm_t_tte.R b/tests/testthat/test-shinytest2-tm_t_tte.R index 8ea1c9072..dcacb2f8b 100644 --- a/tests/testthat/test-shinytest2-tm_t_tte.R +++ b/tests/testthat/test-shinytest2-tm_t_tte.R @@ -18,56 +18,58 @@ app_driver_tm_t_tte <- function() { ) init_teal_app_driver( - data = data, - modules = tm_t_tte( - label = "Time To Event Table", - dataname = "ADTTE", - parentname = "ADSL", - arm_var = teal.transform::choices_selected( - teal.transform::variable_choices(data[["ADSL"]], c("ARM", "ARMCD", "ACTARMCD")), - "ARM" - ), - arm_ref_comp = arm_ref_comp, - paramcd = teal.transform::choices_selected( - teal.transform::value_choices(data[["ADTTE"]], "PARAMCD", "PARAM"), - "OS" - ), - strata_var = teal.transform::choices_selected( - teal.transform::variable_choices(data[["ADSL"]], c("SEX", "BMRKR2")), - "SEX" - ), - time_points = teal.transform::choices_selected(c(182, 243), 182), - event_desc_var = teal.transform::choices_selected( - teal.transform::variable_choices(data[["ADTTE"]], "EVNTDESC"), - "EVNTDESC", - fixed = TRUE - ), - aval_var = teal.transform::choices_selected( - teal.transform::variable_choices(data[["ADTTE"]], "AVAL"), "AVAL", - fixed = TRUE - ), - cnsr_var = teal.transform::choices_selected( - teal.transform::variable_choices(data[["ADTTE"]], "CNSR"), "CNSR", - fixed = TRUE - ), - conf_level_coxph = teal.transform::choices_selected( - c(0.95, 0.9, 0.8), 0.95, - keep_order = TRUE - ), - conf_level_survfit = teal.transform::choices_selected( - c(0.95, 0.9, 0.8), 0.95, - keep_order = TRUE - ), - time_unit_var = teal.transform::choices_selected( - teal.transform::variable_choices(data[["ADTTE"]], "AVALU"), "AVALU", - fixed = TRUE - ), - add_total = FALSE, - total_label = default_total_label(), - na_level = default_na_str(), - pre_output = NULL, - post_output = NULL, - basic_table_args = teal.widgets::basic_table_args() + teal::init( + data = data, + modules = tm_t_tte( + label = "Time To Event Table", + dataname = "ADTTE", + parentname = "ADSL", + arm_var = teal.transform::choices_selected( + teal.transform::variable_choices(data[["ADSL"]], c("ARM", "ARMCD", "ACTARMCD")), + "ARM" + ), + arm_ref_comp = arm_ref_comp, + paramcd = teal.transform::choices_selected( + teal.transform::value_choices(data[["ADTTE"]], "PARAMCD", "PARAM"), + "OS" + ), + strata_var = teal.transform::choices_selected( + teal.transform::variable_choices(data[["ADSL"]], c("SEX", "BMRKR2")), + "SEX" + ), + time_points = teal.transform::choices_selected(c(182, 243), 182), + event_desc_var = teal.transform::choices_selected( + teal.transform::variable_choices(data[["ADTTE"]], "EVNTDESC"), + "EVNTDESC", + fixed = TRUE + ), + aval_var = teal.transform::choices_selected( + teal.transform::variable_choices(data[["ADTTE"]], "AVAL"), "AVAL", + fixed = TRUE + ), + cnsr_var = teal.transform::choices_selected( + teal.transform::variable_choices(data[["ADTTE"]], "CNSR"), "CNSR", + fixed = TRUE + ), + conf_level_coxph = teal.transform::choices_selected( + c(0.95, 0.9, 0.8), 0.95, + keep_order = TRUE + ), + conf_level_survfit = teal.transform::choices_selected( + c(0.95, 0.9, 0.8), 0.95, + keep_order = TRUE + ), + time_unit_var = teal.transform::choices_selected( + teal.transform::variable_choices(data[["ADTTE"]], "AVALU"), "AVALU", + fixed = TRUE + ), + add_total = FALSE, + total_label = default_total_label(), + na_level = default_na_str(), + pre_output = NULL, + post_output = NULL, + basic_table_args = teal.widgets::basic_table_args() + ) ) ) } @@ -79,7 +81,7 @@ testthat::test_that("e2e - tm_t_tte: Module initializes in teal without errors a 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")) + app_driver$is_visible(app_driver$namespaces(TRUE)$module("table-table-with-settings")) ) app_driver$stop() }) @@ -180,7 +182,7 @@ testthat::test_that("e2e - tm_t_tte: 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( + app_driver$namespaces(TRUE)$module( "paramcd-dataset_ADTTE_singleextract-filter1-vals_input .shiny-validation-message" ), "An endpoint is required" @@ -215,7 +217,7 @@ testthat::test_that("e2e - tm_t_tte: 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( + app_driver$namespaces(TRUE)$module( "arm_var-dataset_ADSL_singleextract-select_input .shiny-validation-message" ), "Treatment variable must be selected" diff --git a/tests/testthat/test-tm_t_glm_counts.R b/tests/testthat/test-tm_t_glm_counts.R index bcc15a486..7582a5469 100644 --- a/tests/testthat/test-tm_t_glm_counts.R +++ b/tests/testthat/test-tm_t_glm_counts.R @@ -22,29 +22,31 @@ app_driver_tm_t_glm_counts <- function() { # nolint: object_length. ADTTE <- data[["ADTTE"]] # Initialize the teal app init_teal_app_driver( - data = data, - modules = tm_t_glm_counts( - dataname = "ADTTE", - arm_var = choices_selected( - variable_choices("ADTTE", c("ARM", "ARMCD", "ACTARMCD")), - "ARMCD" - ), - arm_ref_comp = arm_ref_comp, - aval_var = choices_selected( - variable_choices("ADTTE", "AVAL"), - "AVAL" - ), - strata_var = choices_selected( - variable_choices("ADSL", "SEX"), - NULL - ), - offset_var = choices_selected( - variable_choices("ADSL", "AGE"), - NULL - ), - cov_var = choices_selected( - variable_choices("ADTTE", "SITEID"), - NULL + teal::init( + data = data, + modules = tm_t_glm_counts( + dataname = "ADTTE", + arm_var = choices_selected( + variable_choices("ADTTE", c("ARM", "ARMCD", "ACTARMCD")), + "ARMCD" + ), + arm_ref_comp = arm_ref_comp, + aval_var = choices_selected( + variable_choices("ADTTE", "AVAL"), + "AVAL" + ), + strata_var = choices_selected( + variable_choices("ADSL", "SEX"), + NULL + ), + offset_var = choices_selected( + variable_choices("ADSL", "AGE"), + NULL + ), + cov_var = choices_selected( + variable_choices("ADTTE", "SITEID"), + NULL + ) ) ) ) @@ -58,7 +60,7 @@ testthat::test_that( 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")) + app_driver$is_visible(app_driver$namespaces(TRUE)$module("table-table-with-settings")) ) app_driver$stop() }