Open cmaguire485 opened 5 years ago
Could you try:
library(jsonlite)
dat <- data.frame(row = 2, col = 0:3, value = "1")
app$setInputs(table_cell_edit = fromJSON(toJSON(dat), simplifyDataFrame = FALSE),
allowInputNoBinding_ = TRUE, priority_ = "event", wait_ = FALSE, values_ = FALSE)
Doesn't make a difference, app still crashes
I think it may be caused by the fact that the "table_cell_edit" value hasn't been initialized but I don't have time to verify it by now.
@cmaguire485 Would you mind to install this branch and see if it works?
remotes::install_github('rstudio/DT', ref = "fix716")
Doesn't make a difference, app still crashes
Perhaps there's another error. I'm pretty sure that the good "format" for table_cell_edit
is
table_cell_edit = fromJSON(toJSON(dat), simplifyDataFrame = FALSE)
For me there's no crash with this shinytest:
app <- ShinyDriver$new("../", loadTimeout = 1e+05,
shinyOptions = list(test.mode = TRUE))
app$snapshotInit("mytest")
dat <- data.frame(row = 2, col = 0:3, value = "1")
library(jsonlite)
app$setInputs(table_cell_edit = fromJSON(toJSON(dat), simplifyDataFrame = FALSE),
allowInputNoBinding_ = TRUE, timeout_ = 10000, priority_ = "event", wait_ = FALSE, values_ = FALSE)
app$snapshot()
Is it working for you, or just not crashing?
For me, running that code produces a screenshot where the 3 numbers at the bottom are unchanged. If you introduce a Sys.sleep(1)
immediately before the snapshot then the screenshot it produces is now greyed out.
Yes, it doesn't crash, but nothing happens.
@shrektan apologies, forgot to get back to you - no, it didn't work
I'm trying to create unit tests for a shiny app I've been working on but can't work out how to input values to an editable DT table.
Example app:
Example test:
I've kept this mostly how it came out when I recorded the test (
recordTest(".")
), but I've corrected the setInputs values of table_cell_edit and table_cell_clicked (which came out as vectors instead of dataframes).This gives the error:
Error in sd_getAllValues(self, private, input, output, export) : Unable to fetch all values from server. Is target app running with options(shiny.testmode=TRUE?)
Running in test mode does not fix the issue.
Have already asked here: https://stackoverflow.com/questions/58097212/testing-editable-dt-using-shinytest
By filing an issue to this repo, I promise that
xfun::session_info('DT')
. I have upgraded all my packages to their latest versions (e.g., R, RStudio, and R packages), and also tried the development version:remotes::install_github('rstudio/DT')
.I understand that my issue may be closed if I don't fulfill my promises.