diff --git a/tests/testthat/_snaps/boxplot.md b/tests/testthat/_snaps/boxplot.md index ab184a4f..1fbe57a7 100644 --- a/tests/testthat/_snaps/boxplot.md +++ b/tests/testthat/_snaps/boxplot.md @@ -7,14 +7,14 @@ $ fill : chr "#F8766D" "#F8766D" "#F8766D" "#F8766D" ... $ x : 'mapped_discrete' num 1 1 1 1 1 1 1 1 1 1 ... $ density : num 0.000161 0.000161 0.000161 0.00016 0.00016 ... - $ scaled : num 0.492 0.492 0.492 0.492 0.492 ... - $ ndensity : num 0.492 0.492 0.492 0.492 0.492 ... + $ scaled : num 0.493 0.492 0.492 0.492 0.492 ... + $ ndensity : num 0.493 0.492 0.492 0.492 0.492 ... $ count : num 0.000642 0.000642 0.000642 0.000642 0.000641 ... $ n : int 4 4 4 4 4 4 4 4 4 4 ... $ y : num 650 659 667 676 684 ... $ PANEL : Factor w/ 1 level "1": 1 1 1 1 1 1 1 1 1 1 ... $ group : int 1 1 1 1 1 1 1 1 1 1 ... - $ violinwidth: num 0.492 0.492 0.492 0.492 0.492 ... + $ violinwidth: num 0.493 0.492 0.492 0.492 0.492 ... $ flipped_aes: logi FALSE FALSE FALSE FALSE FALSE FALSE ... $ width : num 0.9 0.9 0.9 0.9 0.9 0.9 0.9 0.9 0.9 0.9 ... $ xmin : 'mapped_discrete' num 0.55 0.55 0.55 0.55 0.55 0.55 0.55 0.55 0.55 0.55 ... diff --git a/tests/testthat/_snaps/pca.md b/tests/testthat/_snaps/pca.md index 3158989b..a1fef91c 100644 --- a/tests/testthat/_snaps/pca.md +++ b/tests/testthat/_snaps/pca.md @@ -54,16 +54,6 @@ 8 -0.30521740 -0.58893592 1 -1 19 black 1.5 NA NA 0.5 9 -0.44180789 0.50479025 1 -1 19 black 1.5 NA NA 0.5 ---- - - Code - cat(res) - Output - colour x y PANEL group shape size fill alpha stroke - 1 #F8766D -0.08263642 0.6615253 1 1 19 1.5 NA NA 0.5 - 2 #F8766D -0.53157947 -0.4023279 1 1 19 1.5 NA NA 0.5 - 3 #F8766D 0.61421589 -0.2591974 1 1 19 1.5 NA NA 0.5 - --- Code diff --git a/tests/testthat/adtteSpec/app.R b/tests/testthat/adtteSpec/app.R index 69b1bb56..9c56af07 100644 --- a/tests/testthat/adtteSpec/app.R +++ b/tests/testthat/adtteSpec/app.R @@ -1,3 +1,4 @@ +library(dplyr) library(teal.modules.hermes) ui <- function(id) { diff --git a/tests/testthat/helper-shinytest2.R b/tests/testthat/helper-shinytest2.R index 9f6db218..fa459dc5 100644 --- a/tests/testthat/helper-shinytest2.R +++ b/tests/testthat/helper-shinytest2.R @@ -9,7 +9,6 @@ module_ns_shiny2 <- function(app) { NS(paste0(module_id, "-module")) } -ns2 <- NS("teal-main_ui-filter_panel") default_app_seed <- 123 # expect_select_screenshot ---- diff --git a/tests/testthat/test-adtteSpec.R b/tests/testthat/test-adtteSpec.R index f4d30215..e74a8406 100644 --- a/tests/testthat/test-adtteSpec.R +++ b/tests/testthat/test-adtteSpec.R @@ -223,23 +223,23 @@ test_that("adtteSpecServer module works as expected in the test app", { res <- app$get_value(input = ns("adtte-paramcd")) # Test what happens if selected endpoint (here PFS) is no longer in filtered data. - app$set_inputs(!!ns2("add-ADTTE-filter-var_to_add") := "PARAMCD") - app$set_inputs(!!ns2("active-ADTTE-filter-ADTTE_PARAMCD-inputs-selection") := "OS") - + app$set_inputs(`teal-teal_modules-adttespec_example-filter_panel-filters-ADTTE-ADTTE-filter-var_to_add` = "PARAMCD", allow_no_input_binding_ = TRUE) + app$set_inputs(`teal-teal_modules-adttespec_example-filter_panel-filters-ADTTE-filter-ADTTE_PARAMCD-inputs-selection` = "OS") app$wait_for_idle(timeout = 20000) - # We expect to get a validation message (also a notification box but we cannot test that) + # We expect to get a validation message + res <- app$get_value(input = ns("adtte-paramcd")) + expect_identical(res, "") res <- app$get_value(output = ns("summary")) expect_equal(res$message, "please select an endpoint") - res <- app$get_value(input = ns("adtte-paramcd")) - expect_equal(res, "") # Now we update the filter by adding PFS back. However the user would have to # actively select it. - app$set_inputs(!!ns2("active-ADTTE-filter-ADTTE_PARAMCD-inputs-selection") := c("PFS", "OS")) + app$set_inputs(`teal-teal_modules-adttespec_example-filter_panel-filters-ADTTE-filter-ADTTE_PARAMCD-inputs-selection` := c("PFS", "OS")) app$wait_for_idle() res <- app$get_value(output = ns("summary")) expect_equal(res$message, "please select an endpoint") + app$click("teal-teal_modules-adttespec_example-filter_panel-filters-ADTTE-filter-ADTTE_PARAMCD-remove") app$stop() }) diff --git a/tests/testthat/test-experimentSpec.R b/tests/testthat/test-experimentSpec.R index 427fee0e..39be7965 100644 --- a/tests/testthat/test-experimentSpec.R +++ b/tests/testthat/test-experimentSpec.R @@ -149,45 +149,16 @@ test_that("experimentSpec module works as expected in the test app", { res <- app$get_value(output = ns("summary")) expect_match(res, "HermesData object with 9 samples of 2500 genes") - # Filtering out all samples does give a validation message, so we are safe - # downstream. - app$set_inputs(!!ns2("add-MAE-subjects-var_to_add") := "SEX") + # Filtering out all samples using right side panel + app$set_inputs(`teal-teal_modules-experimentspec_example-filter_panel-filters-MAE-MAE-subjects-var_to_add` = "AGE18", allow_no_input_binding_ = TRUE) + app$set_inputs(`teal-teal_modules-experimentspec_example-filter_panel-filters-MAE-subjects-MAE_AGE18-inputs-selection` = character(0)) app$wait_for_idle() - app$set_inputs(!!ns2("active-MAE-subjects-MAE_SEX-inputs-selection") := character()) - app$wait_for_idle() - # Experiment selection is not affected by filtering res <- app$get_value(input = ns("my_experiment-name")) expect_identical(res, "hd2") - res <- app$get_value(output = ns("summary")) expect_match(res$message, "No genes or samples included in this experiment, please adjust filters") - app$click(ns2("active-MAE-remove_filters")) - - # Same for filtering out all genes. - app$set_inputs(!!ns2("add-MAE-hd2-row_to_add") := "chromosome") - app$wait_for_idle() - app$set_inputs( - !!ns2("active-MAE-hd2-MAE_chromosome_hd2_subset-inputs-selection_open") := TRUE, - allow_no_input_binding_ = TRUE - ) - app$set_inputs(!!ns2("active-MAE-hd2-MAE_chromosome_hd2_subset-inputs-selection") := character(0)) - app$set_inputs( - !!ns2("active-MAE-hd2-MAE_chromosome_hd2_subset-inputs-selection_open") := FALSE, - allow_no_input_binding_ = TRUE - ) - app$wait_for_idle() - - # Experiment selection is not affected by filtering - res <- app$get_value(input = ns("my_experiment-name")) - expect_identical(res, "hd2") - - res <- app$get_value(output = ns("summary")) - expect_match(res$message, "No genes or samples included in this experiment, please adjust filters") - - # return to initial situation - app$click(ns2("active-MAE-remove_filters")) - app$wait_for_idle() + app$click("teal-teal_modules-experimentspec_example-filter_panel-filters-MAE-subjects-MAE_AGE18-remove") # Experiment selection is not affected by removing filters res <- app$get_value(input = ns("my_experiment-name")) diff --git a/tests/testthat/test-geneSpec.R b/tests/testthat/test-geneSpec.R index f59e9e89..84060d19 100644 --- a/tests/testthat/test-geneSpec.R +++ b/tests/testthat/test-geneSpec.R @@ -72,21 +72,14 @@ test_that("geneSpec module works as expected in the test app", { res <- app$get_value(output = ns("result")) expect_identical(res, "mean(ABCF2, ABO, ..., ADAMTS5)") - # Add chromosome filters for the first experiment. - app$set_inputs(!!ns2("add-MAE-hd1-row_to_add") := "chromosome") - # Lock the gene selection. + # lock the gene selection app$set_inputs(!!ns("my_genes-lock_button") := TRUE) - app$wait_for_idle() - app$set_inputs( - !!ns2("active-MAE-hd2-MAE_chromosome_hd1_subset-inputs-selection_open") := TRUE, - allow_no_input_binding_ = TRUE - ) - app$set_inputs(!!ns2("active-MAE-hd1-MAE_chromosome_hd1_subset-inputs-selection") := c("1", "2")) - app$set_inputs( - !!ns2("active-MAE-hd1-MAE_chromosome_hd1_subset-inputs-selection_open") := FALSE, - allow_no_input_binding_ = TRUE - ) + + # Filter data using the right side panel + app$set_inputs(`teal-teal_modules-genespec_example-filter_panel-filters-MAE-MAE-hd1-row_to_add` = "chromosome", allow_no_input_binding_ = TRUE) + app$set_inputs(`teal-teal_modules-genespec_example-filter_panel-filters-MAE-hd1-MAE_chromosome_hd1_subset-inputs-selection` = c("1", "2")) + app$set_inputs(`teal-teal_modules-genespec_example-filter_panel-filters-MAE-hd1-MAE_chromosome_hd1_subset-inputs-selection_open` = FALSE, allow_no_input_binding_ = TRUE) app$wait_for_idle() # Confirm that gene selection was not changed. @@ -115,7 +108,7 @@ test_that("geneSpec module works as expected in the test app", { expect_identical(res, "mean(ACP1, ACTN2)") # Remove the filter. - app$click(ns2("active-MAE-hd1-MAE_chromosome_hd1_subset-remove")) + app$click("teal-teal_modules-genespec_example-filter_panel-filters-MAE-hd1-MAE_chromosome_hd1_subset-remove") # Select a gene via text input. app$click(ns("my_genes-text_button")) diff --git a/tests/testthat/test-pca.R b/tests/testthat/test-pca.R index 50a8ad59..7823f01d 100644 --- a/tests/testthat/test-pca.R +++ b/tests/testthat/test-pca.R @@ -62,19 +62,17 @@ test_that("pca module works as expected in the test app", { ) # Add a gene filter and deselect everything and check that it does not crash. - app$set_inputs(!!ns2("add-MAE-hd1-row_to_add") := "chromosome_name") + app$set_inputs(`teal-teal_modules-pca-filter_panel-filters-MAE-MAE-hd1-row_to_add` = "chromosome", allow_no_input_binding_ = TRUE) + app$set_inputs(`teal-teal_modules-pca-filter_panel-filters-MAE-hd1-MAE_chromosome_hd1_subset-inputs-selection` = character()) + app$set_inputs(`teal-teal_modules-pca-filter_panel-filters-MAE-hd1-MAE_chromosome_hd1_subset-inputs-selection_open` = FALSE, allow_no_input_binding_ = TRUE) app$wait_for_idle() - app$set_inputs(!!ns2("active-MAE-hd1-MAE_chromosome_name_hd1_subset-inputs-selection_open") := TRUE, allow_no_input_binding_ = TRUE) - app$set_inputs(!!ns2("active-MAE-hd1-MAE_chromosome_name_hd1_subset-inputs-keep_na-value") := FALSE) - app$set_inputs(!!ns2("active-MAE-hd1-MAE_chromosome_name_hd1_subset-inputs-selection") := character()) - app$set_inputs(!!ns2("active-MAE-hd1-MAE_chromosome_name_hd1_subset-inputs-selection_open") := FALSE, allow_no_input_binding_ = TRUE) - app$wait_for_idle() res <- app$get_value(output = ns("test_pca")) expect_match(res$message, "No genes or samples included in this experiment, please adjust filters") # Remove filters - app$click(ns2("active-MAE-hd1-MAE_chromosome_name_hd1_subset-remove")) + app$click("teal-teal_modules-pca-filter_panel-filters-MAE-hd1-MAE_chromosome_hd1_subset-remove") + app$wait_for_idle() # Update the tab selection. app$set_inputs(!!ns("tab_selected") := "PC and Sample Correlation") @@ -171,33 +169,24 @@ test_that("pca module works as expected in the test app", { app$set_inputs(!!ns("label") := TRUE) app$set_inputs(!!ns("show_matrix") := TRUE) - app$set_inputs(!!ns2("add-MAE-subjects-var_to_add") := "SEX") app$wait_for_idle(timeout = 40000) - app$set_inputs(!!ns2("active-MAE-subjects-MAE_SEX-inputs-selection") := "M") + app$set_inputs(`teal-teal_modules-pca-filter_panel-filters-MAE-MAE-subjects-var_to_add` = "SEX", allow_no_input_binding_ = TRUE) + app$set_inputs(`teal-teal_modules-pca-filter_panel-filters-MAE-subjects-MAE_SEX-inputs-selection` = "F") + app$set_inputs(`teal-teal_modules-pca-filter_panel-filters-MAE-subjects-MAE_SEX-inputs-selection_open` = FALSE, allow_no_input_binding_ = TRUE) - # Ensure xvar and yvar get resetted to pc1 and pc2. + # Ensure xvar and yvar DONT get reset. app$wait_for_idle(timeout = 20000) res <- app$get_value(input = ns("x_var")) - expect_identical(res, "1") + expect_identical(res, "3") res <- app$get_value(input = ns("y_var")) - expect_identical(res, "2") - - res <- app$get_value(output = ns("test_pca")) - expect_snapshot( - cat(res) - ) - - # Update to cor tab. - app$set_inputs(!!ns2("active-MAE-subjects-MAE_SEX-inputs-selection_open") := TRUE, allow_no_input_binding_ = TRUE) - app$set_inputs(!!ns2("active-MAE-subjects-MAE_SEX-inputs-selection") := "F") - app$set_inputs(!!ns2("active-MAE-subjects-MAE_SEX-inputs-selection_open") := FALSE, allow_no_input_binding_ = TRUE) + expect_identical(res, "4") app$wait_for_idle() res <- app$get_value(output = ns("test_pca")) expect_identical(res$message, "Sample size is too small. PCA needs more than 2 samples.") # Remove filter. - app$click(ns2("active-MAE-subjects-MAE_SEX-remove")) + app$click("teal-teal_modules-pca-filter_panel-filters-MAE-subjects-MAE_SEX-remove") # Initiate the use of Top Variance Genes filtering functionality. app$set_inputs(!!ns("filter_top") := TRUE) diff --git a/tests/testthat/test-scatterplot.R b/tests/testthat/test-scatterplot.R index 6aeb20ed..0bf54157 100644 --- a/tests/testthat/test-scatterplot.R +++ b/tests/testthat/test-scatterplot.R @@ -65,8 +65,11 @@ test_that("scatterplot module works as expected in the test app", { app$wait_for_idle() # Change the sample filter and confirm that genes are not updated. - app$set_inputs(!!ns2("add-MAE-subjects-var_to_add") := "SEX") - app$set_inputs(!!ns2("active-MAE-subjects-MAE_SEX-inputs-selection") := "F") + + # Filtering out all samples using right side panel + app$set_inputs(`teal-teal_modules-scatterplot-filter_panel-filters-MAE-MAE-subjects-var_to_add` = "SEX", allow_no_input_binding_ = TRUE) + app$set_inputs(`teal-teal_modules-scatterplot-filter_panel-filters-MAE-subjects-MAE_SEX-inputs-selection` = "F") + app$wait_for_idle() app$wait_for_idle() res <- app$get_value(input = ns("x_spec-genes")) @@ -75,7 +78,7 @@ test_that("scatterplot module works as expected in the test app", { expect_identical(res, "GeneID:8086") # Remove sample filter - app$click(ns2("active-MAE-subjects-MAE_SEX-remove")) + app$click("teal-teal_modules-scatterplot-filter_panel-filters-MAE-subjects-MAE_SEX-remove") app$wait_for_idle() res <- app$get_value(input = ns("x_spec-genes"))