Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug shinytest with rhandsontable when using hot_validate_numeric #413

Open
stla opened this issue Sep 18, 2021 · 1 comment
Open

Bug shinytest with rhandsontable when using hot_validate_numeric #413

stla opened this issue Sep 18, 2021 · 1 comment

Comments

@stla
Copy link

stla commented Sep 18, 2021

Hello,

The app:

library(shiny)
library(rhandsontable)

ui <- fluidPage(
  br(),
  uiOutput("tables")
)

server <- function(input, output, session){

  output[["hot1"]] <- renderRHandsontable({
    rhandsontable(head(iris))
  })

  output[["hot2"]] <- renderRHandsontable({
    rhandsontable(head(iris)) 
  })

  output[["tables"]] <- renderUI({
    tagList(
      rHandsontableOutput("hot1"),
      br(),
      rHandsontableOutput("hot2")
    )
  })

}

shinyApp(ui, server)

The shinytest script:

library(shinytest)
app <- ShinyDriver$new(".", loadTimeout = 1e+05,
                       shinyOptions = list(test.mode = TRUE))
app$snapshotInit("mytest")

script <-
  "var table = HTMLWidgets.getInstance(hot1).hot;"
script2 <-
  "var t = document.getElementById('hot2').htmlwidget_data_init_result.hot;"


hot <-
  app$waitForValue("hot2", ignore = list(NULL), timeout=20000, iotype = "output")

app$snapshot()
app$executeScript(script)
app$executeScript(script2)
app$snapshot()

app$stop()

No problem.

Now, replace output[["hot2"]] with

  output[["hot2"]] <- renderRHandsontable({
    rhandsontable(head(iris)) %>%
      hot_validate_numeric(col = 1, min = 0, max = 100)
  })

The app works fine. But the shinytest script throws these errors:

> app$executeScript(script)
Error in session_makeRequest(self, private, endpoint, data, params, headers) : 
  undefined is not an object (evaluating 'HTMLWidgets.getInstance(hot1).hot')
> app$executeScript(script2)
Error in session_makeRequest(self, private, endpoint, data, params, headers) : 
  undefined is not an object (evaluating 'document.getElementById('hot2').htmlwidget_data_init_result.hot')
@stla
Copy link
Author

stla commented Sep 19, 2021

Duplicate of #380

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant