Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -23,32 +23,32 @@ Depends:
testthat (>= 3.1.2)
Imports:
R6 (>= 2.4.0),
chromote (>= 0.1.0),
fs,
callr,
crayon,
rlang (>= 0.3.0),
checkmate (>= 2.0.0),
chromote (>= 0.1.0),
crayon,
ellipsis,
fs,
globals (>= 0.14.0),
httr,
jsonlite,
pingr,
rlang (>= 0.3.0),
rmarkdown,
shiny,
withr
Suggests:
diffobj,
globals (>= 0.14.0),
ggplot2,
vdiffr (>= 1.0.0),
knitr,
plotly,
rstudioapi,
shinyWidgets,
shinytest (>= 1.5.1),
shinyvalidate (>= 0.1.2),
showimage,
knitr,
usethis
usethis,
vdiffr (>= 1.0.0)
Config/Needs/check:
rstudio/shiny
Config/Needs/website:
Expand Down
9 changes: 9 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,17 @@

* Fix set of bugs found by @daattali including test files should be opened in the IDE after recording and test and replace missing images in the website (#199)

* Provide example workflows on how to use `rstudio/shinytest2/actions/test-app` GHA action (#217)

* Make `{globals}` an `Imports` package, instead of a `Suggests` package (#223)

* Add support for _not_ recording the screen size when recording a test (#223)

* When setting a date time slider value, it can now handle array inputs properly. When recording a date time slider value, numeric values will not be recorded as milliseconds instead of seconds since epoch. (#223)

* The recording browser window is now closed when either the "Save test and exit" or "Exit" buttons are clicked. (@daattali, #202)


# shinytest2 0.1.0

* Initial release of package
3 changes: 3 additions & 0 deletions R/record-test.R
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#' * be recorded.
#'
#' See [`AppDriver`]`$set_inputs()` for more information.
#' @param record_screen_size If `TRUE`, the screen size will be recorded when initialized and changed.
#' @param run_test If `TRUE`, `test_file` will be executed after saving the recording.
#' @seealso [`test_app()`]
#' @export
Expand All @@ -52,6 +53,7 @@ record_test <- function(
test_file = "test-shinytest2.R",
open_test_file = rlang::is_interactive(),
allow_no_input_binding = NULL,
record_screen_size = TRUE,
run_test = TRUE
) {
ellipsis::check_dots_empty()
Expand Down Expand Up @@ -120,6 +122,7 @@ record_test <- function(
shinytest2.seed = seed,
shinytest2.shiny.args = shiny_args,
shinytest2.test_file = test_file,
shinytest2.record_screen_size = isTRUE(record_screen_size),
shinytest2.allow_no_input_binding = allow_no_input_binding
),
# Make sure the recorder opens in an external browser
Expand Down
24 changes: 19 additions & 5 deletions inst/internal/js/shiny-tracer.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,26 @@ window.shinytest2 = (function() {
},

"shiny.sliderInput": function(el, value) {
if (typeof(value) === "string" &&
/\d\d\d\d-\d\d-\d\d/.test(value))
{
return new Date(value).getTime();
function update_date_string(x) {
if (
(
typeof(x) === "string" &&
/\d\d\d\d-\d\d-\d\d/.test(x)
) ||
(
typeof(x) === "number"
)
) {
return new Date(x).getTime();
} else {
return x;
}
}

if (value instanceof Array) {
return value.map(update_date_string);
} else {
return value;
return update_date_string(value);
}
}
};
Expand Down
14 changes: 14 additions & 0 deletions inst/internal/recorder/app.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ load_timeout <- getOption("shinytest2.load.timeout")
start_seed <- getOption("shinytest2.seed")
shiny_args <- getOption("shinytest2.shiny.args")
save_file <- getOption("shinytest2.test_file")
record_screen_size <- getOption("shinytest2.record_screen_size")
allow_no_input_binding <- getOption("shinytest2.allow_no_input_binding")

if (is.null(target_url) || is.null(app)) {
Expand Down Expand Up @@ -152,6 +153,16 @@ input_processors <- list(
shiny.action = function(value) {
structure("click", class = c("st2_click", "character"))
},
shiny.datetime = function(value) {
if (is.list(value)) {
value <- unlist(value, recursive = FALSE)
}
if (is.numeric(value)) {
# Turn seconds into milliseconds
value <- value * 1000
}
input_processors$default(value)
},

shiny.fileupload = function(value) {
# Extract filenames, then send to default processor
Expand Down Expand Up @@ -437,6 +448,9 @@ shinyApp(
# If two setWindowSize events sandwich an outputEvent,
# remove the first setWindowSize
to_remove[length(to_remove) + 1] <- i - 2
} else if (!record_screen_size && curr_event$type == "setWindowSize") {
# If we're not recording screen size, remove all setWindowSize events
to_remove[length(to_remove) + 1] <- i
}
}

Expand Down
3 changes: 3 additions & 0 deletions man/record_test.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.