From 12348eed2ff0706bbce1c1458e67978327495cd0 Mon Sep 17 00:00:00 2001 From: deepanshkhurana Date: Fri, 3 Oct 2025 13:34:55 +0530 Subject: [PATCH] fix: handle edge case where phrases like "no errors" would still trigger check_error_text() --- app/logic/general_utils.R | 2 +- tests/testthat/test-general_utils.R | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/app/logic/general_utils.R b/app/logic/general_utils.R index 1f5fa47..0b39d69 100644 --- a/app/logic/general_utils.R +++ b/app/logic/general_utils.R @@ -18,7 +18,7 @@ check_text_error <- function( ignore_case = TRUE ) { grepl( - paste(wordlist, collapse = "|"), + paste0("^", wordlist, collapse = "|"), text, ignore.case = ignore_case ) diff --git a/tests/testthat/test-general_utils.R b/tests/testthat/test-general_utils.R index a298404..dd767b2 100644 --- a/tests/testthat/test-general_utils.R +++ b/tests/testthat/test-general_utils.R @@ -34,6 +34,19 @@ describe("check_text_error()", { ) }) + it("handles 'no error' and similar cases gracefully", { + expect_true( + !check_text_error( + "No error detected" + ) + ) + expect_true( + !check_text_error( + "No errors found" + ) + ) + }) + it("returns FALSE for non-error keywords", { expect_true( !check_text_error(