tests/testthat/test-optionalSliderInputValMinMax_ui.R

app_driver_osivmm <- function() {
  ui <- bslib::page_fluid(
    shinyjs::useShinyjs(),
    tags$div(
      optionalSliderInputValMinMax("a1", "b1", 1)
    ),
    optionalSliderInputValMinMax("a2", "b2", c(3, 1, 5))
  )
  shiny::shinyApp(ui, function(input, output) {})
}


testthat::test_that(
  "e2e: teal.widgets::optionalSliderInputValMinMax: initializes",
  {
    skip_if_too_deep(5)
    app_driver <- shinytest2::AppDriver$new(
      app_driver_osivmm(),
      name = "osivmm",
      variant = "app_driver_osivmm_ui",
      wait = FALSE
    )
    app_driver$wait_for_idle()
    expect_hidden("#a1-label", app_driver)
    expect_visible("#a2-label", app_driver)
    app_driver$stop()
  }
)

testthat::test_that("we create label help for optionalSliderInputValMinMax", {
  help_text <- "my-help"
  text_slider_input_min_max <- as.character(
    optionalSliderInputValMinMax("my slider", "my label", 2, label_help = shiny::helpText(help_text))
  )
  expect_true(grepl(help_text, text_slider_input_min_max))
})

testthat::test_that("snapshot test for optionalSliderInput", {
  testthat::skip_if_not_installed("withr")
  withr::local_seed(1)
  testthat::expect_snapshot(as.character(optionalSliderInput("my slider", "my label", 0, 10, 2)))
})

Try the teal.widgets package in your browser

Any scripts or data that you put into this service are public.

teal.widgets documentation built on June 30, 2026, 5:11 p.m.