mirror of
https://github.com/rstudio/shiny.git
synced 2026-04-07 03:00:20 -04:00
Rename testEndpointUrl to testSnapshotUrl
This commit is contained in:
20
R/shiny.R
20
R/shiny.R
@@ -331,11 +331,11 @@ workerId <- local({
|
||||
#' }
|
||||
#' \item{exportTestValues()}{
|
||||
#' Registers expressions for export in test mode, available at the test
|
||||
#' endpoint URL.
|
||||
#' snapshot URL.
|
||||
#' }
|
||||
#' \item{getTestEndpointUrl(input=TRUE, output=TRUE, export=TRUE,
|
||||
#' \item{getTestSnapshotUrl(input=TRUE, output=TRUE, export=TRUE,
|
||||
#' format="json")}{
|
||||
#' Returns a URL for the test endpoint. Only has an effect when the
|
||||
#' Returns a URL for the test snapshots. Only has an effect when the
|
||||
#' \code{shiny.testmode} option is set to TRUE. For the input, output, and
|
||||
#' export arguments, TRUE means to return all of these values. It is also
|
||||
#' possible to specify by name which values to return by providing a
|
||||
@@ -415,7 +415,7 @@ ShinySession <- R6Class(
|
||||
testMode = FALSE, # Are we running in test mode?
|
||||
testExportExprs = list(),
|
||||
outputValues = list(), # Saved output values (for testing mode)
|
||||
testEndpointUrl = character(0),
|
||||
testSnapshotUrl = character(0),
|
||||
|
||||
sendResponse = function(requestMsg, value) {
|
||||
if (is.null(requestMsg$tag)) {
|
||||
@@ -580,8 +580,8 @@ ShinySession <- R6Class(
|
||||
private$outputValues <- mergeVectors(private$outputValues, values)
|
||||
},
|
||||
|
||||
enableTestEndpoint = function() {
|
||||
private$testEndpointUrl <- self$registerDataObj("shinytest", NULL,
|
||||
enableTestSnapshot = function() {
|
||||
private$testSnapshotUrl <- self$registerDataObj("shinytest", NULL,
|
||||
function(data, req) {
|
||||
if (!isTRUE(private$testMode)) {
|
||||
return()
|
||||
@@ -725,7 +725,7 @@ ShinySession <- R6Class(
|
||||
private$createBookmarkObservers()
|
||||
|
||||
private$testMode <- .globals$testMode
|
||||
private$enableTestEndpoint()
|
||||
private$enableTestSnapshot()
|
||||
|
||||
private$registerSessionEndCallbacks()
|
||||
|
||||
@@ -1343,8 +1343,8 @@ ShinySession <- R6Class(
|
||||
private$testExportExprs <- mergeVectors(private$testExportExprs, items)
|
||||
},
|
||||
|
||||
getTestEndpointUrl = function(input = TRUE, output = TRUE, export = TRUE,
|
||||
format = "rds") {
|
||||
getTestSnapshotUrl = function(input = TRUE, output = TRUE, export = TRUE,
|
||||
format = "json") {
|
||||
reqString <- function(group, value) {
|
||||
if (isTRUE(value))
|
||||
paste0(group, "=1")
|
||||
@@ -1354,7 +1354,7 @@ ShinySession <- R6Class(
|
||||
""
|
||||
}
|
||||
paste(
|
||||
private$testEndpointUrl,
|
||||
private$testSnapshotUrl,
|
||||
reqString("input", input),
|
||||
reqString("output", output),
|
||||
reqString("export", export),
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#' Register expressions for export in test mode
|
||||
#'
|
||||
#' This function registers expressions that will be evaluated when a test export
|
||||
#' event occurs. These events are triggered by accessing an API endpoint URL.
|
||||
#' event occurs. These events are triggered by accessing a snapshot URL.
|
||||
#'
|
||||
#' This function only has an effect if the app is launched in test mode. This is
|
||||
#' done by calling \code{runApp()} with \code{test.mode=TRUE}, or by setting the
|
||||
@@ -11,14 +11,14 @@
|
||||
#' @param env_ The environment in which the expression should be evaluated.
|
||||
#' @param session_ A Shiny session object.
|
||||
#' @param ... Named arguments that are quoted or unquoted expressions that will
|
||||
#' be captured and evaluated when API endpoint is visited.
|
||||
#' be captured and evaluated when snapshot URL is visited.
|
||||
#' @examples
|
||||
#' ## Only run this example in interactive R sessions
|
||||
#' if (interactive()) {
|
||||
#'
|
||||
#' options(shiny.testmode = TRUE)
|
||||
#'
|
||||
#' # This application shows the test endpoint URL; clicking on it will
|
||||
#' # This application shows the test snapshot URL; clicking on it will
|
||||
#' # fetch the input, output, and exported values in JSON format.
|
||||
#' shinyApp(
|
||||
#' ui = basicPage(
|
||||
@@ -43,7 +43,7 @@
|
||||
#' )
|
||||
#'
|
||||
#' output$url <- renderUI({
|
||||
#' url <- session$getTestEndpointUrl(format="json")
|
||||
#' url <- session$getTestSnapshotUrl(format="json")
|
||||
#' a(href = url, url)
|
||||
#' })
|
||||
#'
|
||||
|
||||
@@ -9,7 +9,7 @@ exportTestValues(..., quoted_ = FALSE, env_ = parent.frame(),
|
||||
}
|
||||
\arguments{
|
||||
\item{...}{Named arguments that are quoted or unquoted expressions that will
|
||||
be captured and evaluated when API endpoint is visited.}
|
||||
be captured and evaluated when snapshot URL is visited.}
|
||||
|
||||
\item{quoted_}{Are the expression quoted? Default is \code{FALSE}.}
|
||||
|
||||
@@ -19,7 +19,7 @@ be captured and evaluated when API endpoint is visited.}
|
||||
}
|
||||
\description{
|
||||
This function registers expressions that will be evaluated when a test export
|
||||
event occurs. These events are triggered by accessing an API endpoint URL.
|
||||
event occurs. These events are triggered by accessing a snapshot URL.
|
||||
}
|
||||
\details{
|
||||
This function only has an effect if the app is launched in test mode. This is
|
||||
@@ -32,7 +32,7 @@ if (interactive()) {
|
||||
|
||||
options(shiny.testmode = TRUE)
|
||||
|
||||
# This application shows the test endpoint URL; clicking on it will
|
||||
# This application shows the test snapshot URL; clicking on it will
|
||||
# fetch the input, output, and exported values in JSON format.
|
||||
shinyApp(
|
||||
ui = basicPage(
|
||||
@@ -57,7 +57,7 @@ shinyApp(
|
||||
)
|
||||
|
||||
output$url <- renderUI({
|
||||
url <- session$getTestEndpointUrl(format="json")
|
||||
url <- session$getTestSnapshotUrl(format="json")
|
||||
a(href = url, url)
|
||||
})
|
||||
|
||||
|
||||
@@ -157,11 +157,11 @@
|
||||
}
|
||||
\item{exportTestValues()}{
|
||||
Registers expressions for export in test mode, available at the test
|
||||
endpoint URL.
|
||||
snapshot URL.
|
||||
}
|
||||
\item{getTestEndpointUrl(input=TRUE, output=TRUE, export=TRUE,
|
||||
\item{getTestSnapshotUrl(input=TRUE, output=TRUE, export=TRUE,
|
||||
format="json")}{
|
||||
Returns a URL for the test endpoint. Only has an effect when the
|
||||
Returns a URL for the test snapshots. Only has an effect when the
|
||||
\code{shiny.testmode} option is set to TRUE. For the input, output, and
|
||||
export arguments, TRUE means to return all of these values. It is also
|
||||
possible to specify by name which values to return by providing a
|
||||
|
||||
@@ -838,31 +838,6 @@ var ShinyApp = function() {
|
||||
|
||||
exports.progressHandlers = progressHandlers;
|
||||
|
||||
// Returns a URL which can be queried to get values from inside the server
|
||||
// function. This is enabled with `options(shiny.testmode=TRUE)`.
|
||||
this.getTestEndpointUrl = function({ fullUrl = true, input = true,
|
||||
output = true, export = true, format = "json" } = {})
|
||||
{
|
||||
const loc = window.location;
|
||||
let url = "";
|
||||
|
||||
if (fullUrl) {
|
||||
// Strip off everything after last slash in path, like dirname() in R
|
||||
url = loc.origin + loc.pathname.replace(/\/[^/]*$/, "");
|
||||
}
|
||||
url += "/session/" +
|
||||
encodeURIComponent(this.config.sessionId) +
|
||||
"/dataobj/shinytest?w=" +
|
||||
encodeURIComponent(this.config.workerId) +
|
||||
"&nonce=" + randomId() +
|
||||
(input ? "&input=1" : "") +
|
||||
(output ? "&output=1" : "") +
|
||||
(export ? "&export=1" : "") +
|
||||
"&format=" + format;
|
||||
|
||||
return url;
|
||||
};
|
||||
|
||||
}).call(ShinyApp.prototype);
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user