diff --git a/DESCRIPTION b/DESCRIPTION index 2426369b64..770f4ad960 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -34,7 +34,8 @@ Suggests: tidyr, later, withr, - shinytest + shinytest, + chromote Config/Needs/website: tidyverse/tidytemplate URL: https://github.com/rstudio/shinycoreci BugReports: https://github.com/rstudio/shinycoreci/issues diff --git a/R/fix_snaps.R b/R/fix_snaps.R index d10149fe12..6dda6a1e96 100644 --- a/R/fix_snaps.R +++ b/R/fix_snaps.R @@ -355,3 +355,42 @@ verify_no_untracked_files <- function(repo_dir, apps_folder) { stop("Make sure there are no untracked files. Please remove the files or commit the changes.") } } + + +inform_latest_results <- function() { + if (!requireNamespace("chromote", quietly = TRUE)) { + stop("Please install `chromote` to use this function") + } + + url <- "https://rstudio.github.io/shinycoreci/results/" + + b <- chromote::ChromoteSession$new() + withr::defer(b$close()) + + p <- b$Page$loadEventFired(wait_ = FALSE) + b$Page$navigate(url = url, wait_ = FALSE) + b$wait_for(p) + + # Wait for the page to follow the redirect + Sys.sleep(1) + + failed <- b$Runtime$evaluate( + "[...document.querySelectorAll('#app_summary h3')].map(el => el.innerText)", + returnByValue = TRUE + )$result$value + failed <- unlist(failed) + + history <- b$Page$getNavigationHistory() + current_url <- history$entries[[history$currentIndex + 1]] + cli::cli_inform("{.url {current_url$url}}") + + if (length(failed) == 0) { + cli::cli_alert_success("All tests passed!") + return(invisible()) + } + + cli::cli_alert_danger("{length(failed)} test{?s} failed:") + cli::cli_verbatim(sprintf("- `%s`", failed)) + + invisible(unlist(failed)) +}