diff --git a/R/post_bug.R b/R/post_bug.R index 8eebc36..bba2509 100644 --- a/R/post_bug.R +++ b/R/post_bug.R @@ -29,7 +29,7 @@ post_bug <- function(text, title, component, ..., # Fill description, version and summary if (missing(component)) { cli::cli_alert("Please, pick a component:") - component <- menu(components) + component <- menu(components, graphics = TRUE) } component <- components[component] version <- missing_version(version) diff --git a/R/post_help.R b/R/post_help.R index 168a024..70267fb 100644 --- a/R/post_help.R +++ b/R/post_help.R @@ -12,7 +12,7 @@ read_documentation <- function() { if (answer %in% no) { cli::cli_alert_success("Opening documentation...") lapply(official_documentation, browseURL) - stop("Do it and then return please.", call. = FALSE) + try(stop("Do it and then return please.", call. = FALSE)) } invisible(answer == TRUE) } @@ -25,7 +25,7 @@ no <- c("Not sure", "Not now", "Negative", "No", "Nope", "Absolutely not") ask_confirmation <- function(title = NULL, positive = yes, negative = no) { options <- c(sample(positive, 1), sample(negative, 2)) # Mix which ones options <- sample(options, 3) # Random order - sel <- menu(options, title = title) + sel <- menu(options, graphics = TRUE, title = title) invisible(c("Cancel", options)[sel + 1]) } @@ -38,8 +38,8 @@ ask_research <- function() { cli::cli_alert("Are all the above questions affirmative?") answer <- ask_confirmation() if (answer %in% no) { - stop("Do it, later if you are still sure it is a bug then return please.", - call. = FALSE) + try(stop("Do it, later if you are still sure it is a bug then return please.", + call. = FALSE)) } else if (answer == "Cancel") { return(invisible(NULL)) } diff --git a/tests/testthat/_snaps/post_bug.md b/tests/testthat/_snaps/post_bug.md new file mode 100644 index 0000000..0e61be7 --- /dev/null +++ b/tests/testthat/_snaps/post_bug.md @@ -0,0 +1,29 @@ +# post_bug() works [plain] + + Code + expect_equal(post_bug(), url) + Message + > Please, pick a component: + Output + -- Documentation --------------------------------------------------------------- + Message + > Have you read the documentation recently? + Output + (0 to cancel) + -- Previous research ----------------------------------------------------------- + Message + * Did you search for similar issues? + * Did you search on the mailing list archive? + * Did you search on forums and different sites? + > Are all the above questions affirmative? + -- Content of the issue -------------------------------------------------------- + > Do you provide a short reproducible example of the issue? + Output + Maybe first check with the R-devel mailing list + Message + > Is this issue about R and not a package? + > Do you explain expectations and the buggy behaviour? + > Did you try to identify the cause of the bug? + ! This notification will reach the R-core volunteers and many more + * Are you sure to open a bug0 ? + diff --git a/tests/testthat/test-post_bug.R b/tests/testthat/test-post_bug.R new file mode 100644 index 0000000..395cd5e --- /dev/null +++ b/tests/testthat/test-post_bug.R @@ -0,0 +1,7 @@ +cli::test_that_cli(configs = "plain", "post_bug() works", { + skip_if_not(interactive()) + url <- paste0(missing_host(), "rest/bug") + expect_snapshot({ + expect_equal(post_bug(), url) + }) +}) diff --git a/tests/testthat/test-post_help.R b/tests/testthat/test-post_help.R deleted file mode 100644 index 27ef604..0000000 --- a/tests/testthat/test-post_help.R +++ /dev/null @@ -1,34 +0,0 @@ -library(mockery) - -local({ - mockery::mock(read_documentation()) - test_that("read_documentation() works", { - skip_if_not(interactive()) - expect_equal(read_documentation(), FALSE) - }) -}) - - - - - -# cli::test_that_cli(configs = c("plain"),"read_documentation() works",{ -# -# result <- read_documentation() -# print(result) -# # ans <- paste(output_prompts, collapse = "\n") -# # write(ans, f) -# -# expect_snapshot({ -# #expect_true(result) -# #expect_equal(result, result %in% yes) -# #expect_equal(result, result %in% no) -# }) -# }) - -# test_that("ask_confirmation works", { -# vcr::use_cassette("ask_confirmation", { -# ac <- ask_confirmation(title = NULL, positive = yes, negative = no) -# }) -# expect_equal(sample(positive, 1), sample(negative, 2)) -# })