Skip to content

Commit

Permalink
chore: add test dependencies to suggests
Browse files Browse the repository at this point in the history
  • Loading branch information
vedhav committed Oct 28, 2024
1 parent 5990855 commit 0be5c7f
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 8 deletions.
4 changes: 3 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ Suggests:
teal.data (>= 0.5.0),
tern (>= 0.7.10),
testthat (>= 3.0.4),
rvest (>= 1.0.0),
shinytest2,
utils
VignetteBuilder:
knitr,
Expand All @@ -72,7 +74,7 @@ Config/Needs/verdepcheck: insightsengineering/goshawk, rstudio/shiny,
insightsengineering/teal.widgets, yihui/knitr,
insightsengineering/nestcolor, rstudio/rmarkdown, tidyverse/stringr,
insightsengineering/teal.data, insightsengineering/tern,
r-lib/testthat
r-lib/testthat, rstudio/shinytest2, tidyverse/rvest
Config/Needs/website: insightsengineering/nesttemplate
Encoding: UTF-8
Language: en-US
Expand Down
18 changes: 14 additions & 4 deletions tests/testthat/helper-toggle-slider-utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,10 @@ set_slider_values <- function(app, values) {
)
}

#' values should be a numeric vector of length 2
#' value should be a numeric vector of length 1
#' Note that it will automatically toggle slider to be visible before setting it
set_numeric_input_values <- function(app, values) {
checkmate::assert_numeric(values, len = 2)
set_numeric_input_low <- function(app, values) {
checkmate::assert_numeric(values, len = 1)

if (is_slider_visible(app)) {
click_toggle_button(app)
Expand All @@ -80,9 +80,19 @@ set_numeric_input_values <- function(app, values) {
values[1],
wait_ = FALSE
)
}

#' value should be a numeric vector of length 1
#' Note that it will automatically toggle slider to be visible before setting it
set_numeric_input_high <- function(app, values) {
checkmate::assert_numeric(values, len = 1)

if (is_slider_visible(app)) {
click_toggle_button(app)
}
app$set_active_module_input(
"yrange_scale-value_high",
values[2],
values[1],
wait_ = FALSE
)
}
9 changes: 6 additions & 3 deletions tests/testthat/test-shinytest2-tm_g_gh_boxplot.R
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ testthat::test_that(
{
initial_range <- list(min = 0, max = 55)
new_value <- c(10, 40)
set_numeric_input_values(app_driver, new_value)
set_numeric_input_low(app_driver, new_value[1])
set_numeric_input_high(app_driver, new_value[2])
check_widgets_with_value(
app_driver,
list(
Expand All @@ -56,7 +57,8 @@ testthat::test_that(
outside the sliderInput range, sets proper sliderInput values and range",
{
new_range <- c(-5, 60)
set_numeric_input_values(app_driver, new_range)
set_numeric_input_low(app_driver, new_range[1])
set_numeric_input_high(app_driver, new_range[2])
check_widgets_with_value(
app_driver,
list(
Expand All @@ -74,7 +76,8 @@ testthat::test_that(
{
initial_range <- list(min = 0, max = 55)
new_value <- c(11, 30)
set_numeric_input_values(app_driver, new_value)
set_numeric_input_low(app_driver, new_value[1])
set_numeric_input_high(app_driver, new_value[2])
check_widgets_with_value(
app_driver,
list(
Expand Down

0 comments on commit 0be5c7f

Please sign in to comment.