Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 03833e8

Browse files
committedDec 7, 2023··
feat: Add inform_latest_results()
A small helper to list the currently failing tests from the latest nightly run.
1 parent 44c00c1 commit 03833e8

File tree

2 files changed

+41
-1
lines changed

2 files changed

+41
-1
lines changed
 

‎DESCRIPTION

+2-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ Suggests:
3434
tidyr,
3535
later,
3636
withr,
37-
shinytest
37+
shinytest,
38+
chromote
3839
Config/Needs/website: tidyverse/tidytemplate
3940
URL: https://github.com/rstudio/shinycoreci
4041
BugReports: https://github.com/rstudio/shinycoreci/issues

‎R/fix_snaps.R

+39
Original file line numberDiff line numberDiff line change
@@ -355,3 +355,42 @@ verify_no_untracked_files <- function(repo_dir, apps_folder) {
355355
stop("Make sure there are no untracked files. Please remove the files or commit the changes.")
356356
}
357357
}
358+
359+
360+
inform_latest_results <- function() {
361+
if (!requireNamespace("chromote", quietly = TRUE)) {
362+
stop("Please install `chromote` to use this function")
363+
}
364+
365+
url <- "https://rstudio.github.io/shinycoreci/results/"
366+
367+
b <- chromote::ChromoteSession$new()
368+
withr::defer(b$close())
369+
370+
p <- b$Page$loadEventFired(wait_ = FALSE)
371+
b$Page$navigate(url = url, wait_ = FALSE)
372+
b$wait_for(p)
373+
374+
# Wait for the page to follow the redirect
375+
Sys.sleep(1)
376+
377+
failed <- b$Runtime$evaluate(
378+
"[...document.querySelectorAll('#app_summary h3')].map(el => el.innerText)",
379+
returnByValue = TRUE
380+
)$result$value
381+
failed <- unlist(failed)
382+
383+
history <- b$Page$getNavigationHistory()
384+
current_url <- history$entries[[history$currentIndex + 1]]
385+
cli::cli_inform("{.url {current_url$url}}")
386+
387+
if (length(failed) == 0) {
388+
cli::cli_alert_success("All tests passed!")
389+
return(invisible())
390+
}
391+
392+
cli::cli_alert_danger("{length(failed)} test{?s} failed:")
393+
cli::cli_verbatim(sprintf("- `%s`", failed))
394+
395+
invisible(unlist(failed))
396+
}

0 commit comments

Comments
 (0)
Please sign in to comment.