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

feat: Add inform_latest_results() #255

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -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
39 changes: 39 additions & 0 deletions R/fix_snaps.R
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
}
}


Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing docs and export tag

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lol I thought it could be an internal helper function.

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))
}
Loading