Skip to content

Commit

Permalink
Repair part of mod_review_form tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jthompson-arcus committed Dec 3, 2024
1 parent a353f5d commit 579d80e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
6 changes: 3 additions & 3 deletions R/mod_review_forms.R
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ mod_review_forms_server <- function(

observeEvent(r$subject_id, {
session$userData$update_checkboxes[[active_form()]] <- NULL
session$userData$review_records[[active_form()]] <- NULL
session$userData$review_records[[active_form()]] <- data.frame(id = integer(), reviewed = character())
})

observeEvent(input$form_reviewed, {
Expand Down Expand Up @@ -172,7 +172,7 @@ mod_review_forms_server <- function(
# probably better to use defensive coding here to ensure the app does not crash in that case. However we need to define which review status we need to select
# in this case get the reviewed = "No"
review_status <- unique(review_data_active()[["reviewed"]])
review_comment <- unique(review_data_active()[["comment"]])
review_comment <- with(review_data_active(), comment[edit_date_time == max(as.POSIXct(edit_date_time))]) |> unique() |> paste(collapse = "; ")
if(length(review_status) != 1)
review_indeterminate(TRUE)
}
Expand Down Expand Up @@ -233,7 +233,7 @@ mod_review_forms_server <- function(
shinyjs::enable("save_review")
shinyjs::enable("add_comment")
shinyjs::enable("review_comment")
} else{
} else {
shinyjs::disable("save_review")
shinyjs::disable("add_comment")
shinyjs::disable("review_comment")
Expand Down
7 changes: 7 additions & 0 deletions tests/testthat/test-mod_review_forms.R
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ describe(
mod_review_forms_server, args = testargs, {
ns <- session$ns

session$userData$review_records <- reactiveValues()
session$userData$update_checkboxes <- reactiveValues()

## patient has two rows: AF and Cystitis. AF is already reviewed by someone else:
expect_equal(
data.frame(
Expand All @@ -94,6 +97,7 @@ describe(
})
)

session$setInputs(form_reviewed = FALSE) # Needs to be initialized to work
session$setInputs(form_reviewed = TRUE, save_review = 1)
db_reviewdata <- db_get_table(db_path)
db_reviewlogdata <- db_get_table(db_path, "all_review_data_log")
Expand Down Expand Up @@ -183,6 +187,9 @@ describe(
)
}
test_server <- function(input, output, session){
session$userData$review_records <- reactiveValues()
session$userData$update_checkboxes <- reactiveValues()

mod_review_forms_server(
id = "test",
r = reactiveValues(
Expand Down

0 comments on commit 579d80e

Please sign in to comment.