Skip to content

Commit

Permalink
Fix integration test@main (#394)
Browse files Browse the repository at this point in the history
fix namespace name after teal update.

thank you for the review
  • Loading branch information
BFalquet authored Oct 17, 2024
1 parent 3003f4d commit af255ba
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 94 deletions.
6 changes: 3 additions & 3 deletions tests/testthat/_snaps/boxplot.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 ...
Expand Down
10 changes: 0 additions & 10 deletions tests/testthat/_snaps/pca.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions tests/testthat/adtteSpec/app.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
library(dplyr)
library(teal.modules.hermes)

ui <- function(id) {
Expand Down
1 change: 0 additions & 1 deletion tests/testthat/helper-shinytest2.R
Original file line number Diff line number Diff line change
Expand Up @@ -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 ----
Expand Down
14 changes: 7 additions & 7 deletions tests/testthat/test-adtteSpec.R
Original file line number Diff line number Diff line change
Expand Up @@ -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()
})

Expand Down
37 changes: 4 additions & 33 deletions tests/testthat/test-experimentSpec.R
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand Down
21 changes: 7 additions & 14 deletions tests/testthat/test-geneSpec.R
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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"))
Expand Down
35 changes: 12 additions & 23 deletions tests/testthat/test-pca.R
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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)
Expand Down
9 changes: 6 additions & 3 deletions tests/testthat/test-scatterplot.R
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand All @@ -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"))
Expand Down

0 comments on commit af255ba

Please sign in to comment.