Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wave 2 - tm_g_lineplot shinytest2 #1137

Merged
Merged
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
222 changes: 222 additions & 0 deletions tests/testthat/test-shinytest2-tm_g_lineplot.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,222 @@
app_driver_tm_g_lineplot <- function() {
data <- within(teal.data::teal_data(), {
require(nestcolor)
ADSL <- teal.modules.clinical::tmc_ex_adsl

ADLB <- dplyr::mutate(
teal.modules.clinical::tmc_ex_adlb,
AVISIT == forcats::fct_reorder(AVISIT, AVISITN, min)
)
})

datanames <- c("ADSL", "ADLB")
teal.data::datanames(data) <- datanames
teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[datanames]

init_teal_app_driver(
data = data,
modules = tm_g_lineplot(
label = "Line Plot",
dataname = "ADLB",
strata = 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 =

Check warning on line 46 in tests/testthat/test-shinytest2-tm_g_lineplot.R

View workflow job for this annotation

GitHub Actions / SuperLinter 🦸‍♀️ / Lint R code 🧶

file=tests/testthat/test-shinytest2-tm_g_lineplot.R,line=46,col=52,[indentation_linter] Indentation should be 8 spaces but is 52 spaces.
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
)
}

testthat::test_that("e2e - tm_g_lineplot: Module initializes in teal without errors.", {
skip_if_too_deep(5)

app_driver <- app_driver_tm_g_lineplot()
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"))
)

app_driver$stop()
})

testthat::test_that(
paste0(

Check warning on line 81 in tests/testthat/test-shinytest2-tm_g_lineplot.R

View workflow job for this annotation

GitHub Actions / SuperLinter 🦸‍♀️ / Lint R code 🧶

file=tests/testthat/test-shinytest2-tm_g_lineplot.R,line=81,col=2,[indentation_linter] Hanging indent should be 20 spaces but is 2 spaces.
"e2e - tm_g_lineplot: Starts with specified",
"label, param, strata, y-dataset, mid, interval, incl_screen",
kartikeyakirar marked this conversation as resolved.
Show resolved Hide resolved
"plot settings and table settings"
),
{
skip_if_too_deep(5)

app_driver <- app_driver_tm_g_lineplot()

Check warning on line 89 in tests/testthat/test-shinytest2-tm_g_lineplot.R

View workflow job for this annotation

GitHub Actions / SuperLinter 🦸‍♀️ / Lint R code 🧶

file=tests/testthat/test-shinytest2-tm_g_lineplot.R,line=89,col=4,[indentation_linter] Indentation should be 22 spaces but is 4 spaces.

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

Check warning on line 91 in tests/testthat/test-shinytest2-tm_g_lineplot.R

View workflow job for this annotation

GitHub Actions / SuperLinter 🦸‍♀️ / Lint R code 🧶

file=tests/testthat/test-shinytest2-tm_g_lineplot.R,line=91,col=4,[indentation_linter] Indentation should be 22 spaces but is 4 spaces.
testthat::expect_equal(app_driver$get_active_module_input("param-dataset_ADLB_singleextract-filter1-vals"), "ALT")
testthat::expect_equal(app_driver$get_active_module_input("strata-dataset_ADSL_singleextract-select"), "ARM")
testthat::expect_equal(app_driver$get_active_module_input("y-dataset_ADLB_singleextract-select"), "AVAL")
testthat::expect_equal(app_driver$get_active_module_input("mid"), "mean")
testthat::expect_equal(app_driver$get_active_module_input("interval"), "mean_ci")
testthat::expect_true(app_driver$get_active_module_input("incl_screen"))

# addtional plot settings

Check warning on line 99 in tests/testthat/test-shinytest2-tm_g_lineplot.R

View workflow job for this annotation

GitHub Actions / SuperLinter 🦸‍♀️ / Lint R code 🧶

file=tests/testthat/test-shinytest2-tm_g_lineplot.R,line=99,col=4,[indentation_linter] Indentation should be 22 spaces but is 4 spaces.
testthat::expect_equal(app_driver$get_active_module_input("conf_level"), "0.95")
testthat::expect_equal(app_driver$get_active_module_input("mid_point_size"), 2)
testthat::expect_equal(app_driver$get_active_module_input("whiskers"), c("Upper", "Lower"))
testthat::expect_equal(app_driver$get_active_module_input("mid_type"), "pl")

# addtional table settings

Check warning on line 105 in tests/testthat/test-shinytest2-tm_g_lineplot.R

View workflow job for this annotation

GitHub Actions / SuperLinter 🦸‍♀️ / Lint R code 🧶

file=tests/testthat/test-shinytest2-tm_g_lineplot.R,line=105,col=4,[indentation_linter] Indentation should be 22 spaces but is 4 spaces.
testthat::expect_equal(app_driver$get_active_module_input("table_font_size"), 4)
testthat::expect_equal(app_driver$get_active_module_input("table"), c("n", "mean_sd", "median", "range" ))

Check warning on line 107 in tests/testthat/test-shinytest2-tm_g_lineplot.R

View workflow job for this annotation

GitHub Actions / SuperLinter 🦸‍♀️ / Lint R code 🧶

file=tests/testthat/test-shinytest2-tm_g_lineplot.R,line=107,col=108,[spaces_inside_linter] Do not place spaces before parentheses.

app_driver$stop()

Check warning on line 109 in tests/testthat/test-shinytest2-tm_g_lineplot.R

View workflow job for this annotation

GitHub Actions / SuperLinter 🦸‍♀️ / Lint R code 🧶

file=tests/testthat/test-shinytest2-tm_g_lineplot.R,line=109,col=4,[indentation_linter] Indentation should be 22 spaces but is 4 spaces.
})

