[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
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

testApp fails with shinyBS #144

Closed
fabianekc opened this issue Sep 25, 2017 · 4 comments
Closed

testApp fails with shinyBS #144

fabianekc opened this issue Sep 25, 2017 · 4 comments

Comments

@fabianekc
Copy link

Testing my shiny app throws an error when I open a dialog (using shinyBS):

Running mytest.R Error in session_makeRequest(self, private, endpoint, data, params, headers) :
undefined is not a constructor (evaluating 'binding.setValue($el[0], value)')

here is my test.R:

app <- ShinyDriver$new("../")
app$snapshotInit("mytest")

app$setInputs(`oyd-startConfig` = TRUE)
# Input 'myData' was set, but doesn't have an input binding.
app$setInputs(`oyd-startConfig` = FALSE)
app$snapshot()

The code to open the dialog is:

shinyBS::bsModal(ns('startConfig'), uiOutput(ns('ctrlTrnsl_configDialogTitle')), 'launchDialog', ...

The dialog is in a separate module and to support multiple languages I use uiOutput(...) to change labels on the fly.

Any recommendations how to debug this error? (again :-)

@nFrechen
Copy link
nFrechen commented May 9, 2019

I get the same error with this app using shinyBS:

library(shiny)
library(shinyBS)

app = shinyApp(
    ui =
        fluidPage(
            sidebarLayout(
                sidebarPanel(HTML("This button will open Panel 1 using <code>updateCollapse</code>."),
                             actionButton("p1Button", "Push Me!"),
                             selectInput("styleSelect", "Select style for Panel 1",
                                         c("default", "primary", "danger", "warning", "info", "success"))
                ),
                mainPanel(
                    bsCollapse(id = "collapseExample", open = "Panel 2",
                               bsCollapsePanel("Panel 1", "This is a panel with just text ",
                                               "and has the default style. You can change the style in ",
                                               "the sidebar.", style = "info"),
                               bsCollapsePanel("Panel 2", "This panel has a generic plot. ",
                                               "and a 'success' style.", plotOutput("genericPlot"), style = "success")
                    )
                )
            )
        ),
    server =
        function(input, output, session) {
            output$genericPlot <- renderPlot(plot(rnorm(100)))
            observeEvent(input$p1Button, ({
                updateCollapse(session, "collapseExample", open = "Panel 1")
            }))
            observeEvent(input$styleSelect, ({
                updateCollapse(session, "collapseExample", style = list("Panel 1" = input$styleSelect))
            }))
        }
)

and this test script:

app <- ShinyDriver$new("../")
app$snapshotInit("mytest")

app$setInputs(collapseExample = "Panel 1")
app$snapshot()

The result is similar to the error above:

==> Testing Shiny application using 'shinytest'

Running mytest.R Error in session_makeRequest(self, private, endpoint, data, params, headers) : 
  undefined is not a function (evaluating 'binding.setValue($el[0], value)')
Calls: <Anonymous> ... session_executeScriptAsync -> <Anonymous> -> session_makeRequest -> report_error
Execution halted

Exited with status 1.

I am using shinytest v1.3.1 in R 3.6.0

@devinrkeane
Copy link

+1 on this. ShinyBS collapse panels dont seem to work well with shinytest:

app <- ShinyDriver$new('./DemosApp', loadTimeout = 10000)
app$snapshotInit("test-make-drivers")

app$setInputs(poll = "0")

#this is the collapse panel selecting
app$setInputs(reports = "Make Drivers Analysis Graph - Correlation Table", wait_ = FALSE, values_ = FALSE)

#and get the error
Error in session_makeRequest(self, private, endpoint, data, params, headers) : undefined is not a constructor (evaluating 'binding.setValue($el[0], value)')

R 3.4.4
Ubuntu 16.04
shinytest_1.3.1
shinyBS 0.61

@natbprice
Copy link

A workaround for shinyBS::bsCollapse is to create a new hidden input that indirectly sets the active panel using shinyBS::updateCollapse.

Here is a hidden select input:

conditionalPanel(
  condition = "false",
  selectInput(
    "activePanelSelect",
    label = "Active Panel:",
    choices = c("",
                "Panel A",
                "Panel B",),
    selected = ""
  )
)

Some panels:

shinyBS::bsCollapse(
  id = "myPanels",
  
  shinyBS::bsCollapsePanel("Panel A",
                           # Panel A content
                           ),
  shinyBS::bsCollapsePanel("Panel B",
                           # Panel B content
                           )
)

Create an observer to update the active panel when select input is changed:

observe({
  shinyBS::updateCollapse(session,
                          "myPanels",
                          open = input$activePanelSelect)
})

Run tests by manipulating hidden input:

# Setting active panel directly doesn't work
# app$setInputs(myPanels = "Panel A")

# Set hidden input instead
app$setInputs(activePanelSelect = "Panel A")

@hadley hadley changed the title Error in session_makeRequest testApp fails with shinyBS Aug 8, 2020
@hadley
Copy link
Member
hadley commented Aug 12, 2020

This requires changes in shinyBS — you can see what learnr needed to fix the same problem at rstudio/learnr#407.

@hadley hadley closed this as completed Aug 12, 2020
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

5 participants