Skip to content

Commit

Permalink
trying to use shinytest
Browse files Browse the repository at this point in the history
  • Loading branch information
mrjoh3 committed Feb 15, 2022
1 parent 12dcea6 commit 02e9846
Show file tree
Hide file tree
Showing 8 changed files with 753 additions and 3 deletions.
12 changes: 10 additions & 2 deletions R/editAttributes.R
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
#' mapview(st_as_sfc(zoomto_area$bbox))
#'
#' }
editAttributes <- function(dat, zoomto = NULL, col_add = TRUE, reset = TRUE, provider = 'Esri.WorldImagery'){
editAttributes <- function(dat, zoomto = NULL, col_add = TRUE, reset = TRUE, provider = 'Esri.WorldImagery', testing = FALSE){


#create base df if dat missing
Expand Down Expand Up @@ -511,6 +511,8 @@ editAttributes <- function(dat, zoomto = NULL, col_add = TRUE, reset = TRUE, pro
# provide mechanism to return after all done
observeEvent(input$donebtn, {

if (testing) stopApp()

if(grepl(class(df$data$geometry)[[1]], "sfc_GEOMETRY")){

if (any(st_is_empty(df$data$geometry))) {
Expand Down Expand Up @@ -555,7 +557,13 @@ editAttributes <- function(dat, zoomto = NULL, col_add = TRUE, reset = TRUE, pro

}

return(runApp(shinyApp(ui,server)))
# this allows shinytest to record
if (testing) {
return(shinyApp(ui,server))
} else {
return(runApp(shinyApp(ui,server)))
}


}

Expand Down
6 changes: 6 additions & 0 deletions experiments/editAttributes_testing/app.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@


library(mapedit)


editAttributes(zoomto = 'victoria', testing = TRUE)
3 changes: 3 additions & 0 deletions experiments/editAttributes_testing/tests/shinytest.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
library(shinytest)
shinytest::testApp("../")

5 changes: 5 additions & 0 deletions experiments/editAttributes_testing/tests/shinytest/test1.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
app <- ShinyDriver$new("../../")
app$snapshotInit("test1")

app$setInputs(donebtn = "click")
app$snapshot()
Loading

0 comments on commit 02e9846

Please sign in to comment.