testthat::test_that("e2e - tm_g_lineplot: Selecting biomarker changes plot and doesn't throw validation errors.", {
skip_if_too_deep(5)
app_driver <- app_driver_tm_g_lineplot()
plot_before <- app_driver$get_active_module_pws_output("myplot")
app_driver$set_active_module_input("param-dataset_ADLB_singleextract-filter1-vals", "CRP")
testthat::expect_false(
identical(
plot_before,
app_driver$get_active_module_pws_output("myplot")
)
)
app_driver$expect_no_validation_error()
app_driver$stop()
})

testthat::test_that("e2e - tm_g_lineplot: Deselecting biomarker throws validation error.", {
skip_if_too_deep(5)
app_driver <- app_driver_tm_g_lineplot()
app_driver$set_active_module_input("param-dataset_ADLB_singleextract-filter1-vals", NULL)
testthat::expect_identical(app_driver$get_active_module_pws_output("myplot"), character(0))
testthat::expect_identical(
app_driver$active_module_element_text("param-dataset_ADLB_singleextract-filter1-vals_input > div > span"),
"Please select Biomarker filter."
)
app_driver$expect_validation_error()
app_driver$stop()
})

testthat::test_that("e2e - tm_g_lineplot: Selecting treatment variable changes plot and doesn't throw validation errors.", {

Check warning on line 140 in tests/testthat/test-shinytest2-tm_g_lineplot.R

View workflow job for this annotation

GitHub Actions / SuperLinter 🦸‍♀️ / Lint R code 🧶

file=tests/testthat/test-shinytest2-tm_g_lineplot.R,line=140,col=121,[line_length_linter] Lines should not be more than 120 characters. This line is 124 characters.
skip_if_too_deep(5)
app_driver <- app_driver_tm_g_lineplot()
plot_before <- app_driver$get_active_module_pws_output("myplot")
app_driver$set_active_module_input("strata-dataset_ADSL_singleextract-select", "ARMCD")
testthat::expect_false(
identical(
plot_before,
app_driver$get_active_module_pws_output("myplot")
)
)
app_driver$expect_no_validation_error()
app_driver$stop()
})

testthat::test_that("e2e - tm_g_lineplot: Deselecting treatment variable throws validation error.", {
skip_if_too_deep(5)
app_driver <- app_driver_tm_g_lineplot()
app_driver$set_active_module_input("strata-dataset_ADSL_singleextract-select", NULL)
testthat::expect_identical(app_driver$get_active_module_pws_output("myplot"), character(0))
testthat::expect_identical(
app_driver$active_module_element_text("strata-dataset_ADSL_singleextract-select_input > div > span"),
"Please select a treatment variable"
)
app_driver$expect_validation_error()
app_driver$stop()
})

testthat::test_that("e2e - tm_g_lineplot: Selecting analysis variable changes plot and doesn't throw validation errors.", {

Check warning on line 168 in tests/testthat/test-shinytest2-tm_g_lineplot.R

View workflow job for this annotation

GitHub Actions / SuperLinter 🦸‍♀️ / Lint R code 🧶

file=tests/testthat/test-shinytest2-tm_g_lineplot.R,line=168,col=121,[line_length_linter] Lines should not be more than 120 characters. This line is 123 characters.
skip_if_too_deep(5)
app_driver <- app_driver_tm_g_lineplot()
plot_before <- app_driver$get_active_module_pws_output("myplot")
app_driver$set_active_module_input("y-dataset_ADLB_singleextract-select", "BASE")
testthat::expect_false(
identical(
plot_before,
app_driver$get_active_module_pws_output("myplot")
)
)
app_driver$expect_no_validation_error()
app_driver$stop()
})

testthat::test_that("e2e - tm_g_lineplot: Deselecting analysis variable throws validation error.", {
skip_if_too_deep(5)
app_driver <- app_driver_tm_g_lineplot()
app_driver$set_active_module_input("y-dataset_ADLB_singleextract-select", NULL)
testthat::expect_identical(app_driver$get_active_module_pws_output("myplot"), character(0))
testthat::expect_identical(
app_driver$active_module_element_text("y-dataset_ADLB_singleextract-select_input > div > span"),
"Please select an analysis variable"
)
app_driver$expect_validation_error()
app_driver$stop()
})

testthat::test_that("e2e - tm_g_lineplot: Selecting confidence level changes plot and doesn't throw validation errors.", {
skip_if_too_deep(5)
app_driver <- app_driver_tm_g_lineplot()
plot_before <- app_driver$get_active_module_pws_output("myplot")
app_driver$set_active_module_input("conf_level", "0.8")
testthat::expect_false(
identical(
plot_before,
app_driver$get_active_module_pws_output("myplot")
)
)
app_driver$expect_no_validation_error()
app_driver$stop()
})

testthat::test_that("e2e - tm_g_lineplot: Deselecting confidence level validation error.", {
skip_if_too_deep(5)
app_driver <- app_driver_tm_g_lineplot()
app_driver$set_active_module_input("conf_level", NULL)
testthat::expect_identical(app_driver$get_active_module_pws_output("myplot"), character(0))
testthat::expect_identical(
app_driver$active_module_element_text("conf_level_input > div > span"),
"Please choose a confidence level"
)
app_driver$expect_validation_error()
app_driver$stop()
})
Loading