From d7fd794529e658af442ee712436f00e2d29ecf30 Mon Sep 17 00:00:00 2001 From: cjrace Date: Fri, 3 May 2024 17:03:14 +0100 Subject: [PATCH 1/4] update debugging script to account for shiny now autoloading --- R/manual_scripts/debugging.R | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/R/manual_scripts/debugging.R b/R/manual_scripts/debugging.R index 416b021..d303acc 100644 --- a/R/manual_scripts/debugging.R +++ b/R/manual_scripts/debugging.R @@ -1,7 +1,18 @@ # Debugging script # Use this script to manually read in and screen files for those occasions when the app breaks without a useful error +# Helpful for running code in console +# Uncomment when you need to use this, and always make sure to comment it again before committing +# # Dependencies ============================================================== # source("global.R") +# source("R/readFile.R") +# source("R/screenFiles.R") +# source("R/knownVariables.R") +# source("R/fileValidation.R") +# source("R/preCheck1.R") +# source("R/preCheck2.R") +# source("R/mainTests.R") +# # # debugReadFile <- function(file) { # output <- readFile(file) @@ -9,14 +20,16 @@ # return(output) # } # -# # Put the file paths of the files in here +# # Choose files ============================================================== # datafile <- debugReadFile(file.choose()) # metafile <- debugReadFile(file.choose()) # +# # Screen files ============================================================== # results <- screenFiles(datafile$filename, metafile$filename, datafile$fileSeparator, metafile$fileSeparator, datafile$fileCharacter, metafile$fileCharacter, datafile$mainFile, metafile$mainFile) # # data.table(results$results) %>% View() # +# # Extra helpers ============================================================= # data <- datafile$mainFile # meta <- metafile$mainFile # From 0ca0ace761885b26be3bdeb8a2c7fb3bb7068451 Mon Sep 17 00:00:00 2001 From: cjrace Date: Fri, 3 May 2024 17:03:44 +0100 Subject: [PATCH 2/4] add example data and test case --- tests/testthat/test-data/label_blank_notNA.csv | 7 +++++++ tests/testthat/test-data/label_blank_notNA.meta.csv | 3 +++ tests/testthat/test-function-edge_cases.R | 6 ++++++ 3 files changed, 16 insertions(+) create mode 100644 tests/testthat/test-data/label_blank_notNA.csv create mode 100644 tests/testthat/test-data/label_blank_notNA.meta.csv diff --git a/tests/testthat/test-data/label_blank_notNA.csv b/tests/testthat/test-data/label_blank_notNA.csv new file mode 100644 index 0000000..155fe4e --- /dev/null +++ b/tests/testthat/test-data/label_blank_notNA.csv @@ -0,0 +1,7 @@ +time_period,time_identifier,geographic_level,country_code,country_name,staff_count_type,some_number +202122,Academic year,National,E92000001,England,Admin,6 +202122,Academic year,National,E92000001,England,Support,4 +202122,Academic year,National,E92000001,England,Teacher,2 +202122,Academic year,National,E92000001,England,Manager,6 +202122,Academic year,National,E92000001,England,Leader,8 +202122,Academic year,National,E92000001,England,Total,89098 diff --git a/tests/testthat/test-data/label_blank_notNA.meta.csv b/tests/testthat/test-data/label_blank_notNA.meta.csv new file mode 100644 index 0000000..4207e16 --- /dev/null +++ b/tests/testthat/test-data/label_blank_notNA.meta.csv @@ -0,0 +1,3 @@ +col_name,col_type,label,indicator_grouping,indicator_unit,indicator_dp,filter_hint,filter_grouping_column +"staff_count_type","Filter","","","","","","" +"some_number","Indicator","Test indicator","","","0","","" diff --git a/tests/testthat/test-function-edge_cases.R b/tests/testthat/test-function-edge_cases.R index 3a1b66a..3936667 100644 --- a/tests/testthat/test-function-edge_cases.R +++ b/tests/testthat/test-function-edge_cases.R @@ -198,3 +198,9 @@ test_that("prov_level_diff_names", { expect_equal(screeningOutput$results %>% filter(result == "FAIL") %>% nrow(), 0) }) + +test_that("blank_meta_label_notNA_still_fails", { + screeningOutput <- testOther("../../tests/testthat/test-data/label_blank_notNA.csv") + + expect_equal(screeningOutput$results %>% filter(test == "label") %>% pull(result) %>% unlist(use.names = FALSE), "FAIL") +}) From 6e8668644a110306871f7845857fcce65384cc87 Mon Sep 17 00:00:00 2001 From: cjrace Date: Fri, 3 May 2024 17:10:50 +0100 Subject: [PATCH 3/4] add wait in flaky test --- tests/testthat/test-UI-03_additional_qa.R | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/testthat/test-UI-03_additional_qa.R b/tests/testthat/test-UI-03_additional_qa.R index 864461f..a1ab73b 100644 --- a/tests/testthat/test-UI-03_additional_qa.R +++ b/tests/testthat/test-UI-03_additional_qa.R @@ -79,5 +79,7 @@ test_that("Additional QA tabs", { app$set_inputs(geog_indicator_parameter = "num_schools") app$set_inputs(submit_geographies = "click") + app$wait_for_idle(5) # this test seems weirdly flaky for unknown reasons + app$expect_values(output = "geog_agg2") }) From f0dc65e25c4e38f292d63f2f5f64141d08ed8e34 Mon Sep 17 00:00:00 2001 From: cjrace Date: Fri, 3 May 2024 17:11:33 +0100 Subject: [PATCH 4/4] fix blank label bug by accounting for blank cells as well as NAs --- R/mainTests.r | 1 + 1 file changed, 1 insertion(+) diff --git a/R/mainTests.r b/R/mainTests.r index a8dce62..5a8cb33 100644 --- a/R/mainTests.r +++ b/R/mainTests.r @@ -1959,6 +1959,7 @@ col_name_spaces <- function(meta) { label <- function(meta) { completed_labels <- meta %>% filter(!is.na(label)) %>% + filter(label != "") %>% nrow() blank_labels <- nrow(meta) - completed_labels