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

Using shinytest to select menuSubItem in shinydashboard app #205

Closed
alastairrushworth opened this issue Jun 28, 2018 · 2 comments
Closed

Comments

@alastairrushworth
Copy link

@alastairrushworth alastairrushworth commented Jun 28, 2018

I am trying to use shinytest to simulate the following user action within an app built on shinydashboard:

  • user clicks on a sidebar menuItem which expands to reveal a number of menuSubItem
  • user clicks on a sidebar menuSubItem which should update the tab shown in dashboardBody

The code below illustrates how such an app might look. The problem is that when recordTest(".") is run for this app and the steps above are followed, the test script returned doesn't contain any reference to user selection of menuSubItems:

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

This seems related to issue #167 which has been marked as closed, but I'm still unable to resolve the problem above. I'm using the dev versions of both shinydashboard and shinytest.

library(shiny)
library(shinydashboard)

ui <- dashboardPage(
  dashboardHeader(title = "Basic dashboard"),
  ## Sidebar content
  dashboardSidebar(
    sidebarMenu(
      menuItem("Widgets", tabName = "widgets", icon = icon("globe"),
               menuSubItem("Widget1", tabName = "widget1", icon = icon("blind")), 
               menuSubItem("Widget2", tabName = "widget2", icon = icon("blind")))
    )
  ),
  ## Body content
  dashboardBody(
    tabItems(
      # Second tab content
      tabItem(tabName = "widget1", h2("Widgets1 tab content")),
      # Second tab content
      tabItem(tabName = "widget2", h2("Widgets2 tab content"))
    )
  )
)

server <- function(input, output){}
shinyApp(ui, server)
@cpsievert
Copy link
Contributor

@cpsievert cpsievert commented Apr 10, 2019

It seems as though if you add an id to sidebarMenu(), then shinytest will in fact record the user clicks on the menu items.

@wch would it make sense to include an id, by default?

@wch
Copy link
Collaborator

@wch wch commented Apr 10, 2019

Note that the answer to this question is in https://rstudio.github.io/shinydashboard/behavior.html#bookmarking

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

4 participants