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

appDriver ignores enableBookmarking argument #379

Open
gogonzo opened this issue Mar 28, 2024 · 1 comment
Open

appDriver ignores enableBookmarking argument #379

gogonzo opened this issue Mar 28, 2024 · 1 comment

Comments

@gogonzo
Copy link

gogonzo commented Mar 28, 2024

I'm trying to test an app which displays button conditionally depending whether bookmarkStore option is set or not.

library(shiny)

# bookmarkable shiny app
ui <- fluidPage(
  textInput("text", "Text", ""),
  uiOutput("bookmark_button")
)

server <- function(input, output, session) {
  shiny_option <- getShinyOption("bookmarkStore", "disabled")
  print(shiny_option)
  output$bookmark_button <- renderUI({
    if (shiny_option != "disabled") {
      bookmarkButton("Bookmark")
    } else {
      NULL
    }
  })
}

app <- shinyApp(ui, server, enableBookmarking = "url")
  1. The app run normally displays bookmarkButton
app

image

  1. The app run through appDriver doesn't display a button
remdr <- shinytest2::AppDriver$new(app)
browseURL(remdr$get_url())

image


Question:

  • how to force appDriver to use enableBookmarking?
@pawelru
Copy link

pawelru commented Apr 2, 2024

I have found out that it also ignores onStart argument.

library(shiny)

ui <- fluidPage(
  titlePanel("Simple Shiny App"),
  sidebarLayout(
    sidebarPanel(
      sliderInput("num_points", "Number of Points", min = 10, max = 100, value = 50)
    ),
    mainPanel(
      plotOutput("scatter_plot")
    )
  )
)

server <- function(input, output) {
  output$scatter_plot <- renderPlot({
    x <- rnorm(input$num_points)
    y <- rnorm(input$num_points)
    plot(x, y, main = "Scatter Plot", xlab = "X", ylab = "Y")
  })
}

app <- shinyApp(ui, server, onStart = function() print("hello!"))

app_driver <- shinytest2::AppDriver$new(app)
on.exit(app_driver$stop(), add = TRUE)

app_driver$get_logs()
#> {shinytest2} R  info   13:55:14.92 Start AppDriver initialization
#> {shinytest2} R  info   13:55:14.95 Starting Shiny app
#> {shinytest2} R  info   13:55:15.39 Creating new ChromoteSession
#> {shinytest2} R  info   13:55:15.90 Navigating to Shiny app
#> {shinytest2} R  info   13:55:15.92 Injecting shiny-tracer.js
#> {chromote}   JS info   13:55:15.93 shinytest2; jQuery found
#> {chromote}   JS info   13:55:15.94 shinytest2; Waiting for shiny session to connect
#> {chromote}   JS info   13:55:15.94 shinytest2; Loaded
#> {shinytest2} R  info   13:55:15.94 Waiting for Shiny to become ready
#> {chromote}   JS info   13:55:15.99 shinytest2; Connected
#> {chromote}   JS info   13:55:16.01 shinytest2; shiny:busy
#> {shinytest2} R  info   13:55:16.04 Waiting for Shiny to become idle for 200ms within 15000ms
#> {chromote}   JS info   13:55:16.04 shinytest2; Waiting for Shiny to be stable
#> {chromote}   JS info   13:55:16.10 shinytest2; shiny:idle
#> {chromote}   JS info   13:55:16.10 shinytest2; shiny:value scatter_plot
#> {chromote}   JS info   13:55:16.31 shinytest2; Shiny has been idle for 200ms
#> {shinytest2} R  info   13:55:16.31 Shiny app started
#> {shinytest2} R  info   13:55:16.32 Closing chromote session
#> {shinytest2} R  info   13:55:16.32 Ending Shiny process. Ignoring Shiny process result
#> {shiny}      R  stderr ----------- Loading required package: shiny
#> {shiny}      R  stderr ----------- Running application in test mode.
#> {shiny}      R  stderr ----------- 
#> {shiny}      R  stderr ----------- Listening on http://127.0.0.1:6377
#> {shiny}      R  stderr ----------- 
#> {shiny}      R  stdout ----------- <interrupt: >

Created on 2024-04-02 with reprex v2.1.0

There should be my hello print somewhere.

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

2 participants