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

404 for expected values #356

Open
simon-smart88 opened this issue Sep 1, 2023 · 1 comment
Open

404 for expected values #356

simon-smart88 opened this issue Sep 1, 2023 · 1 comment

Comments

@simon-smart88
Copy link

simon-smart88 commented Sep 1, 2023

Hello

I've encountered an error whilst testing:


Error in `app_expect_values(self, private, ..., input = input, output = output, 
    export = export, screenshot_args = screenshot_args, name = name, 
    cran = cran)`: Shiny server returned 404 for values URL: http://127.0.0.1:5711/session/bc777a48fd9d472a3a1f837f1ece2d67/dataobj/shinytest?w=&nonce=c7e7d7b16&input=1&output=1&export=1&format=json&sortC=1
ℹ Is `shiny::runApp(test.mode = TRUE)` enabled?
Backtrace:
    ▆
 1. └─app$expect_values() at test-shinytest2.R:16:2
 2.   └─shinytest2:::app_expect_values(...)
 3.     └─shinytest2:::app_httr_get(...)
 4.       └─shinytest2 (local) fn_404(req)
 5.         └─shinytest2:::app_abort(...)
 6.           └─rlang::abort(..., app = self, call = call)

I've managed to establish that it's caused by an interaction between my use of gargoyle and leaflet.extras. When the app either contains leaflet.extras::addDrawToolbar without gargoyle everything is fine, and similarly if I create a simple app using just gargoyle everything works fine. Here's an MRE and the test which fails to run: (what was extra confusing, is that I encountered this on my first use of shinytest2 and so I spent hours trying to enable test.mode = TRUE)

library(shiny)
library(leaflet)
library(leaflet.extras)
library(gargoyle)

shiny_app <- shinyApp(
  fluidPage(
    leafletOutput("map",width=500,height=500),
    verbatimTextOutput("coords")
  ),
  function(input, output) {

    output$map <- renderLeaflet(
      leaflet() %>%
        setView(0, 0, zoom = 2) %>%
        addProviderTiles('Esri.WorldTopoMap') %>%
        addDrawToolbar(polylineOptions=F,circleOptions = F, rectangleOptions = T, markerOptions = F, circleMarkerOptions = F, singleFeature = T,polygonOptions = F)
    )

    common_class <- R6::R6Class(
      classname = "common",
      public = list(
        poly = NULL
      )
    )
    gargoyle::init("change_poly")

    common <- common_class$new()

    observe({
      coords <- unlist(input$map_draw_new_feature$geometry$coordinates)
      xy <- matrix(c(coords[c(TRUE,FALSE)], coords[c(FALSE,TRUE)]), ncol=2)
      colnames(xy) <- c('longitude', 'latitude')
      common$poly <- xy
      gargoyle::trigger("change_poly")
    }) %>% bindEvent(input$map_draw_new_feature)

      output$coords <- renderText({
      common$poly}) %>% bindEvent(gargoyle::watch("change_poly"))
  }
)
test_that("{shinytest2} recording: testing_bug", {
  app <- AppDriver$new(name = "testing_bug", height = 909, width = 1379)
  app$set_inputs(map_groups = "editableFeatureGroup", allow_no_input_binding_ = TRUE)
  app$set_inputs(map_draw_start = "rectangle", allow_no_input_binding_ = TRUE)
  app$set_inputs(map_draw_new_feature = c("Feature", 76, "rectangle", "Polygon",
      c(c(2.460938, 18.312811), c(2.460938, 28.921631), c(15.820313, 28.921631),
          c(15.820313, 18.312811), c(2.460938, 18.312811))), allow_no_input_binding_ = TRUE)
  app$set_inputs(map_draw_all_features = c("FeatureCollection", c("Feature", 76,
      "rectangle", "Polygon", c(c(2.460938, 18.312811), c(2.460938, 28.921631), c(15.820313,
          28.921631), c(15.820313, 18.312811), c(2.460938, 18.312811)))), allow_no_input_binding_ = TRUE)
  app$set_inputs(map_draw_stop = "rectangle", allow_no_input_binding_ = TRUE)
  app$set_inputs(map_click = c(18.3128108464255, 15.8203125, 0.384901733059819),
      allow_no_input_binding_ = TRUE)
  app$expect_values()
})
@nick-youngblut
Copy link

nick-youngblut commented Dec 1, 2023

I'm also getting a Shiny server returned 404 for values URL error.

The error seems to provide no information on the cause of the issue. Instead, one just gets "something went wrong, good luck fixing it". This leads to such tragedies as:

and so I spent hours trying to enable test.mode = TRUE


In my case, using shinytest2::record_test() provided a full log of the error. The cause of the error was a mis-named function.

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