From d98909e67b088e2ce40b23c46d8d788e37339175 Mon Sep 17 00:00:00 2001 From: osenan Date: Wed, 17 Dec 2025 19:43:19 -0300 Subject: [PATCH 01/13] tests: add test for add_no_selected_choices --- tests/testthat/test-choices_selected.R | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/testthat/test-choices_selected.R b/tests/testthat/test-choices_selected.R index 4cf40b41d..3a08a78db 100644 --- a/tests/testthat/test-choices_selected.R +++ b/tests/testthat/test-choices_selected.R @@ -197,3 +197,13 @@ testthat::test_that("delayed version of choices_selected - resolve_delayed", { res_obj <- isolate(resolve_delayed(obj, datasets = data_list, keys = key_list)) testthat::expect_equal(res_obj, exp_obj) }) + +testthat::test_that("if we call add_no_selected_choices we add no selection", { + choices_list <- choices_selected( + choices = c("a", "b", "c"), + selected = "a" + ) + testthat::expect_false(any(grepl("no selection", choices_list$choices))) + choices_list <- add_no_selected_choices(choices_list) + testthat::expect_true(any(grepl("no selection", choices_list$choices))) +}) From cf3f30c72f96e6fd6d4caf44f72265e7b8dc020d Mon Sep 17 00:00:00 2001 From: osenan Date: Wed, 17 Dec 2025 19:57:27 -0300 Subject: [PATCH 02/13] add test for datanames_input --- tests/testthat/test-data_extract_datanames.R | 28 ++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/tests/testthat/test-data_extract_datanames.R b/tests/testthat/test-data_extract_datanames.R index 226f7f040..1e4fe13c6 100644 --- a/tests/testthat/test-data_extract_datanames.R +++ b/tests/testthat/test-data_extract_datanames.R @@ -83,3 +83,31 @@ testthat::test_that("get_extract_datanames returns unique dataname when data_ext testthat::expect_identical(ged_output, "ADSL") testthat::expect_equal(length(ged_output), 1) }) + +testthat::test_that("datanames_input gets the data names provided to module", { + adtte_filters <- filter_spec( + vars = c("PARAMCD", "CNSR"), + sep = "-", + choices = c("OS-1" = "OS-1", "OS-0" = "OS-0", "PFS-1" = "PFS-1"), + selected = "OS-1", + multiple = FALSE, + label = "Choose endpoint and Censor" + ) + + response_spec <- data_extract_spec( + dataname = "ADTTE", + filter = adtte_filters, + select = select_spec( + choices = c("AVAL", "BMRKR1", "AGE"), + selected = c("AVAL", "BMRKR1"), + multiple = TRUE, + fixed = FALSE, + label = "Column" + ) + ) + + input_names <- datanames_input(response_spec) + + testthat::expect_s3_class(input_names, "shiny.tag") + testthat::expect_true(grepl("ADTTE", as.character(input_names))) +}) From 199e29c4e77adc29a09450674970fd01a2da80fa Mon Sep 17 00:00:00 2001 From: osenan Date: Fri, 19 Dec 2025 10:18:30 -0300 Subject: [PATCH 03/13] feat: add test for missing function and update function to handle multiple values --- R/column_functions.R | 2 +- tests/testthat/test-column_functions.R | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 tests/testthat/test-column_functions.R diff --git a/R/column_functions.R b/R/column_functions.R index a2499218f..b49f29974 100644 --- a/R/column_functions.R +++ b/R/column_functions.R @@ -12,7 +12,7 @@ #' @export #' get_dataset_prefixed_col_names <- function(data) { - if (!is.null(attr(data, "filter_and_columns")$columns) && attr(data, "filter_and_columns")$columns != "") { + if (any(!is.null(attr(data, "filter_and_columns")$columns)) && all(attr(data, "filter_and_columns")$columns != "")) { paste(attr(data, "dataname"), attr(data, "filter_and_columns")$columns, sep = ".") } else { NULL diff --git a/tests/testthat/test-column_functions.R b/tests/testthat/test-column_functions.R new file mode 100644 index 000000000..4f42fb8d6 --- /dev/null +++ b/tests/testthat/test-column_functions.R @@ -0,0 +1,13 @@ +testthat::test_that("get_dataset_prefixed_col_names returns vector of columns", { + data_test <- data.frame() + attr(data_test, "filter_and_columns") <- list(columns = c("col_1")) + + testthat::expect_identical(".col_1", get_dataset_prefixed_col_names(data_test)) +}) + +testthat::test_that("get_dataset_prefixed_col_names returns vector of multiple columns", { + data_test <- data.frame() + attr(data_test, "filter_and_columns") <- list(columns = c("col_1", "col_2")) + + testthat::expect_identical(c(".col_1", ".col_2"), get_dataset_prefixed_col_names(data_test)) +}) From 68fa0ebee75ca7519ab1d5e0d0a6594c6b2fa8a7 Mon Sep 17 00:00:00 2001 From: osenan Date: Fri, 19 Dec 2025 11:28:52 -0300 Subject: [PATCH 04/13] tests: add test for is_single_dataset function --- tests/testthat/test-data_extract_datanames.R | 64 ++++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/tests/testthat/test-data_extract_datanames.R b/tests/testthat/test-data_extract_datanames.R index 1e4fe13c6..d3bb6f4ae 100644 --- a/tests/testthat/test-data_extract_datanames.R +++ b/tests/testthat/test-data_extract_datanames.R @@ -111,3 +111,67 @@ testthat::test_that("datanames_input gets the data names provided to module", { testthat::expect_s3_class(input_names, "shiny.tag") testthat::expect_true(grepl("ADTTE", as.character(input_names))) }) + +testthat::test_that("data_extract_datanames returns TRUE in single dataset", { + adtte_filters <- filter_spec( + vars = c("PARAMCD", "CNSR"), + sep = "-", + choices = c("OS-1" = "OS-1", "OS-0" = "OS-0", "PFS-1" = "PFS-1"), + selected = "OS-1", + multiple = FALSE, + label = "Choose endpoint and Censor" + ) + + data_spec <- data_extract_spec( + dataname = "ADTTE", + filter = adtte_filters, + select = select_spec( + choices = c("AVAL", "BMRKR1", "AGE"), + selected = c("AVAL", "BMRKR1"), + multiple = TRUE, + fixed = FALSE, + label = "Column" + ) + ) + + testthat::expect_true(is_single_dataset((data_spec))) + +}) + +testthat::test_that("data_extract_datanames returns FALSE in multiple datasets", { + adtte_filters <- filter_spec( + vars = c("PARAMCD", "CNSR"), + sep = "-", + choices = c("OS-1" = "OS-1", "OS-0" = "OS-0", "PFS-1" = "PFS-1"), + selected = "OS-1", + multiple = FALSE, + label = "Choose endpoint and Censor" + ) + + data_spec_1 <- data_extract_spec( + dataname = "ADTTE", + filter = adtte_filters, + select = select_spec( + choices = c("AVAL", "BMRKR1", "AGE"), + selected = c("AVAL", "BMRKR1"), + multiple = TRUE, + fixed = FALSE, + label = "Column" + ) + ) + + + data_spec_2 <- data_extract_spec( + dataname = "ADTTE2", + filter = adtte_filters, + select = select_spec( + choices = c("AVAL", "BMRKR1", "AGE"), + selected = c("AVAL", "BMRKR1"), + multiple = TRUE, + fixed = FALSE, + label = "Column" + ) + ) + + testthat::expect_false(is_single_dataset(data_spec_1, data_spec_2)) +}) From 5041eeaddeb853092e9c49220ff37ffcde458610 Mon Sep 17 00:00:00 2001 From: osenan Date: Fri, 19 Dec 2025 11:37:07 -0300 Subject: [PATCH 05/13] tests: add test for no_selected_as_NULL --- tests/testthat/test-choices_selected.R | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/testthat/test-choices_selected.R b/tests/testthat/test-choices_selected.R index 3a08a78db..5cc85aa47 100644 --- a/tests/testthat/test-choices_selected.R +++ b/tests/testthat/test-choices_selected.R @@ -207,3 +207,10 @@ testthat::test_that("if we call add_no_selected_choices we add no selection", { choices_list <- add_no_selected_choices(choices_list) testthat::expect_true(any(grepl("no selection", choices_list$choices))) }) + +testthat::test_that("no_selected_as_NULL returns NULL if word is within no selected", { + testthat::expect_null(no_selected_as_NULL(NULL)) + testthat::expect_null(no_selected_as_NULL(no_select_keyword)) + testthat::expect_true(!is.null(no_selected_as_NULL("random"))) +}) + From ab758f4ae2646f9b2bcfcc48ac4f30a42223c079 Mon Sep 17 00:00:00 2001 From: osenan Date: Fri, 19 Dec 2025 11:42:28 -0300 Subject: [PATCH 06/13] chore: fix lintr --- tests/testthat/test-choices_selected.R | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/testthat/test-choices_selected.R b/tests/testthat/test-choices_selected.R index 5cc85aa47..88005bd5f 100644 --- a/tests/testthat/test-choices_selected.R +++ b/tests/testthat/test-choices_selected.R @@ -213,4 +213,3 @@ testthat::test_that("no_selected_as_NULL returns NULL if word is within no selec testthat::expect_null(no_selected_as_NULL(no_select_keyword)) testthat::expect_true(!is.null(no_selected_as_NULL("random"))) }) - From 23628228cf978347817fba4544993d22f7fd5a9d Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 19 Dec 2025 14:44:38 +0000 Subject: [PATCH 07/13] [skip style] [skip vbump] Restyle files --- tests/testthat/test-data_extract_datanames.R | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/testthat/test-data_extract_datanames.R b/tests/testthat/test-data_extract_datanames.R index d3bb6f4ae..c7053ee82 100644 --- a/tests/testthat/test-data_extract_datanames.R +++ b/tests/testthat/test-data_extract_datanames.R @@ -135,7 +135,6 @@ testthat::test_that("data_extract_datanames returns TRUE in single dataset", { ) testthat::expect_true(is_single_dataset((data_spec))) - }) testthat::test_that("data_extract_datanames returns FALSE in multiple datasets", { From c2e696d2dcf1b89fcb6ad50030aa713b546610e8 Mon Sep 17 00:00:00 2001 From: Oriol Senan <35930244+osenan@users.noreply.github.com> Date: Thu, 12 Feb 2026 09:27:51 +0100 Subject: [PATCH 08/13] Apply suggestion from @m7pr Co-authored-by: Marcin <133694481+m7pr@users.noreply.github.com> Signed-off-by: Oriol Senan <35930244+osenan@users.noreply.github.com> --- tests/testthat/test-choices_selected.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/testthat/test-choices_selected.R b/tests/testthat/test-choices_selected.R index 88005bd5f..1e9f2325d 100644 --- a/tests/testthat/test-choices_selected.R +++ b/tests/testthat/test-choices_selected.R @@ -198,7 +198,7 @@ testthat::test_that("delayed version of choices_selected - resolve_delayed", { testthat::expect_equal(res_obj, exp_obj) }) -testthat::test_that("if we call add_no_selected_choices we add no selection", { +testthat::test_that("add_no_selected_choices actually does not add any selection", { choices_list <- choices_selected( choices = c("a", "b", "c"), selected = "a" From bcb685426e50d206dfdac0e2428cfbbc1489be6f Mon Sep 17 00:00:00 2001 From: osenan Date: Thu, 12 Feb 2026 11:49:04 +0100 Subject: [PATCH 09/13] tests: rephrase the description of the test --- tests/testthat/test-choices_selected.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/testthat/test-choices_selected.R b/tests/testthat/test-choices_selected.R index 1e9f2325d..52297768a 100644 --- a/tests/testthat/test-choices_selected.R +++ b/tests/testthat/test-choices_selected.R @@ -208,7 +208,7 @@ testthat::test_that("add_no_selected_choices actually does not add any selection testthat::expect_true(any(grepl("no selection", choices_list$choices))) }) -testthat::test_that("no_selected_as_NULL returns NULL if word is within no selected", { +testthat::test_that("no_selected_as_will return NULL only if provided word is NULL or part of `no_select_keyword` vector", { testthat::expect_null(no_selected_as_NULL(NULL)) testthat::expect_null(no_selected_as_NULL(no_select_keyword)) testthat::expect_true(!is.null(no_selected_as_NULL("random"))) From 4e734d34393e0c2ffa1a10bbc1a87f6ef021f632 Mon Sep 17 00:00:00 2001 From: osenan Date: Thu, 12 Feb 2026 13:52:36 +0100 Subject: [PATCH 10/13] tests: add a new scenario --- tests/testthat/test-choices_selected.R | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/testthat/test-choices_selected.R b/tests/testthat/test-choices_selected.R index 52297768a..9ad418d2d 100644 --- a/tests/testthat/test-choices_selected.R +++ b/tests/testthat/test-choices_selected.R @@ -208,8 +208,9 @@ testthat::test_that("add_no_selected_choices actually does not add any selection testthat::expect_true(any(grepl("no selection", choices_list$choices))) }) -testthat::test_that("no_selected_as_will return NULL only if provided word is NULL or part of `no_select_keyword` vector", { +testthat::test_that("no_selected_as_returns NULL only if word is NULL or equals `no_select_keyword`", { testthat::expect_null(no_selected_as_NULL(NULL)) + testthat::expect_null(no_selected_as_NULL("")) testthat::expect_null(no_selected_as_NULL(no_select_keyword)) testthat::expect_true(!is.null(no_selected_as_NULL("random"))) }) From cba48d827fc24a6845eacdf01fc9f1e7db1b9d26 Mon Sep 17 00:00:00 2001 From: Oriol Senan <35930244+osenan@users.noreply.github.com> Date: Thu, 12 Feb 2026 15:31:56 +0100 Subject: [PATCH 11/13] Update tests/testthat/test-choices_selected.R MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: André Veríssimo <211358+averissimo@users.noreply.github.com> Signed-off-by: Oriol Senan <35930244+osenan@users.noreply.github.com> --- tests/testthat/test-choices_selected.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/testthat/test-choices_selected.R b/tests/testthat/test-choices_selected.R index 9ad418d2d..15302e386 100644 --- a/tests/testthat/test-choices_selected.R +++ b/tests/testthat/test-choices_selected.R @@ -212,5 +212,5 @@ testthat::test_that("no_selected_as_returns NULL only if word is NULL or equals testthat::expect_null(no_selected_as_NULL(NULL)) testthat::expect_null(no_selected_as_NULL("")) testthat::expect_null(no_selected_as_NULL(no_select_keyword)) - testthat::expect_true(!is.null(no_selected_as_NULL("random"))) + testthat::expect_failure(testthat::expect_null(no_selected_as_NULL("random"))) }) From d4b427db2f4b58c3472e94e2bf30ad06bb179470 Mon Sep 17 00:00:00 2001 From: Oriol Senan <35930244+osenan@users.noreply.github.com> Date: Thu, 12 Feb 2026 15:32:14 +0100 Subject: [PATCH 12/13] Update tests/testthat/test-choices_selected.R MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: André Veríssimo <211358+averissimo@users.noreply.github.com> Signed-off-by: Oriol Senan <35930244+osenan@users.noreply.github.com> --- tests/testthat/test-choices_selected.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/testthat/test-choices_selected.R b/tests/testthat/test-choices_selected.R index 15302e386..ede5c87d9 100644 --- a/tests/testthat/test-choices_selected.R +++ b/tests/testthat/test-choices_selected.R @@ -208,7 +208,7 @@ testthat::test_that("add_no_selected_choices actually does not add any selection testthat::expect_true(any(grepl("no selection", choices_list$choices))) }) -testthat::test_that("no_selected_as_returns NULL only if word is NULL or equals `no_select_keyword`", { +testthat::test_that("no_selected_as_NULL returns NULL only if word is NULL or equals `no_select_keyword`", { testthat::expect_null(no_selected_as_NULL(NULL)) testthat::expect_null(no_selected_as_NULL("")) testthat::expect_null(no_selected_as_NULL(no_select_keyword)) From a92ca0e49c8b06cbd161449a612e50551f915ea1 Mon Sep 17 00:00:00 2001 From: Oriol Senan <35930244+osenan@users.noreply.github.com> Date: Thu, 12 Feb 2026 15:40:48 +0100 Subject: [PATCH 13/13] Apply suggestion from @averissimo MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: André Veríssimo <211358+averissimo@users.noreply.github.com> Signed-off-by: Oriol Senan <35930244+osenan@users.noreply.github.com> --- R/column_functions.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/column_functions.R b/R/column_functions.R index b49f29974..559c55d5a 100644 --- a/R/column_functions.R +++ b/R/column_functions.R @@ -12,7 +12,7 @@ #' @export #' get_dataset_prefixed_col_names <- function(data) { - if (any(!is.null(attr(data, "filter_and_columns")$columns)) && all(attr(data, "filter_and_columns")$columns != "")) { + if (!is.null(attr(data, "filter_and_columns", exact = TRUE)$columns) && all(attr(data, "filter_and_columns", exact = TRUE)$columns != "")) { paste(attr(data, "dataname"), attr(data, "filter_and_columns")$columns, sep = ".") } else { NULL