Skip to content

Commit

Permalink
Revert "plot with settings test ui (#135)"
Browse files Browse the repository at this point in the history
This reverts commit fce6bc9.
  • Loading branch information
BLAZEWIM authored Jan 11, 2023
1 parent 2fc873b commit 539691a
Show file tree
Hide file tree
Showing 8 changed files with 2 additions and 86 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@ Encoding: UTF-8
Language: en-US
LazyData: true
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.2.3
RoxygenNote: 7.2.1
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
49 changes: 0 additions & 49 deletions tests/testthat/helpers-with-settings.R
Original file line number Diff line number Diff line change
Expand Up @@ -31,55 +31,6 @@ app_tws <- function() {
)
}

#' Plot with settings app
#'
#' @description Example plot with setting app for testing using \code{shinytest2}
#'
#' @keywords internal
#'
app_pws <- function() {
shiny::shinyApp(
ui = shiny::fluidPage(
shinyjs::useShinyjs(),
shiny::actionButton("button", "Show/Hide"),
plot_with_settings_ui(
id = "plot_with_settings"
)
),
server = function(input, output, session) {
plot_r <- shiny::reactive({
ggplot2::ggplot(data.frame(x = 1:5, y = 1:5)) +
ggplot2::geom_point(ggplot2::aes(x = 1:5, y = 1:5))
})

show_hide_signal <- shiny::reactiveVal(TRUE)

shiny::observeEvent(input$button, {
show_hide_signal(
!show_hide_signal()
)
})

plot_data <- plot_with_settings_srv(
id = "plot_with_settings",
plot_r = plot_r,
height = c(400, 100, 1200),
width = c(500, 250, 750),
brushing = TRUE,
clicking = TRUE,
dblclicking = TRUE,
hovering = TRUE,
show_hide_signal = show_hide_signal
)

shiny::exportTestValues(
plot_r = plot_r,
plot_data = plot_data
)
}
)
}

#' Function to check if a function has a side effect of drawing something
#' @param `function` function which possibly draws something.
#' @return `logical(1)` whether the function has a side effect of drawing a plot.
Expand Down
37 changes: 1 addition & 36 deletions tests/testthat/test-plot_with_settings_ui.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,39 +6,4 @@ testthat::test_that("plot_with_settings_ui returns shiny.tag.list", {
testthat::expect_s3_class(plot_with_settings_ui("STH"), "shiny.tag.list")
})

testthat::test_that("Plot with settings: UI screenshots", {
skip_on_cran()
skip_on_ci()
app <- AppDriver$new(
app_pws(),
name = "pws",
variant = "app_pws_ui"
)
threshold <- 60
kernel_size <- 20
delay <- 0.3

# click on hide/show button
app$click("button")
app$expect_screenshot(
threshold = threshold, kernel_size = kernel_size, delay = delay, name = "hidden"
)
app$click("button")
app$expect_screenshot(
threshold = threshold, kernel_size = kernel_size, delay = delay, name = "visible"
)

app$set_inputs(`plot_with_settings-downbutton-file_name` = "plot1")
app$set_inputs(`plot_with_settings-modal_downbutton-file_name` = "plot2")

app$click("plot_with_settings-downbutton-downl")
app$expect_screenshot(
threshold = threshold, kernel_size = kernel_size, delay = delay, name = "download_menu"
)
app$click("plot_with_settings-expbut")
app$expect_screenshot(
threshold = threshold, kernel_size = kernel_size, delay = delay, name = "resize_menu"
)

app$stop()
})
library(shinytest2)

0 comments on commit 539691a

Please sign in to comment.