diff --git a/R/tm_g_distribution.R b/R/tm_g_distribution.R index d7f4eeca7..9e8319302 100644 --- a/R/tm_g_distribution.R +++ b/R/tm_g_distribution.R @@ -245,7 +245,17 @@ ui_distribution <- function(id, ...) { tags$h3("Statistics Table"), DT::dataTableOutput(ns("summary_table")), tags$h3("Tests"), - DT::dataTableOutput(ns("t_stats")) + conditionalPanel( + sprintf("input['%s'].length === 0", ns("dist_tests")), + div( + id = ns("please_select_a_test"), + "Please select a test" + ) + ), + conditionalPanel( + sprintf("input['%s'].length > 0", ns("dist_tests")), + DT::dataTableOutput(ns("t_stats")) + ) ), encoding = tags$div( ### Reporter @@ -1101,7 +1111,7 @@ srv_distribution <- function(id, dist_tests <- input$dist_tests t_dist <- input$t_dist - validate(need(dist_tests, "Please select a test")) + req(dist_tests) teal::validate_inputs(iv_dist) diff --git a/tests/testthat/test-shinytest2-tm_g_distribution.R b/tests/testthat/test-shinytest2-tm_g_distribution.R index df32d82c4..73d06b858 100644 --- a/tests/testthat/test-shinytest2-tm_g_distribution.R +++ b/tests/testthat/test-shinytest2-tm_g_distribution.R @@ -74,7 +74,7 @@ testthat::test_that("e2e - tm_g_distribution: Histogram encoding inputs produce app_driver <- app_driver_tm_g_distribution() app_driver$set_active_module_input("main_type", "Density") - app_driver$expect_validation_error() # test needs to be updated to remove validation error + app_driver$expect_no_validation_error() app_driver$set_active_module_input("dist_tests", "Shapiro-Wilk") # Encodings in the Histogram tab @@ -112,8 +112,6 @@ testthat::test_that("e2e - tm_g_distribution: QQ plot encoding inputs produce ou # Encodings in the QQplot tab app_driver$set_active_module_input("main_type", "Density") - app_driver$expect_validation_error() # test needs to be updated to remove validation error - app_driver$set_active_module_input("dist_tests", "Shapiro-Wilk") app_driver$expect_no_validation_error() app_driver$set_active_module_input("tabs", "QQplot")