Skip to content

Commit 058455d

Browse files
committed
Disable skipping if only one snapshot left
Fixes #2025
1 parent 1154cbf commit 058455d

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

NEWS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# testthat (development version)
22

3+
* `snapshot_review()` disables the skip button if there's only one snapshot to review (#2025).
34
* Interrupting a test now prints the test name. This makes it easier to tell where a very slow test might be hanging (#1464)
45
* Parallel testthat now does not ignore test files with syntax errors (#1360).
56
* `expect_lt()`, `expect_gt()`, and friends have a refined display that is more likely to display the correct number of digits and shows you the actual values compared.

R/snapshot-manage.R

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,9 @@ review_app <- function(name, old_path, new_path) {
7777
diffviewer::visual_diff(old_path[[i()]], new_path[[i()]])
7878
})
7979

80+
# Can't skip if there's only one file to review
81+
shiny::updateActionButton(session, "skip", disabled = (n <= 1))
82+
8083
# Handle buttons - after clicking update move input$cases to next case,
8184
# and remove current case (for accept/reject). If no cases left, close app
8285
shiny::observeEvent(input$reject, {
@@ -104,6 +107,10 @@ review_app <- function(name, old_path, new_path) {
104107
choices = case_index[!handled],
105108
selected = i
106109
)
110+
111+
n_left <- sum(!handled)
112+
# Disable skip button if only one case remains
113+
shiny::updateActionButton(session, "skip", disabled = (n_left <= 1))
107114
}
108115
next_case <- function() {
109116
if (all(handled)) {

0 commit comments

Comments
 (0)