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

Error with shinydashboard #167

Closed
dchen71 opened this issue Dec 20, 2017 · 9 comments · Fixed by rstudio/shinydashboard#256
Closed

Error with shinydashboard #167

dchen71 opened this issue Dec 20, 2017 · 9 comments · Fixed by rstudio/shinydashboard#256

Comments

@dchen71
Copy link

dchen71 commented Dec 20, 2017

I am having problems running tests using shinydashboard. For instance, I get Unable to find input binding for element with id sidebarCollapsed if I were to use sidebars. Similarly, I get errors with testing the tabitems with sidebarItemExpanded.

@wch
Copy link
Collaborator

wch commented Jan 11, 2018

@dchen71 Could you provide a simple reproducible example?

@dchen71
Copy link
Author

dchen71 commented Jan 11, 2018

The relevant package versions are the following:

  • shinydashboard_0.6.1
  • shiny_1.0.5
  • shinytest_1.2.0.9001

app.R

#
# This is a Shiny web application. You can run the application by clicking
# the 'Run App' button above.
#
# Find out more about building applications with Shiny here:
#
#    http://shiny.rstudio.com/
#

library(shiny)
library(shinydashboard)

ui <- dashboardPage(
  dashboardHeader(title = "Basic dashboard"),
  ## Sidebar content
  dashboardSidebar(
    sidebarMenu(
      menuItem("Dashboard", tabName = "dashboard", icon = icon("dashboard")),
      menuItem("Widgets", tabName = "widgets", icon = icon("globe"),
               menuSubItem("Widget1", tabName = "widget1", icon = icon("blind")),
               menuSubItem("Widget2", tabName = "widget2", icon = icon("binoculars")))
    )
  ),
  ## Body content
  dashboardBody(
    tabItems(
      # First tab content
      tabItem(tabName = "dashboard",
              fluidRow(
                box(plotOutput("plot1", height = 250)),
                
                box(
                  title = "Controls",
                  sliderInput("slider", "Number of observations:", 1, 100, 50)
                )
              )
      ),
      
      # Second tab content
      tabItem(tabName = "widget1",
              h2("Widgets1 tab content")
      ),
      # Second tab content
      tabItem(tabName = "widget2",
              h2("Widgets2 tab content")
      )
    )
  )
)

server <- function(input, output) {
  set.seed(122)
  histdata <- rnorm(500)
  
  output$plot1 <- renderPlot({
    data <- histdata[seq_len(input$slider)]
    hist(data)
  })
}

shinyApp(ui, server)

To start recording

library(shinytest)

recordTest(".")

myTest.R(Test script)

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

app$setInputs(sidebarCollapsed = FALSE)
app$setInputs(sidebarItemExpanded = "Widgets")
app$setInputs(sidebarItemExpanded = character(0))
app$snapshot()

@wch
Copy link
Collaborator

wch commented Jan 11, 2018

Thanks, I've been able to reproduce it. It seems likely that it's an issue with shinydashboard.

@dchen71
Copy link
Author

dchen71 commented Jan 11, 2018

Does it seem like an issue over on my end or with the package itself? If it's with the package, should I close this bug and open it up on shinydashboard instead?

@wch
Copy link
Collaborator

wch commented Jan 12, 2018

Sure, I'm already working on a fix, but it wouldn't hurt to open an issue on shinydashboard.

@samuelhuerga
Copy link

Hi!

I'm facing the same issue when trying to run a test with a shinydashboard app. Is there any news about the fix? Is there any workaround meanwhile?

Thanks!

@wch
Copy link
Collaborator

wch commented Jan 26, 2018

Hi all, I've fixed this in the dev version of shinydashboard.

@alastairrushworth
Copy link

alastairrushworth commented Jun 27, 2018

I have a related issue when trying to test/click tab items using shinytest after expanding a sidebar menu item.

Using the app provided by @dchen71 above, the code below is recorded in which the 'Widgets' sidebarItem is expanded, and the sub item widgets1 is selected. However, in the resulting script there is no record of the subItem.

app <- ShinyDriver$new("../")
app$snapshotInit("mytest")
app$setInputs(sidebarCollapsed = FALSE)
app$setInputs(sidebarItemExpanded = "Widgets")
app$snapshot()

After running the commands above, and running app$listWidgets()$input returns only:

[1] "sidebarCollapsed" "sidebarItemExpanded" "slider"

Is it possible to select a sidebarItem after expanding the parent?

@romunov
Copy link

romunov commented Nov 22, 2018

Same problem in shinydashboard where I have a selectInput in absolutePanel (here).

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

Successfully merging a pull request may close this issue.

5 participants