diff --git a/.Rbuildignore b/.Rbuildignore index e262b35..cb1ea78 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -3,5 +3,5 @@ ^\.github$ ^LICENSE\.md$ ^quarto\.qmd$ -^quarto\.qmd$ ^README\.qmd$ +^CITATION\.cff$ diff --git a/CITATION.cff b/CITATION.cff new file mode 100644 index 0000000..b3f436e --- /dev/null +++ b/CITATION.cff @@ -0,0 +1,430 @@ +# ------------------------------------------------ +# CITATION.cff file created with {cffr} R package +# See also: https://docs.ropensci.org/cffr/ +# ------------------------------------------------ + +cff-version: 1.2.0 +message: 'To cite package "mwanaApp" in publications use:' +type: software +license: GPL-3.0-or-later +title: 'mwanaApp: mwana GUI' +version: 0.2.2 +abstract: A seamless graphical interface to the mwana R package for data wrangling, + plausibility checks, and prevalence estimation of wasting. +authors: +- family-names: Zaba + given-names: Tomás + email: tomas.zaba@outlook.com + orcid: https://orcid.org/0000-0002-7079-3574 +preferred-citation: + type: manual + title: 'mwanaApp: A seamless graphical interface to the mwana R package for data + wrangling, plausibility checks, and prevalence estimation of wasting' + authors: + - name: Tomás Zaba + year: '2026' + notes: R package version 0.2.2 + url: https://github.com/mphimo/mwanaApp +repository-code: https://github.com/mphimo/mwanaApp +url: https://mphimo.github.io/mwanaApp/ +contact: +- family-names: Zaba + given-names: Tomás + email: tomas.zaba@outlook.com + orcid: https://orcid.org/0000-0002-7079-3574 +keywords: +- acute-malnutrition +- anthropometry +- wasting +references: +- type: software + title: dplyr + abstract: 'dplyr: A Grammar of Data Manipulation' + notes: Imports + url: https://dplyr.tidyverse.org + repository: https://CRAN.R-project.org/package=dplyr + authors: + - family-names: Wickham + given-names: Hadley + email: hadley@posit.co + orcid: https://orcid.org/0000-0003-4757-117X + - family-names: François + given-names: Romain + orcid: https://orcid.org/0000-0002-2444-4226 + - family-names: Henry + given-names: Lionel + - family-names: Müller + given-names: Kirill + orcid: https://orcid.org/0000-0002-1416-3412 + - family-names: Vaughan + given-names: Davis + email: davis@posit.co + orcid: https://orcid.org/0000-0003-4777-038X + year: '2026' + doi: 10.32614/CRAN.package.dplyr + version: '>= 1.1.4' +- type: software + title: mwana + abstract: 'mwana: An Efficient Workflow for Plausibility Checks and Prevalence Analysis + of Wasting in R' + notes: Imports + url: https://mphimo.github.io/mwana/ + repository: https://CRAN.R-project.org/package=mwana + authors: + - family-names: Zaba + given-names: Tomás + email: tomas.zaba@outlook.com + orcid: https://orcid.org/0000-0002-7079-3574 + - family-names: Guevarra + given-names: Ernest + orcid: https://orcid.org/0000-0002-4887-4415 + - family-names: Myatt + given-names: Mark + year: '2026' + doi: 10.32614/CRAN.package.mwana + version: '>= 0.2.5' +- type: software + title: rlang + abstract: 'rlang: Functions for Base Types and Core R and ''Tidyverse'' Features' + notes: Imports + url: https://rlang.r-lib.org + repository: https://CRAN.R-project.org/package=rlang + authors: + - family-names: Henry + given-names: Lionel + email: lionel@posit.co + - family-names: Wickham + given-names: Hadley + email: hadley@posit.co + year: '2026' + doi: 10.32614/CRAN.package.rlang +- type: software + title: shiny + abstract: 'shiny: Web Application Framework for R' + notes: Imports + url: https://shiny.posit.co/ + repository: https://CRAN.R-project.org/package=shiny + authors: + - family-names: Chang + given-names: Winston + email: winston@posit.co + orcid: https://orcid.org/0000-0002-1576-2126 + - family-names: Cheng + given-names: Joe + email: joe@posit.co + - family-names: Allaire + given-names: JJ + email: jj@posit.co + - family-names: Sievert + given-names: Carson + email: carson@posit.co + orcid: https://orcid.org/0000-0002-4958-2844 + - family-names: Schloerke + given-names: Barret + email: barret@posit.co + orcid: https://orcid.org/0000-0001-9986-114X + - family-names: Aden-Buie + given-names: Garrick + email: garrick@adenbuie.com + orcid: https://orcid.org/0000-0002-7111-0077 + - family-names: Xie + given-names: Yihui + email: yihui@posit.co + - family-names: Allen + given-names: Jeff + - family-names: McPherson + given-names: Jonathan + email: jonathan@posit.co + - family-names: Dipert + given-names: Alan + - family-names: Borges + given-names: Barbara + year: '2026' + doi: 10.32614/CRAN.package.shiny + version: '>= 1.11.1' +- type: software + title: shinycssloaders + abstract: 'shinycssloaders: Add Loading Animations to a ''shiny'' Output While It''s + Recalculating' + notes: Imports + url: https://daattali.com/shiny/shinycssloaders-demo/ + repository: https://CRAN.R-project.org/package=shinycssloaders + authors: + - family-names: Attali + given-names: Dean + email: daattali@gmail.com + orcid: https://orcid.org/0000-0002-5645-3493 + - family-names: Sali + given-names: Andras + email: andras.sali@alphacruncher.hu + year: '2026' + doi: 10.32614/CRAN.package.shinycssloaders + version: '>= 1.1.0' +- type: software + title: bslib + abstract: 'bslib: Custom ''Bootstrap'' ''Sass'' Themes for ''shiny'' and ''rmarkdown''' + notes: Imports + url: https://rstudio.github.io/bslib/ + repository: https://CRAN.R-project.org/package=bslib + authors: + - family-names: Sievert + given-names: Carson + email: carson@posit.co + orcid: https://orcid.org/0000-0002-4958-2844 + - family-names: Cheng + given-names: Joe + email: joe@posit.co + - family-names: Aden-Buie + given-names: Garrick + email: garrick@posit.co + orcid: https://orcid.org/0000-0002-7111-0077 + year: '2026' + doi: 10.32614/CRAN.package.bslib + version: '>= 0.9.0' +- type: software + title: openxlsx + abstract: 'openxlsx: Read, Write and Edit xlsx Files' + notes: Imports + url: https://ycphs.github.io/openxlsx/index.html + repository: https://CRAN.R-project.org/package=openxlsx + authors: + - family-names: Schauberger + given-names: Philipp + email: philipp@schauberger.co.at + - family-names: Walker + given-names: Alexander + email: Alexander.Walker1989@gmail.com + year: '2026' + doi: 10.32614/CRAN.package.openxlsx + version: '>= 4.2.8.1' +- type: software + title: DT + abstract: 'DT: A Wrapper of the JavaScript Library ''DataTables''' + notes: Imports + url: https://github.com/rstudio/DT + repository: https://CRAN.R-project.org/package=DT + authors: + - family-names: Xie + given-names: Yihui + - family-names: Cheng + given-names: Joe + email: joe@posit.co + - family-names: Tan + given-names: Xianying + - family-names: Aden-Buie + given-names: Garrick + email: garrick@posit.co + orcid: https://orcid.org/0000-0002-7111-0077 + year: '2026' + doi: 10.32614/CRAN.package.DT +- type: software + title: htmltools + abstract: 'htmltools: Tools for HTML' + notes: Imports + url: https://rstudio.github.io/htmltools/ + repository: https://CRAN.R-project.org/package=htmltools + authors: + - family-names: Cheng + given-names: Joe + email: joe@posit.co + - family-names: Sievert + given-names: Carson + email: carson@posit.co + orcid: https://orcid.org/0000-0002-4958-2844 + - family-names: Schloerke + given-names: Barret + email: barret@posit.co + orcid: https://orcid.org/0000-0001-9986-114X + - family-names: Chang + given-names: Winston + email: winston@posit.co + orcid: https://orcid.org/0000-0002-1576-2126 + - family-names: Xie + given-names: Yihui + email: yihui@posit.co + - family-names: Allen + given-names: Jeff + year: '2026' + doi: 10.32614/CRAN.package.htmltools + version: '>= 0.5.8.1' +- type: software + title: scales + abstract: 'scales: Scale Functions for Visualization' + notes: Imports + url: https://scales.r-lib.org + repository: https://CRAN.R-project.org/package=scales + authors: + - family-names: Wickham + given-names: Hadley + email: hadley@posit.co + - family-names: Pedersen + given-names: Thomas Lin + email: thomas.pedersen@posit.co + orcid: https://orcid.org/0000-0002-5147-4711 + - family-names: Seidel + given-names: Dana + year: '2026' + doi: 10.32614/CRAN.package.scales + version: '>= 1.4.0' +- type: software + title: covr + abstract: 'covr: Test Coverage for Packages' + notes: Suggests + url: https://covr.r-lib.org + repository: https://CRAN.R-project.org/package=covr + authors: + - family-names: Hester + given-names: Jim + email: james.f.hester@gmail.com + year: '2026' + doi: 10.32614/CRAN.package.covr + version: '>= 3.6.4' +- type: software + title: knitr + abstract: 'knitr: A General-Purpose Package for Dynamic Report Generation in R' + notes: Suggests + url: https://yihui.org/knitr/ + repository: https://CRAN.R-project.org/package=knitr + authors: + - family-names: Xie + given-names: Yihui + email: xie@yihui.name + orcid: https://orcid.org/0000-0003-0645-5666 + year: '2026' + doi: 10.32614/CRAN.package.knitr + version: '>= 1.50' +- type: software + title: rmarkdown + abstract: 'rmarkdown: Dynamic Documents for R' + notes: Suggests + url: https://pkgs.rstudio.com/rmarkdown/ + repository: https://CRAN.R-project.org/package=rmarkdown + authors: + - family-names: Allaire + given-names: JJ + email: jj@posit.co + - family-names: Xie + given-names: Yihui + email: xie@yihui.name + orcid: https://orcid.org/0000-0003-0645-5666 + - family-names: Dervieux + given-names: Christophe + email: cderv@posit.co + orcid: https://orcid.org/0000-0003-4474-2498 + - family-names: McPherson + given-names: Jonathan + email: jonathan@posit.co + - family-names: Luraschi + given-names: Javier + - family-names: Ushey + given-names: Kevin + email: kevin@posit.co + - family-names: Atkins + given-names: Aron + email: aron@posit.co + - family-names: Wickham + given-names: Hadley + email: hadley@posit.co + - family-names: Cheng + given-names: Joe + email: joe@posit.co + - family-names: Chang + given-names: Winston + email: winston@posit.co + - family-names: Iannone + given-names: Richard + email: rich@posit.co + orcid: https://orcid.org/0000-0003-3925-190X + year: '2026' + doi: 10.32614/CRAN.package.rmarkdown + version: '>= 2.30' +- type: software + title: quarto + abstract: 'quarto: R Interface to ''Quarto'' Markdown Publishing System' + notes: Suggests + url: https://quarto-dev.github.io/quarto-r/ + repository: https://CRAN.R-project.org/package=quarto + authors: + - family-names: Allaire + given-names: JJ + email: jj@posit.co + orcid: https://orcid.org/0000-0003-0174-9868 + - family-names: Dervieux + given-names: Christophe + email: cderv@posit.co + orcid: https://orcid.org/0000-0003-4474-2498 + year: '2026' + doi: 10.32614/CRAN.package.quarto + version: '>= 1.4.4' +- type: software + title: spelling + abstract: 'spelling: Tools for Spell Checking in R' + notes: Suggests + url: https://ropensci.r-universe.dev/spelling + repository: https://CRAN.R-project.org/package=spelling + authors: + - family-names: Ooms + given-names: Jeroen + email: jeroenooms@gmail.com + orcid: https://orcid.org/0000-0002-4035-0289 + - family-names: Hester + given-names: Jim + email: james.hester@rstudio.com + year: '2026' + doi: 10.32614/CRAN.package.spelling + version: '>= 2.3.1' +- type: software + title: testthat + abstract: 'testthat: Unit Testing for R' + notes: Suggests + url: https://testthat.r-lib.org + repository: https://CRAN.R-project.org/package=testthat + authors: + - family-names: Wickham + given-names: Hadley + email: hadley@posit.co + year: '2026' + doi: 10.32614/CRAN.package.testthat + version: '>= 3.0.0' +- type: software + title: shinytest2 + abstract: 'shinytest2: Testing for Shiny Applications' + notes: Suggests + url: https://rstudio.github.io/shinytest2/ + repository: https://CRAN.R-project.org/package=shinytest2 + authors: + - family-names: Schloerke + given-names: Barret + email: barret@posit.co + orcid: https://orcid.org/0000-0001-9986-114X + year: '2026' + doi: 10.32614/CRAN.package.shinytest2 + version: '>= 0.4.1' +- type: software + title: stringr + abstract: 'stringr: Simple, Consistent Wrappers for Common String Operations' + notes: Suggests + url: https://stringr.tidyverse.org + repository: https://CRAN.R-project.org/package=stringr + authors: + - family-names: Wickham + given-names: Hadley + email: hadley@posit.co + year: '2026' + doi: 10.32614/CRAN.package.stringr + version: '>= 1.6.0' +- type: software + title: 'R: A Language and Environment for Statistical Computing' + notes: Depends + url: https://www.R-project.org/ + authors: + - name: R Core Team + website: https://ror.org/02zz1nj61 + institution: + name: R Foundation for Statistical Computing + website: https://ror.org/05qewa988 + address: Vienna, Austria + year: '2026' + doi: 10.32614/R.manuals + version: '>= 4.1.0' + diff --git a/DESCRIPTION b/DESCRIPTION index 0f4bb1e..4cfe995 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: mwanaApp -Title: mwana GUI -Version: 0.2.1 +Title: Graphical User Interface to 'mwana' +Version: 0.2.2 Authors@R: person(given = "Tomás", family = "Zaba", @@ -8,19 +8,17 @@ Authors@R: email = "tomas.zaba@outlook.com", comment = c(ORCID = "0000-0002-7079-3574") ) -Description: A seamless graphical interface to the mwana R package for data +Description: A graphical interface to the 'mwana' R package for data wrangling, plausibility checks, and prevalence estimation of wasting. License: GPL (>= 3) Encoding: UTF-8 -LazyData: true Language: en-GB Roxygen: list(markdown = TRUE) -RoxygenNote: 8.0.0 -URL: https://github.com/mphimo/mwanaApp, https://mphimo.github.io/mwanaApp/ +URL: https://github.com/mphimo/mwanaApp BugReports: https://github.com/mphimo/mwanaApp/issues Imports: dplyr (>= 1.1.4), - mwana (>= 0.2.3), + mwana (>= 0.2.5), rlang, shiny (>= 1.11.1), shinycssloaders (>= 1.1.0), @@ -38,8 +36,7 @@ Suggests: testthat (>= 3.0.0), shinytest2 (>= 0.4.1), stringr (>= 1.6.0) -Remotes: - mphimo/mwana Config/testthat/edition: 3 Depends: R (>= 4.1.0) +Config/roxygen2/version: 8.1.0 diff --git a/NEWS.md b/NEWS.md index f26b870..49b400d 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,16 @@ +# mwanaApp 0.2.2 + +### Bug fixes + ++ Removed the survey weights input field from the prevalence module's UI when +the selected data source is "screening" or "sentinel" (it is now shown only +for the "survey" source) (#45). + +### General updates ++ Revised user-guide documentation to enhance clarity on type and format of the +input variables to the app. ++ Updated hyperlinks to open in a new browser tab. + # mwanaApp 0.2.1 ### Bug fixes diff --git a/README.md b/README.md index 29d41c6..0e75f1b 100644 --- a/README.md +++ b/README.md @@ -54,7 +54,7 @@ citation("mwanaApp") Tomás Zaba (2026). _mwanaApp: A seamless graphical interface to the mwana R package for data wrangling, plausibility checks, and - prevalence estimation of wasting_. R package version 0.2.1, + prevalence estimation of wasting_. R package version 0.2.2, . A BibTeX entry for LaTeX users is @@ -63,6 +63,6 @@ citation("mwanaApp") title = {mwanaApp: A seamless graphical interface to the mwana R package for data wrangling, plausibility checks, and prevalence estimation of wasting}, author = {{Tomás Zaba}}, year = {2026}, - note = {R package version 0.2.1}, + note = {R package version 0.2.2}, url = {https://github.com/mphimo/mwanaApp}, } diff --git a/inst/CITATION b/inst/CITATION index ccf4fdb..de66d16 100644 --- a/inst/CITATION +++ b/inst/CITATION @@ -4,6 +4,6 @@ bibentry( title = "mwanaApp: A seamless graphical interface to the mwana R package for data wrangling, plausibility checks, and prevalence estimation of wasting", author = person("Tomás Zaba"), year = 2026, - note = "R package version 0.2.1", + note = "R package version 0.2.2", url = "https://github.com/mphimo/mwanaApp" ) diff --git a/man/mwanaApp-package.Rd b/man/mwanaApp-package.Rd index e514e8e..9461e24 100644 --- a/man/mwanaApp-package.Rd +++ b/man/mwanaApp-package.Rd @@ -4,15 +4,14 @@ \name{mwanaApp-package} \alias{mwanaApp} \alias{mwanaApp-package} -\title{mwanaApp: mwana GUI} +\title{mwanaApp: Graphical User Interface to 'mwana'} \description{ -A seamless graphical interface to the mwana R package for data wrangling, plausibility checks, and prevalence estimation of wasting. +A graphical interface to the 'mwana' R package for data wrangling, plausibility checks, and prevalence estimation of wasting. } \seealso{ Useful links: \itemize{ \item \url{https://github.com/mphimo/mwanaApp} - \item \url{https://mphimo.github.io/mwanaApp/} \item Report bugs at \url{https://github.com/mphimo/mwanaApp/issues} } diff --git a/tests/testthat/test-module-data-upload.R b/tests/testthat/test-module-data-upload.R index 60b0ad1..3092892 100644 --- a/tests/testthat/test-module-data-upload.R +++ b/tests/testthat/test-module-data-upload.R @@ -2,16 +2,12 @@ # Test Suite: Module Data Upload # ============================================================================== - ## ---- Module: Data Upload ---------------------------------------------------- - -### Skip test on windows ---- -# if (identical(Sys.getenv("CI"), "true") && Sys.info()[["sysname"]] == "Windows") { -# skip("Skipping shinytest2 integration tests on Windows CI to reduce runtime") -# } - testthat::test_that("Data upload tab works as expected", { + ### Skip test on CRAN ---- + testthat::skip_on_cran() + ### Initialise app ---- app <- shinytest2::AppDriver$new( app_dir = testthat::test_path("fixtures"), @@ -46,23 +42,41 @@ testthat::test_that("Data upload tab works as expected", { ) ### Test checks ---- - testthat::expect_gte(object = column_names$input$`upload_data-upload`$size, 130756) - testthat::expect_equal(object = column_names$input$`upload_data-upload`$type, "text/csv") + testthat::expect_gte( + object = column_names$input$`upload_data-upload`$size, + 130756 + ) + testthat::expect_equal( + object = column_names$input$`upload_data-upload`$type, + "text/csv" + ) testthat::expect_true(object = column_names$output$`upload_data-fileUploaded`) - testthat::expect_true(app$get_js("$('#upload_data-uploadedDataTable').length > 0")) + testthat::expect_true(app$get_js( + "$('#upload_data-uploadedDataTable').length > 0" + )) expect_equal( - object = app$get_js(" + object = app$get_js( + " $('#upload_data-uploadedDataTable thead th').map(function() { return $(this).text(); }).get(); - ")[1:10] |> as.character(), + " + )[1:10] |> + as.character(), expected = c( - "province", "strata", "cluster", "sex", "age", "weight", "height", - "oedema", "muac", "wtfactor" + "province", + "strata", + "cluster", + "sex", + "age", + "weight", + "height", + "oedema", + "muac", + "wtfactor" ) ) #### Stop the app ---- app$stop() }) - diff --git a/tests/testthat/test-module-ipc-check.R b/tests/testthat/test-module-ipc-check.R index 372af80..7a4dfab 100644 --- a/tests/testthat/test-module-ipc-check.R +++ b/tests/testthat/test-module-ipc-check.R @@ -2,214 +2,206 @@ # Test Suite: Module IPC Check # ============================================================================== - ## ---- IPC check on survey data ----------------------------------------------- - -### Skip test on windows ---- -# if (identical(Sys.getenv("CI"), "true") && Sys.info()[["sysname"]] == "Windows") { -# skip("Skipping shinytest2 integration tests on Windows CI to reduce runtime") -# } - -testthat::test_that( - "IPC check's server module behaves as expected on survey data", - { - ### Initialise mwana app ---- - app <- shinytest2::AppDriver$new( - app_dir = testthat::test_path("fixtures"), - load_timeout = 120000, - wait = TRUE - ) - - ### Let the app load ---- - app$wait_for_idle(timeout = 40000) - - ### Click on the Data uploading navbar ---- - app$click(selector = "a[data-value='Data Upload']") - app$wait_for_idle(timeout = 40000) - - ### Upload data ---- - #### Read data ---- - data <- read.csv( - file = testthat::test_path("fixtures", "anthro-01.csv"), - check.names = FALSE - ) - tempfile <- tempfile(fileext = ".csv") - write.csv(data, tempfile, row.names = FALSE) - - #### Upload onto the app ---- - app$upload_file(`upload_data-upload` = tempfile, wait_ = TRUE) - - ### Click on the Data uploading navbar ---- - app$click(selector = "a[data-value='IPC Check']") - app$wait_for_idle(timeout = 40000) - - #### Set IPC Check for survey data ---- - app$set_inputs(`ipc_check-ipccheck` = "survey", wait_ = FALSE) - app$wait_for_idle(timeout = 40000) - - #### Now set parameters for survey ---- - app$set_inputs(`ipc_check-area1` = "province", wait_ = FALSE) - app$set_inputs(`ipc_check-area2` = "strata", wait_ = FALSE) - app$set_inputs(`ipc_check-psu` = "cluster", wait_ = FALSE) - - #### Run check ---- - app$click(input = "ipc_check-apply_check") - app$wait_for_value(output = "ipc_check-checked", timeout = 40000) - - ### Capture JavaScript expressions to return results's cols and values ---- - js_cols <- "$('#ipc_check-checked thead th').map(function() { +testthat::test_that("IPC check's server module behaves as expected on survey data", { + ### Skip test on CRAN ---- + testthat::skip_on_cran() + + ### Initialise mwana app ---- + app <- shinytest2::AppDriver$new( + app_dir = testthat::test_path("fixtures"), + load_timeout = 120000, + wait = TRUE + ) + + ### Let the app load ---- + app$wait_for_idle(timeout = 40000) + + ### Click on the Data uploading navbar ---- + app$click(selector = "a[data-value='Data Upload']") + app$wait_for_idle(timeout = 40000) + + ### Upload data ---- + #### Read data ---- + data <- read.csv( + file = testthat::test_path("fixtures", "anthro-01.csv"), + check.names = FALSE + ) + tempfile <- tempfile(fileext = ".csv") + write.csv(data, tempfile, row.names = FALSE) + + #### Upload onto the app ---- + app$upload_file(`upload_data-upload` = tempfile, wait_ = TRUE) + + ### Click on the Data uploading navbar ---- + app$click(selector = "a[data-value='IPC Check']") + app$wait_for_idle(timeout = 40000) + + #### Set IPC Check for survey data ---- + app$set_inputs(`ipc_check-ipccheck` = "survey", wait_ = FALSE) + app$wait_for_idle(timeout = 40000) + + #### Now set parameters for survey ---- + app$set_inputs(`ipc_check-area1` = "province", wait_ = FALSE) + app$set_inputs(`ipc_check-area2` = "strata", wait_ = FALSE) + app$set_inputs(`ipc_check-psu` = "cluster", wait_ = FALSE) + + #### Run check ---- + app$click(input = "ipc_check-apply_check") + app$wait_for_value(output = "ipc_check-checked", timeout = 40000) + + ### Capture JavaScript expressions to return results's cols and values ---- + js_cols <- "$('#ipc_check-checked thead th').map(function() { return $(this).text();}).get();" - js_values <- "$('#ipc_check-checked tbody tr').map(function() + js_values <- "$('#ipc_check-checked tbody tr').map(function() {return $(this).text();}).get();" - ### Test check ---- - testthat::expect_true(app$get_js("$('#ipc_check-checked').length > 0")) - testthat::expect_equal(as.character(app$get_js(js_cols)[1:5]), + ### Test check ---- + testthat::expect_true(app$get_js("$('#ipc_check-checked').length > 0")) + testthat::expect_equal( + as.character(app$get_js(js_cols)[1:5]), c("province", "strata", "n_clusters", "n_obs", "meet_ipc") - ) - testthat::expect_equal(app$get_js(js_values)[[1]], "NampulaRural60472yes") - testthat::expect_equal(app$get_js(js_values)[[3]], "ZambeziaRural51368yes") - } -) + ) + testthat::expect_equal(app$get_js(js_values)[[1]], "NampulaRural60472yes") + testthat::expect_equal(app$get_js(js_values)[[3]], "ZambeziaRural51368yes") +}) ## ---- IPC Check on screening data -------------------------------------------- - -### Skip test on windows ---- -# if (identical(Sys.getenv("CI"), "true") && Sys.info()[["sysname"]] == "Windows") { -# skip("Skipping shinytest2 integration tests on Windows CI to reduce runtime") -# } - -testthat::test_that( - "IPC check's server module behaves as expected on screening data", - { - ### Initialise mwana app ---- - app <- shinytest2::AppDriver$new( - app_dir = testthat::test_path("fixtures"), - load_timeout = 120000, - wait = TRUE - ) - - ### Let the app load ---- - app$wait_for_idle(timeout = 40000) - - ### Click on the Data uploading navbar ---- - app$click(selector = "a[data-value='Data Upload']") - app$wait_for_idle(timeout = 40000) - - ### Upload data ---- - #### Read data ---- - data <- read.csv( - file = testthat::test_path("fixtures", "anthro-01.csv"), - check.names = FALSE - ) - tempfile <- tempfile(fileext = ".csv") - write.csv(data, tempfile, row.names = FALSE) - - #### Upload onto the app ---- - app$upload_file(`upload_data-upload` = tempfile, wait_ = TRUE) - - #### Set IPC Check for screening data ---- - app$set_inputs(`ipc_check-ipccheck` = "screening", wait_ = TRUE, timeout_ = 10000) - app$wait_for_idle(timeout = 40000) - - ### Click on the Data uploading navbar ---- - app$click(selector = "a[data-value='IPC Check']") - app$wait_for_idle(timeout = 40000) - - #### Now set parameters for survey ---- - app$set_inputs(`ipc_check-area1` = "province", wait_ = FALSE) - app$set_inputs(`ipc_check-area2` = "strata", wait_ = FALSE) - app$set_inputs(`ipc_check-sites` = "cluster", wait_ = FALSE) - - #### Run check ---- - app$click(input = "ipc_check-apply_check") - app$wait_for_value(output = "ipc_check-checked", timeout = 40000) - - ### Capture JavaScript expressions to return results's cols and values ---- - js_cols <- "$('#ipc_check-checked thead th').map(function() { +testthat::test_that("IPC check's server module behaves as expected on screening data", { + ### Skip test on CRAN ---- + testthat::skip_on_cran() + + ### Initialise mwana app ---- + app <- shinytest2::AppDriver$new( + app_dir = testthat::test_path("fixtures"), + load_timeout = 120000, + wait = TRUE + ) + + ### Let the app load ---- + app$wait_for_idle(timeout = 40000) + + ### Click on the Data uploading navbar ---- + app$click(selector = "a[data-value='Data Upload']") + app$wait_for_idle(timeout = 40000) + + ### Upload data ---- + #### Read data ---- + data <- read.csv( + file = testthat::test_path("fixtures", "anthro-01.csv"), + check.names = FALSE + ) + tempfile <- tempfile(fileext = ".csv") + write.csv(data, tempfile, row.names = FALSE) + + #### Upload onto the app ---- + app$upload_file(`upload_data-upload` = tempfile, wait_ = TRUE) + + #### Set IPC Check for screening data ---- + app$set_inputs( + `ipc_check-ipccheck` = "screening", + wait_ = TRUE, + timeout_ = 10000 + ) + app$wait_for_idle(timeout = 40000) + + ### Click on the Data uploading navbar ---- + app$click(selector = "a[data-value='IPC Check']") + app$wait_for_idle(timeout = 40000) + + #### Now set parameters for survey ---- + app$set_inputs(`ipc_check-area1` = "province", wait_ = FALSE) + app$set_inputs(`ipc_check-area2` = "strata", wait_ = FALSE) + app$set_inputs(`ipc_check-sites` = "cluster", wait_ = FALSE) + + #### Run check ---- + app$click(input = "ipc_check-apply_check") + app$wait_for_value(output = "ipc_check-checked", timeout = 40000) + + ### Capture JavaScript expressions to return results's cols and values ---- + js_cols <- "$('#ipc_check-checked thead th').map(function() { return $(this).text();}).get();" - js_values <- "$('#ipc_check-checked tbody tr').map(function() + js_values <- "$('#ipc_check-checked tbody tr').map(function() {return $(this).text();}).get();" - ### Test ---- - testthat::expect_true(app$get_js("$('#ipc_check-checked').length > 0")) - testthat::expect_equal(as.character(app$get_js(js_cols)[1:5]), + ### Test ---- + testthat::expect_true(app$get_js("$('#ipc_check-checked').length > 0")) + testthat::expect_equal( + as.character(app$get_js(js_cols)[1:5]), c("province", "strata", "n_clusters", "n_obs", "meet_ipc") - ) - testthat::expect_equal(app$get_js(js_values)[[1]], "NampulaRural60472no") - testthat::expect_equal(app$get_js(js_values)[[3]], "ZambeziaRural51368no") - } -) + ) + testthat::expect_equal(app$get_js(js_values)[[1]], "NampulaRural60472no") + testthat::expect_equal(app$get_js(js_values)[[3]], "ZambeziaRural51368no") +}) ## ---- IPC Check on sentinel site data ---------------------------------------- - -### Skip test on windows ---- -# if (identical(Sys.getenv("CI"), "true") && Sys.info()[["sysname"]] == "Windows") { -# skip("Skipping shinytest2 integration tests on Windows CI to reduce runtime") -# } - -testthat::test_that( - "IPC check's server module behaves as expected on sentinel site data", - { - ### Initialise mwana app ---- - app <- shinytest2::AppDriver$new( - app_dir = testthat::test_path("fixtures"), - load_timeout = 120000, - wait = TRUE - ) - - ### Let the app load ---- - app$wait_for_idle(timeout = 40000) - - ### Click on the Data uploading navbar ---- - app$click(selector = "a[data-value='Data Upload']") - app$wait_for_idle(timeout = 40000) - - ### Upload data ---- - #### Read data ---- - data <- read.csv( - file = testthat::test_path("fixtures", "anthro-01.csv"), - check.names = FALSE - ) - tempfile <- tempfile(fileext = ".csv") - write.csv(data, tempfile, row.names = FALSE) - - #### Upload onto the app ---- - app$upload_file(`upload_data-upload` = tempfile, wait_ = TRUE) - - ### Click on the IPC Check nav bar ---- - app$click(selector = "a[data-value='IPC Check']") - - #### Set IPC Check for screening data ---- - app$set_inputs(`ipc_check-ipccheck` = "sentinel", wait_ = TRUE, timeout_ = 10000) - app$wait_for_idle(timeout = 40000) - - #### Now set parameters for survey ---- - app$set_inputs(`ipc_check-area1` = "province", wait_ = FALSE) - app$set_inputs(`ipc_check-area2` = "strata", wait_ = FALSE) - app$set_inputs(`ipc_check-ssites` = "cluster", wait_ = FALSE) - - #### Run check ---- - app$click(input = "ipc_check-apply_check") - app$wait_for_value(output = "ipc_check-checked", timeout = 40000) - - ### Capture JavaScript expressions to return results's cols and values ---- - js_cols <- "$('#ipc_check-checked thead th').map(function() { +testthat::test_that("IPC check's server module behaves as expected on sentinel site data", { + ### Skip test on CRAN ---- + testthat::skip_on_cran() + + ### Initialise mwana app ---- + app <- shinytest2::AppDriver$new( + app_dir = testthat::test_path("fixtures"), + load_timeout = 120000, + wait = TRUE + ) + + ### Let the app load ---- + app$wait_for_idle(timeout = 40000) + + ### Click on the Data uploading navbar ---- + app$click(selector = "a[data-value='Data Upload']") + app$wait_for_idle(timeout = 40000) + + ### Upload data ---- + #### Read data ---- + data <- read.csv( + file = testthat::test_path("fixtures", "anthro-01.csv"), + check.names = FALSE + ) + tempfile <- tempfile(fileext = ".csv") + write.csv(data, tempfile, row.names = FALSE) + + #### Upload onto the app ---- + app$upload_file(`upload_data-upload` = tempfile, wait_ = TRUE) + + ### Click on the IPC Check nav bar ---- + app$click(selector = "a[data-value='IPC Check']") + + #### Set IPC Check for screening data ---- + app$set_inputs( + `ipc_check-ipccheck` = "sentinel", + wait_ = TRUE, + timeout_ = 10000 + ) + app$wait_for_idle(timeout = 40000) + + #### Now set parameters for survey ---- + app$set_inputs(`ipc_check-area1` = "province", wait_ = FALSE) + app$set_inputs(`ipc_check-area2` = "strata", wait_ = FALSE) + app$set_inputs(`ipc_check-ssites` = "cluster", wait_ = FALSE) + + #### Run check ---- + app$click(input = "ipc_check-apply_check") + app$wait_for_value(output = "ipc_check-checked", timeout = 40000) + + ### Capture JavaScript expressions to return results's cols and values ---- + js_cols <- "$('#ipc_check-checked thead th').map(function() { return $(this).text();}).get();" - js_values <- "$('#ipc_check-checked tbody tr').map(function() + js_values <- "$('#ipc_check-checked tbody tr').map(function() {return $(this).text();}).get();" - ### Test ---- - testthat::expect_true(app$get_js("$('#ipc_check-checked').length > 0")) - testthat::expect_equal(as.character(app$get_js(js_cols)[1:5]), + ### Test ---- + testthat::expect_true(app$get_js("$('#ipc_check-checked').length > 0")) + testthat::expect_equal( + as.character(app$get_js(js_cols)[1:5]), c("province", "strata", "n_clusters", "n_obs", "meet_ipc") - ) - testthat::expect_equal(app$get_js(js_values)[[1]], "NampulaRural60472yes") - testthat::expect_equal(app$get_js(js_values)[[3]], "ZambeziaRural51368yes") - } -) + ) + testthat::expect_equal(app$get_js(js_values)[[1]], "NampulaRural60472yes") + testthat::expect_equal(app$get_js(js_values)[[3]], "ZambeziaRural51368yes") +}) diff --git a/tests/testthat/test-module-plausibility-check.R b/tests/testthat/test-module-plausibility-check.R index 76fdd16..1c05d09 100644 --- a/tests/testthat/test-module-plausibility-check.R +++ b/tests/testthat/test-module-plausibility-check.R @@ -2,309 +2,341 @@ # Test Suite: Module Plausibility Check # ============================================================================== - ## ---- Plausibility Check on WFHZ data ---------------------------------------- - -### Skip test on windows ---- -# if (identical(Sys.getenv("CI"), "true") && Sys.info()[["sysname"]] == "Windows") { -# skip("Skipping shinytest2 integration tests on Windows CI to reduce runtime") -# } - -testthat::test_that( - desc = "Plausibility check module works well for WFHZ data", - code = { - ### Initialise mwana app ---- - app <- shinytest2::AppDriver$new( - app_dir = testthat::test_path("fixtures"), - load_timeout = 120000, - wait = TRUE - ) - - ### Let the app load ---- - app$wait_for_idle(timeout = 40000) - - ### Click on data upload tab ---- - app$click(selector = "a[data-value='Data Upload']") - app$wait_for_idle(timeout = 40000) - - #### Find the data to upload ---- - data <- read.csv( - file = testthat::test_path("fixtures", "anthro-01.csv"), - check.names = FALSE - ) - - tempfile <- tempfile(fileext = ".csv") - write.csv(data, tempfile, row.names = FALSE) - - #### Upload ---- - app$upload_file(`upload_data-upload` = tempfile, wait_ = TRUE) - - ### Click on the data wrangling tab ---- - app$click(selector = "a[data-value='Data Wrangling']") - app$wait_for_idle(timeout = 40000) - - ### Select data wrangling method ---- - app$set_inputs(`wrangle_data-wrangle` = "wfhz", wait_ = FALSE) - - ### Select input variables ---- - app$set_inputs(`wrangle_data-dos` = "", wait_ = FALSE) - app$set_inputs(`wrangle_data-dob` = "", wait_ = FALSE) - app$set_inputs(`wrangle_data-age` = "", wait_ = FALSE) - app$set_inputs(`wrangle_data-sex` = "sex", wait_ = FALSE) - app$set_inputs(`wrangle_data-weight` = "weight", wait_ = FALSE) - app$set_inputs(`wrangle_data-height` = "height", wait_ = FALSE) - - ### Click wrangle button ---- - app$click(input = "wrangle_data-apply_wrangle") - app$wait_for_idle(timeout = 40000) - - ### Click on the Plausibility Check tab ---- - app$click(selector = "a[data-value='Plausibility Check']") - app$wait_for_idle(timeout = 40000) - - ### Select method for plausibility check ---- - app$set_inputs(`plausible-method` = "wfhz", wait_ = FALSE) - - ### Select input variables ---- - app$set_inputs(`plausible-area1` = "province", wait_ = FALSE) - app$set_inputs(`plausible-area2` = "strata", wait_ = FALSE) - app$set_inputs(`plausible-area3` = "sex", wait_ = FALSE) - app$set_inputs(`plausible-sex` = "sex", wait_ = FALSE) - app$set_inputs(`plausible-age` = "age", wait_ = FALSE) - app$set_inputs(`plausible-weight` = "weight", wait_ = FALSE) - app$set_inputs(`plausible-height` = "height", wait_ = FALSE) - app$set_inputs(`plausible-flags` = "flag_wfhz", wait_ = FALSE) - - ### Click on check plausibility button ---- - app$click(input = "plausible-check") - app$wait_for_value(output = "plausible-checked", timeout = 40000) - - ### Capture JavaScript expressions to return results's cols and values ---- - js_cols <- "$('#plausible-checked thead th').map(function() { +testthat::test_that(desc = "Plausibility check module works well for WFHZ data", code = { + ### Skip test on CRAN ---- + testthat::skip_on_cran() + + ### Initialise mwana app ---- + app <- shinytest2::AppDriver$new( + app_dir = testthat::test_path("fixtures"), + load_timeout = 120000, + wait = TRUE + ) + + ### Let the app load ---- + app$wait_for_idle(timeout = 40000) + + ### Click on data upload tab ---- + app$click(selector = "a[data-value='Data Upload']") + app$wait_for_idle(timeout = 40000) + + #### Find the data to upload ---- + data <- read.csv( + file = testthat::test_path("fixtures", "anthro-01.csv"), + check.names = FALSE + ) + + tempfile <- tempfile(fileext = ".csv") + write.csv(data, tempfile, row.names = FALSE) + + #### Upload ---- + app$upload_file(`upload_data-upload` = tempfile, wait_ = TRUE) + + ### Click on the data wrangling tab ---- + app$click(selector = "a[data-value='Data Wrangling']") + app$wait_for_idle(timeout = 40000) + + ### Select data wrangling method ---- + app$set_inputs(`wrangle_data-wrangle` = "wfhz", wait_ = FALSE) + + ### Select input variables ---- + app$set_inputs(`wrangle_data-dos` = "", wait_ = FALSE) + app$set_inputs(`wrangle_data-dob` = "", wait_ = FALSE) + app$set_inputs(`wrangle_data-age` = "", wait_ = FALSE) + app$set_inputs(`wrangle_data-sex` = "sex", wait_ = FALSE) + app$set_inputs(`wrangle_data-weight` = "weight", wait_ = FALSE) + app$set_inputs(`wrangle_data-height` = "height", wait_ = FALSE) + + ### Click wrangle button ---- + app$click(input = "wrangle_data-apply_wrangle") + app$wait_for_idle(timeout = 40000) + + ### Click on the Plausibility Check tab ---- + app$click(selector = "a[data-value='Plausibility Check']") + app$wait_for_idle(timeout = 40000) + + ### Select method for plausibility check ---- + app$set_inputs(`plausible-method` = "wfhz", wait_ = FALSE) + + ### Select input variables ---- + app$set_inputs(`plausible-area1` = "province", wait_ = FALSE) + app$set_inputs(`plausible-area2` = "strata", wait_ = FALSE) + app$set_inputs(`plausible-area3` = "sex", wait_ = FALSE) + app$set_inputs(`plausible-sex` = "sex", wait_ = FALSE) + app$set_inputs(`plausible-age` = "age", wait_ = FALSE) + app$set_inputs(`plausible-weight` = "weight", wait_ = FALSE) + app$set_inputs(`plausible-height` = "height", wait_ = FALSE) + app$set_inputs(`plausible-flags` = "flag_wfhz", wait_ = FALSE) + + ### Click on check plausibility button ---- + app$click(input = "plausible-check") + app$wait_for_value(output = "plausible-checked", timeout = 40000) + + ### Capture JavaScript expressions to return results's cols and values ---- + js_cols <- "$('#plausible-checked thead th').map(function() { return $(this).text();}).get();" - - js_values <- "$('#plausible-checked tbody tr').map(function() + + js_values <- "$('#plausible-checked tbody tr').map(function() {return $(this).text();}).get();" - ### Capture Zambezia-urban plausibility check results ---- - plausibility_results <- - "ZambeziaRural23681.4%Excellent<0.001Problematic0.882Excellent9Good7Excellent0.92Excellent0.1Excellent0.2Excellent12Good" - - ### Test check ----- - testthat::expect_equal(as.character(app$get_js(js_cols)[1:22]), - expected = c( - "Province", "Strata", "Sex", "Total children", "Flagged data (%)", - "Class. of flagged data", "Sex ratio (p)", "Class. of sex ratio", - "Age ratio (p)", "Class. of age ratio", "DPS weight (#)", "Class. DPS weight", - "DPS height (#)", "Class. DPS height", "Standard Dev* (#)", - "Class. of standard dev", "Skewness* (#)", "Class. of skewness", - "Kurtosis* (#)", "Class. of kurtosis", "Overall score", "Overall quality" - ) + ### Capture Zambezia-urban plausibility check results ---- + plausibility_results <- + "ZambeziaRural23681.4%Excellent<0.001Problematic0.882Excellent9Good7Excellent0.92Excellent0.1Excellent0.2Excellent12Good" + + ### Test check ----- + testthat::expect_equal( + as.character(app$get_js(js_cols)[1:22]), + expected = c( + "Province", + "Strata", + "Sex", + "Total children", + "Flagged data (%)", + "Class. of flagged data", + "Sex ratio (p)", + "Class. of sex ratio", + "Age ratio (p)", + "Class. of age ratio", + "DPS weight (#)", + "Class. DPS weight", + "DPS height (#)", + "Class. DPS height", + "Standard Dev* (#)", + "Class. of standard dev", + "Skewness* (#)", + "Class. of skewness", + "Kurtosis* (#)", + "Class. of kurtosis", + "Overall score", + "Overall quality" ) - testthat::expect_equal(app$get_js(js_values)[[3]], plausibility_results) - ### Stop the app ---- - app$stop() - } -) + ) + testthat::expect_equal(app$get_js(js_values)[[3]], plausibility_results) + ### Stop the app ---- + app$stop() +}) ## ---- Plausibility Check on MFAZ data ---------------------------------------- - -### Skip test on windows ---- -# if (identical(Sys.getenv("CI"), "true") && Sys.info()[["sysname"]] == "Windows") { -# skip("Skipping shinytest2 integration tests on Windows CI to reduce runtime") -# } - -testthat::test_that( - desc = "Plausibility check module works well for MFAZ data", - code = { - # Initialise app ---- - app <- shinytest2::AppDriver$new( - app_dir = testthat::test_path("fixtures"), - load_timeout = 120000, - wait = TRUE - ) - - ### Let the app load ---- - app$wait_for_idle(timeout = 40000) - - ### Click on the Data uploading navbar ---- - app$click(selector = "a[data-value='Data Upload']") - app$wait_for_idle(timeout = 40000) - - #### Read data ---- - data <- read.csv( - file = testthat::test_path("fixtures", "anthro-01.csv"), - check.names = FALSE - ) - tempfile <- tempfile(fileext = ".csv") - write.csv(data, tempfile, row.names = FALSE) - - #### Upload onto the app ---- - app$upload_file(`upload_data-upload` = tempfile, wait_ = TRUE) - - ### Click on the data wrangling tab ---- - app$click(selector = "a[data-value='Data Wrangling']") - app$wait_for_idle(timeout = 40000) - - ### Select data wrangling method ---- - app$set_inputs(`wrangle_data-wrangle` = "mfaz", wait_ = TRUE, timeout_ = 15000) - app$wait_for_idle(timeout = 40000) - - app$set_inputs(`wrangle_data-dos` = "", wait_ = FALSE) - app$set_inputs(`wrangle_data-dob` = "", wait_ = FALSE) - app$set_inputs(`wrangle_data-age` = "age", wait_ = FALSE) - app$set_inputs(`wrangle_data-sex` = "sex", wait_ = FALSE) - app$set_inputs(`wrangle_data-muac` = "muac", wait_ = FALSE) - - ### Click wrangle button ---- - app$click(input = "wrangle_data-apply_wrangle") - app$wait_for_idle(timeout = 40000) - - ### Click on the Plausibility Check tab ---- - app$click(selector = "a[data-value='Plausibility Check']") - app$wait_for_idle(timeout = 40000) - - ### Select method for plausibility check ---- - app$set_inputs(`plausible-method` = "mfaz", wait_ = TRUE, timeout_ = 15000) - - ### Select input variables ---- - app$set_inputs(`plausible-area1` = "province", wait_ = FALSE) - app$set_inputs(`plausible-area2` = "strata", wait_ = FALSE) - app$set_inputs(`plausible-area3` = "sex", wait_ = FALSE) - app$set_inputs(`plausible-sex` = "sex", wait_ = FALSE) - app$set_inputs(`plausible-age` = "age", wait_ = FALSE) - app$set_inputs(`plausible-muac` = "muac", wait_ = FALSE) - app$set_inputs(`plausible-flags` = "flag_mfaz", wait_ = FALSE) - - ### Click on check plausibility button ---- - app$click(input = "plausible-check") - app$wait_for_value(output = "plausible-checked", timeout = 40000) - - ### Capture JavaScript expressions to return results's cols and values ---- - js_cols <- "$('#plausible-checked thead th').map(function() { +testthat::test_that(desc = "Plausibility check module works well for MFAZ data", code = { + ### Skip test on CRAN ---- + testthat::skip_on_cran() + + # Initialise app ---- + app <- shinytest2::AppDriver$new( + app_dir = testthat::test_path("fixtures"), + load_timeout = 120000, + wait = TRUE + ) + + ### Let the app load ---- + app$wait_for_idle(timeout = 40000) + + ### Click on the Data uploading navbar ---- + app$click(selector = "a[data-value='Data Upload']") + app$wait_for_idle(timeout = 40000) + + #### Read data ---- + data <- read.csv( + file = testthat::test_path("fixtures", "anthro-01.csv"), + check.names = FALSE + ) + tempfile <- tempfile(fileext = ".csv") + write.csv(data, tempfile, row.names = FALSE) + + #### Upload onto the app ---- + app$upload_file(`upload_data-upload` = tempfile, wait_ = TRUE) + + ### Click on the data wrangling tab ---- + app$click(selector = "a[data-value='Data Wrangling']") + app$wait_for_idle(timeout = 40000) + + ### Select data wrangling method ---- + app$set_inputs( + `wrangle_data-wrangle` = "mfaz", + wait_ = TRUE, + timeout_ = 15000 + ) + app$wait_for_idle(timeout = 40000) + + app$set_inputs(`wrangle_data-dos` = "", wait_ = FALSE) + app$set_inputs(`wrangle_data-dob` = "", wait_ = FALSE) + app$set_inputs(`wrangle_data-age` = "age", wait_ = FALSE) + app$set_inputs(`wrangle_data-sex` = "sex", wait_ = FALSE) + app$set_inputs(`wrangle_data-muac` = "muac", wait_ = FALSE) + + ### Click wrangle button ---- + app$click(input = "wrangle_data-apply_wrangle") + app$wait_for_idle(timeout = 40000) + + ### Click on the Plausibility Check tab ---- + app$click(selector = "a[data-value='Plausibility Check']") + app$wait_for_idle(timeout = 40000) + + ### Select method for plausibility check ---- + app$set_inputs(`plausible-method` = "mfaz", wait_ = TRUE, timeout_ = 15000) + + ### Select input variables ---- + app$set_inputs(`plausible-area1` = "province", wait_ = FALSE) + app$set_inputs(`plausible-area2` = "strata", wait_ = FALSE) + app$set_inputs(`plausible-area3` = "sex", wait_ = FALSE) + app$set_inputs(`plausible-sex` = "sex", wait_ = FALSE) + app$set_inputs(`plausible-age` = "age", wait_ = FALSE) + app$set_inputs(`plausible-muac` = "muac", wait_ = FALSE) + app$set_inputs(`plausible-flags` = "flag_mfaz", wait_ = FALSE) + + ### Click on check plausibility button ---- + app$click(input = "plausible-check") + app$wait_for_value(output = "plausible-checked", timeout = 40000) + + ### Capture JavaScript expressions to return results's cols and values ---- + js_cols <- "$('#plausible-checked thead th').map(function() { return $(this).text();}).get();" - js_values <- "$('#plausible-checked tbody tr').map(function() + js_values <- "$('#plausible-checked tbody tr').map(function() {return $(this).text();}).get();" - ### Capture Nampula-urban plausibility check results ---- - plausibility_results <- - "NampulaUrban26141.3%Good<0.001Problematic0.241Excellent10Good0.96Excellent-0.36Excellent0.27Good18Acceptable" - - ### Test check ---- - testthat::expect_equal(as.character(app$get_js(js_cols)[1:20]), - expected = c( - "Province", "Strata", "Sex", "Total children", "Flagged data (%)", - "Class. of flagged data", "Sex ratio (p)", "Class. of sex ratio", - "Age ratio (p)", "Class. of age ratio", "DPS (#)", - "Class. of DPS", "Standard Dev* (#)", "Class. of standard dev", - "Skewness* (#)", "Class. of skewness", "Kurtosis* (#)", - "Class. of kurtosis", "Overall score", "Overall quality" - ) + ### Capture Nampula-urban plausibility check results ---- + plausibility_results <- + "NampulaUrban26141.3%Good<0.001Problematic0.241Excellent10Good0.96Excellent-0.36Excellent0.27Good18Acceptable" + + ### Test check ---- + testthat::expect_equal( + as.character(app$get_js(js_cols)[1:20]), + expected = c( + "Province", + "Strata", + "Sex", + "Total children", + "Flagged data (%)", + "Class. of flagged data", + "Sex ratio (p)", + "Class. of sex ratio", + "Age ratio (p)", + "Class. of age ratio", + "DPS (#)", + "Class. of DPS", + "Standard Dev* (#)", + "Class. of standard dev", + "Skewness* (#)", + "Class. of skewness", + "Kurtosis* (#)", + "Class. of kurtosis", + "Overall score", + "Overall quality" ) - testthat::expect_equal(app$get_js(js_values)[[2]], plausibility_results) - ### Stop the app ---- - app$stop() - } -) + ) + testthat::expect_equal(app$get_js(js_values)[[2]], plausibility_results) + ### Stop the app ---- + app$stop() +}) ## ---- Plausibility Check on raw MUAC data ------------------------------------ +testthat::test_that(desc = "Plausibility check module works well for MUAC data", code = { + ### Skip test on CRAN ---- + testthat::skip_on_cran() + + ### Initialise mwana app ---- + app <- shinytest2::AppDriver$new( + app_dir = testthat::test_path("fixtures"), + load_timeout = 120000, + wait = TRUE + ) + + ### Let the app load ---- + app$wait_for_idle(timeout = 40000) + + ### Click on data upload tab ---- + app$click(selector = "a[data-value='Data Upload']") + app$wait_for_idle(timeout = 40000) + + #### Find the data to upload ---- + data <- read.csv( + file = testthat::test_path("fixtures", "anthro-01.csv"), + check.names = FALSE + ) + + tempfile <- tempfile(fileext = ".csv") + write.csv(data, tempfile, row.names = FALSE) + + #### Upload ---- + app$upload_file(`upload_data-upload` = tempfile, wait_ = TRUE) + + ### Click on the data wrangling tab ---- + app$click(selector = "a[data-value='Data Wrangling']") + app$wait_for_idle(timeout = 40000) + + ### Select data wrangling method ---- + app$set_inputs( + `wrangle_data-wrangle` = "muac", + wait_ = TRUE, + timeout_ = 15000 + ) + app$wait_for_idle(timeout = 40000) + + ### Select input variables ---- + app$set_inputs(`wrangle_data-sex` = "sex", wait_ = FALSE) + app$set_inputs(`wrangle_data-muac` = "muac", wait_ = FALSE) + + ### Click wrangle button ---- + app$click(input = "wrangle_data-apply_wrangle") + app$wait_for_idle(timeout = 40000) + + ### Click on the Plausibility Check tab ---- + app$click(selector = "a[data-value='Plausibility Check']") + app$wait_for_idle(timeout = 40000) + + ### Select method for plausibility check ---- + app$set_inputs(`plausible-method` = "muac", wait_ = TRUE, timeout_ = 15000) + app$wait_for_idle(timeout = 40000) + + ### Select input variables ---- + app$set_inputs(`plausible-area1` = "province", wait_ = FALSE) + app$set_inputs(`plausible-area2` = "strata", wait_ = FALSE) + app$set_inputs(`plausible-area3` = "sex", wait_ = FALSE) + app$set_inputs(`plausible-sex` = "sex", wait_ = FALSE) + app$set_inputs(`plausible-muac` = "muac", wait_ = FALSE) + app$set_inputs(`plausible-flags` = "flag_muac", wait_ = FALSE) + + ### Click on check plausibility button + app$click(input = "plausible-check") + app$wait_for_value(output = "plausible-checked", timeout = 40000) + + ### Capture JavaScript expressions to return results's cols and values ---- + js_cols <- "$('#plausible-checked thead th').map(function() { + return $(this).text();}).get();" + js_values <- "$('#plausible-checked tbody tr').map(function() + {return $(this).text();}).get();" -### Skip test on windows ---- -# if (identical(Sys.getenv("CI"), "true") && Sys.info()[["sysname"]] == "Windows") { -# skip("Skipping shinytest2 integration tests on Windows CI to reduce runtime") -# } - -testthat::test_that( - desc = "Plausibility check module works well for MUAC data", - code = { - - ### Initialise mwana app ---- - app <- shinytest2::AppDriver$new( - app_dir = testthat::test_path("fixtures"), - load_timeout = 120000, - wait = TRUE - ) - - ### Let the app load ---- - app$wait_for_idle(timeout = 40000) - - ### Click on data upload tab ---- - app$click(selector = "a[data-value='Data Upload']") - app$wait_for_idle(timeout = 40000) - - #### Find the data to upload ---- - data <- read.csv( - file = testthat::test_path("fixtures", "anthro-01.csv"), - check.names = FALSE + ### Capture Zambezia-urban plausibility check results ---- + plausibility_results <- + "ZambeziaUrban28130.1%Excellent<0.001Problematic5Excellent13.48Acceptable" + + ### Test check ----- + testthat::expect_equal( + as.character(app$get_js(js_cols)[1:12]), + expected = c( + "Province", + "Strata", + "Sex", + "Total children", + "Flagged data (%)", + "Class. of flagged data", + "Sex ratio (p)", + "Class. of sex ratio", + "DPS(#)", + "Class. of DPS", + "Standard Dev* (#)", + "Class. of standard dev" ) + ) - tempfile <- tempfile(fileext = ".csv") - write.csv(data, tempfile, row.names = FALSE) - - #### Upload ---- - app$upload_file(`upload_data-upload` = tempfile, wait_ = TRUE) - - ### Click on the data wrangling tab ---- - app$click(selector = "a[data-value='Data Wrangling']") - app$wait_for_idle(timeout = 40000) - - ### Select data wrangling method ---- - app$set_inputs(`wrangle_data-wrangle` = "muac", wait_ = TRUE, timeout_ = 15000) - app$wait_for_idle(timeout = 40000) - - ### Select input variables ---- - app$set_inputs(`wrangle_data-sex` = "sex", wait_ = FALSE) - app$set_inputs(`wrangle_data-muac` = "muac", wait_ = FALSE) - - ### Click wrangle button ---- - app$click(input = "wrangle_data-apply_wrangle") - app$wait_for_idle(timeout = 40000) - - ### Click on the Plausibility Check tab ---- - app$click(selector = "a[data-value='Plausibility Check']") - app$wait_for_idle(timeout = 40000) - - ### Select method for plausibility check ---- - app$set_inputs(`plausible-method` = "muac", wait_ = TRUE, timeout_ = 15000) - app$wait_for_idle(timeout = 40000) - - ### Select input variables ---- - app$set_inputs(`plausible-area1` = "province", wait_ = FALSE) - app$set_inputs(`plausible-area2` = "strata", wait_ = FALSE) - app$set_inputs(`plausible-area3` = "sex", wait_ = FALSE) - app$set_inputs(`plausible-sex` = "sex", wait_ = FALSE) - app$set_inputs(`plausible-muac` = "muac", wait_ = FALSE) - app$set_inputs(`plausible-flags` = "flag_muac", wait_ = FALSE) - - ### Click on check plausibility button - app$click(input = "plausible-check") - app$wait_for_value(output = "plausible-checked", timeout = 40000) - - ### Capture JavaScript expressions to return results's cols and values ---- - js_cols <- "$('#plausible-checked thead th').map(function() { - return $(this).text();}).get();" - js_values <- "$('#plausible-checked tbody tr').map(function() - {return $(this).text();}).get();" + testthat::expect_equal(app$get_js(js_values)[[4]], plausibility_results) - ### Capture Zambezia-urban plausibility check results ---- - plausibility_results <- - "ZambeziaUrban28130.1%Excellent<0.001Problematic5Excellent13.48Acceptable" - - ### Test check ----- - testthat::expect_equal(as.character(app$get_js(js_cols)[1:12]), - expected = c( - "Province", "Strata", "Sex", "Total children", "Flagged data (%)", - "Class. of flagged data", "Sex ratio (p)", "Class. of sex ratio", "DPS(#)", - "Class. of DPS", "Standard Dev* (#)", "Class. of standard dev")) - - testthat::expect_equal(app$get_js(js_values)[[4]], plausibility_results) - - ### Stop the app ---- - app$stop() - } -) + ### Stop the app ---- + app$stop() +}) diff --git a/tests/testthat/test-module-prevalence.R b/tests/testthat/test-module-prevalence.R index a618553..b15e165 100644 --- a/tests/testthat/test-module-prevalence.R +++ b/tests/testthat/test-module-prevalence.R @@ -2,789 +2,801 @@ # Test Suite: Module Prevalence # ============================================================================== - ## ---- Survey data ------------------------------------------------------------ - ### WFHZ weighted prevalence ---- -testthat::test_that( - desc = "Module works well to estimate weighted-WFHZ prevalence from survey", - code = { - ### Initialise mwana app ---- - app <- shinytest2::AppDriver$new( - app_dir = testthat::test_path("fixtures"), - timeout = 120000, - wait = TRUE - ) - - ### Wait the app to idle ---- - app$wait_for_idle(timeout = 40000) - - ### Click in the Data Upload tab ---- - app$click(selector = "a[data-value='Data Upload']") - app$wait_for_idle(timeout = 40000) - - #### Read data ---- - data <- read.csv( - file = testthat::test_path("fixtures", "anthro-01.csv"), - check.names = FALSE - ) - data["sex"] <- ifelse(data$sex == 1, "m", "f") - tempfile <- tempfile(fileext = ".csv") - write.csv(data, tempfile, row.names = FALSE) - - #### Upload onto the app ---- - app$upload_file(`upload_data-upload` = tempfile, wait_ = TRUE) - - ### Click on the data wrangling tab ---- - app$click(selector = "a[data-value='Data Wrangling']") - app$wait_for_idle(timeout = 40000) - - ## App defaults to WFHZ ---- - ### Input variables ---- - app$set_inputs(`wrangle_data-dos` = "", wait_ = FALSE) - app$set_inputs(`wrangle_data-dob` = "", wait_ = FALSE) - app$set_inputs(`wrangle_data-sex` = "sex", wait_ = FALSE) - app$set_inputs(`wrangle_data-weight` = "weight", wait_ = FALSE) - app$set_inputs(`wrangle_data-height` = "height", wait_ = FALSE) - - ### Click wrangle button and wait the app to idle ---- - app$click(input = "wrangle_data-apply_wrangle") - Sys.sleep(3) - - ### Click on the Prevalence tab and wait the app to idle ---- - app$click(selector = "a[data-value='Prevalence Analysis']") - app$wait_for_idle(timeout = 40000) - - ### Select source of data ---- - app$set_inputs(`prevalence-source` = "survey", wait_ = FALSE) - - ### Select the method ---- - app$set_inputs(`prevalence-amn_method_survey` = "wfhz", wait_ = FALSE) - app$set_inputs(`prevalence-area1` = "province", wait_ = FALSE) - app$set_inputs(`prevalence-area2` = "strata", wait_ = FALSE) ## Assume sex as grouping var - app$set_inputs(`prevalence-area3` = "sex", wait_ = FALSE) - app$set_inputs(`prevalence-wts` = "wtfactor", wait_ = FALSE) - app$set_inputs(`prevalence-oedema` = "oedema", wait_ = FALSE) - - ### Click on Estime Prevalence button ---- - app$click(input = "prevalence-estimate") - app$wait_for_value(output = "prevalence-results", timeout = 40000) - - ### Capture JavaScript expressions to return results's cols and values ---- - js_cols <- "$('#prevalence-results thead th').map(function() +testthat::test_that(desc = "Module works well to estimate weighted-WFHZ prevalence from survey", code = { + ### Skip test on CRAN ---- + testthat::skip_on_cran() + + ### Initialise mwana app ---- + app <- shinytest2::AppDriver$new( + app_dir = testthat::test_path("fixtures"), + timeout = 120000, + wait = TRUE + ) + + ### Wait the app to idle ---- + app$wait_for_idle(timeout = 40000) + + ### Click in the Data Upload tab ---- + app$click(selector = "a[data-value='Data Upload']") + app$wait_for_idle(timeout = 40000) + + #### Read data ---- + data <- read.csv( + file = testthat::test_path("fixtures", "anthro-01.csv"), + check.names = FALSE + ) + data["sex"] <- ifelse(data$sex == 1, "m", "f") + tempfile <- tempfile(fileext = ".csv") + write.csv(data, tempfile, row.names = FALSE) + + #### Upload onto the app ---- + app$upload_file(`upload_data-upload` = tempfile, wait_ = TRUE) + + ### Click on the data wrangling tab ---- + app$click(selector = "a[data-value='Data Wrangling']") + app$wait_for_idle(timeout = 40000) + + ## App defaults to WFHZ ---- + ### Input variables ---- + app$set_inputs(`wrangle_data-dos` = "", wait_ = FALSE) + app$set_inputs(`wrangle_data-dob` = "", wait_ = FALSE) + app$set_inputs(`wrangle_data-sex` = "sex", wait_ = FALSE) + app$set_inputs(`wrangle_data-weight` = "weight", wait_ = FALSE) + app$set_inputs(`wrangle_data-height` = "height", wait_ = FALSE) + + ### Click wrangle button and wait the app to idle ---- + app$click(input = "wrangle_data-apply_wrangle") + Sys.sleep(3) + + ### Click on the Prevalence tab and wait the app to idle ---- + app$click(selector = "a[data-value='Prevalence Analysis']") + app$wait_for_idle(timeout = 40000) + + ### Select source of data ---- + app$set_inputs(`prevalence-source` = "survey", wait_ = FALSE) + + ### Select the method ---- + app$set_inputs(`prevalence-amn_method_survey` = "wfhz", wait_ = FALSE) + app$set_inputs(`prevalence-area1` = "province", wait_ = FALSE) + app$set_inputs(`prevalence-area2` = "strata", wait_ = FALSE) ## Assume sex as grouping var + app$set_inputs(`prevalence-area3` = "sex", wait_ = FALSE) + app$set_inputs(`prevalence-wts` = "wtfactor", wait_ = FALSE) + app$set_inputs(`prevalence-oedema` = "oedema", wait_ = FALSE) + + ### Click on Estime Prevalence button ---- + app$click(input = "prevalence-estimate") + app$wait_for_value(output = "prevalence-results", timeout = 40000) + + ### Capture JavaScript expressions to return results's cols and values ---- + js_cols <- "$('#prevalence-results thead th').map(function() {return $(this).text();}).get();" - js_values <- "$('#prevalence-results tbody tr').map(function() + js_values <- "$('#prevalence-results tbody tr').map(function() {return $(this).text();}).get();" - ### Capture prevalence results of Nampula Province, Rural Strata ---- - glued_results <- app$get_js(js_values)[[3]] - weighted_pop <- sub("1", "", stringr::str_extract(glued_results, "\\d{7}(?:)")) - gam_prev <- stringr::str_extract(glued_results, "\\d\\.\\d") + ### Capture prevalence results of Nampula Province, Rural Strata ---- + glued_results <- app$get_js(js_values)[[3]] + weighted_pop <- sub( + "1", + "", + stringr::str_extract(glued_results, "\\d{7}(?:)") + ) + gam_prev <- stringr::str_extract(glued_results, "\\d\\.\\d") - ### Test check ---- - testthat::expect_equal(length(app$get_js(js_cols)[1:19]), 19) - testthat::expect_equal(as.numeric(weighted_pop), 292611) - testthat::expect_equal(as.numeric(gam_prev), 6.1) + ### Test check ---- + testthat::expect_equal(length(app$get_js(js_cols)[1:19]), 19) + testthat::expect_equal(as.numeric(weighted_pop), 292611) + testthat::expect_equal(as.numeric(gam_prev), 6.1) - ### Stop the app ---- - app$stop() - } -) + ### Stop the app ---- + app$stop() +}) ### WFHZ unweighted prevalence ---- -testthat::test_that( - desc = "Module works well to estimate unweighted-WFHZ prevalence from survey", - code = { - ### Initialise mwana app ---- - app <- shinytest2::AppDriver$new( - app_dir = testthat::test_path("fixtures"), - timeout = 120000, - wait = TRUE - ) - - ### Wait the app to idle ---- - app$wait_for_idle(timeout = 40000) - - ### Click in the Data Upload tab ---- - app$click(selector = "a[data-value='Data Upload']") - app$wait_for_idle(timeout = 40000) - - #### Read data ---- - data <- read.csv( - file = testthat::test_path("fixtures", "anthro-01.csv"), - check.names = FALSE - ) - data["sex"] <- ifelse(data$sex == 1, "m", "f") - tempfile <- tempfile(fileext = ".csv") - write.csv(data, tempfile, row.names = FALSE) - - #### Upload onto the app ---- - app$upload_file(`upload_data-upload` = tempfile, wait_ = TRUE) - - ### Click on the data wrangling tab ---- - app$click(selector = "a[data-value='Data Wrangling']") - app$wait_for_idle(timeout = 40000) - - ## App defaults to WFHZ ---- - ### Input variables ---- - app$set_inputs(`wrangle_data-dos` = "", wait_ = FALSE) - app$set_inputs(`wrangle_data-dob` = "", wait_ = FALSE) - app$set_inputs(`wrangle_data-sex` = "sex", wait_ = FALSE) - app$set_inputs(`wrangle_data-weight` = "weight", wait_ = FALSE) - app$set_inputs(`wrangle_data-height` = "height", wait_ = FALSE) - - ### Click wrangle button and wait the app to idle ---- - app$click(input = "wrangle_data-apply_wrangle") - Sys.sleep(3) - - ### Click on the Prevalence tab and wait the app to idle ---- - app$click(selector = "a[data-value='Prevalence Analysis']") - app$wait_for_idle(timeout = 40000) - - ### Select source of data ---- - app$set_inputs(`prevalence-source` = "survey", wait_ = FALSE) - - ### Select the method ---- - app$set_inputs(`prevalence-amn_method_survey` = "wfhz", wait_ = FALSE) - app$set_inputs(`prevalence-area1` = "province", wait_ = FALSE) - app$set_inputs(`prevalence-area2` = "strata", wait_ = FALSE) ## Assume sex as grouping var - app$set_inputs(`prevalence-area3` = "sex", wait_ = FALSE) - app$set_inputs(`prevalence-wts` = "", wait_ = FALSE) - app$set_inputs(`prevalence-oedema` = "oedema", wait_ = FALSE) - - ### Click on Estime Prevalence button ---- - app$click(input = "prevalence-estimate") - app$wait_for_value(output = "prevalence-results", timeout = 40000) - - ### Capture JavaScript expressions to return results's cols and values ---- - js_cols <- "$('#prevalence-results thead th').map(function() +testthat::test_that(desc = "Module works well to estimate unweighted-WFHZ prevalence from survey", code = { + ### Skip test on CRAN ---- + testthat::skip_on_cran() + + ### Initialise mwana app ---- + app <- shinytest2::AppDriver$new( + app_dir = testthat::test_path("fixtures"), + timeout = 120000, + wait = TRUE + ) + + ### Wait the app to idle ---- + app$wait_for_idle(timeout = 40000) + + ### Click in the Data Upload tab ---- + app$click(selector = "a[data-value='Data Upload']") + app$wait_for_idle(timeout = 40000) + + #### Read data ---- + data <- read.csv( + file = testthat::test_path("fixtures", "anthro-01.csv"), + check.names = FALSE + ) + data["sex"] <- ifelse(data$sex == 1, "m", "f") + tempfile <- tempfile(fileext = ".csv") + write.csv(data, tempfile, row.names = FALSE) + + #### Upload onto the app ---- + app$upload_file(`upload_data-upload` = tempfile, wait_ = TRUE) + + ### Click on the data wrangling tab ---- + app$click(selector = "a[data-value='Data Wrangling']") + app$wait_for_idle(timeout = 40000) + + ## App defaults to WFHZ ---- + ### Input variables ---- + app$set_inputs(`wrangle_data-dos` = "", wait_ = FALSE) + app$set_inputs(`wrangle_data-dob` = "", wait_ = FALSE) + app$set_inputs(`wrangle_data-sex` = "sex", wait_ = FALSE) + app$set_inputs(`wrangle_data-weight` = "weight", wait_ = FALSE) + app$set_inputs(`wrangle_data-height` = "height", wait_ = FALSE) + + ### Click wrangle button and wait the app to idle ---- + app$click(input = "wrangle_data-apply_wrangle") + Sys.sleep(3) + + ### Click on the Prevalence tab and wait the app to idle ---- + app$click(selector = "a[data-value='Prevalence Analysis']") + app$wait_for_idle(timeout = 40000) + + ### Select source of data ---- + app$set_inputs(`prevalence-source` = "survey", wait_ = FALSE) + + ### Select the method ---- + app$set_inputs(`prevalence-amn_method_survey` = "wfhz", wait_ = FALSE) + app$set_inputs(`prevalence-area1` = "province", wait_ = FALSE) + app$set_inputs(`prevalence-area2` = "strata", wait_ = FALSE) ## Assume sex as grouping var + app$set_inputs(`prevalence-area3` = "sex", wait_ = FALSE) + app$set_inputs(`prevalence-wts` = "", wait_ = FALSE) + app$set_inputs(`prevalence-oedema` = "oedema", wait_ = FALSE) + + ### Click on Estime Prevalence button ---- + app$click(input = "prevalence-estimate") + app$wait_for_value(output = "prevalence-results", timeout = 40000) + + ### Capture JavaScript expressions to return results's cols and values ---- + js_cols <- "$('#prevalence-results thead th').map(function() {return $(this).text();}).get();" - js_values <- "$('#prevalence-results tbody tr').map(function() + js_values <- "$('#prevalence-results tbody tr').map(function() {return $(this).text();}).get();" - ### Capture prevalence results of Nampula Province, Rural Strata ---- - glued_results <- app$get_js(js_values)[[3]] - pop <- sub("1", "", stringr::str_extract(glued_results, "\\d{4}")) - gam_prev <- stringr::str_extract(glued_results, "\\d{1}\\.\\d") + ### Capture prevalence results of Nampula Province, Rural Strata ---- + glued_results <- app$get_js(js_values)[[3]] + pop <- sub("1", "", stringr::str_extract(glued_results, "\\d{4}")) + gam_prev <- stringr::str_extract(glued_results, "\\d{1}\\.\\d") - ### Test check ---- - testthat::expect_equal(length(app$get_js(js_cols)[1:19]), 19) - testthat::expect_equal(as.numeric(pop), 280) - testthat::expect_equal(as.numeric(gam_prev), 6.1) + ### Test check ---- + testthat::expect_equal(length(app$get_js(js_cols)[1:19]), 19) + testthat::expect_equal(as.numeric(pop), 280) + testthat::expect_equal(as.numeric(gam_prev), 6.1) - ### Stop the app ---- - app$stop() - } -) + ### Stop the app ---- + app$stop() +}) ### MUAC weighted prevalence ---- -testthat::test_that( - desc = "Module works well to estimate weighted-MUAC prevalence from survey", - code = { - ### Initialise mwana app ---- - app <- shinytest2::AppDriver$new( - app_dir = testthat::test_path("fixtures"), - timeout = 120000, - wait = TRUE - ) - - ### Wait the app to idle ---- - app$wait_for_idle(timeout = 40000) - - ### Click in the Data Upload tab ---- - app$click(selector = "a[data-value='Data Upload']") - app$wait_for_idle(timeout = 40000) - - #### Read data ---- - data <- read.csv( - file = testthat::test_path("fixtures", "anthro-01.csv"), - check.names = FALSE - ) - data["sex"] <- ifelse(data$sex == 1, "m", "f") - tempfile <- tempfile(fileext = ".csv") - write.csv(data, tempfile, row.names = FALSE) - - #### Upload onto the app ---- - app$upload_file(`upload_data-upload` = tempfile, wait_ = TRUE) - - ### Click on the data wrangling tab ---- - app$click(selector = "a[data-value='Data Wrangling']") - app$wait_for_idle(timeout = 40000) - - ### Select data wrangling method and wait the app till idles ---- - app$set_inputs(`wrangle_data-wrangle` = "mfaz", wait_ = TRUE) - app$wait_for_idle(timeout = 40000) - - ### Input variables ---- - app$set_inputs(`wrangle_data-dos` = "", wait_ = FALSE) - app$set_inputs(`wrangle_data-dob` = "", wait_ = FALSE) - app$set_inputs(`wrangle_data-age` = "age", wait_ = FALSE) - app$set_inputs(`wrangle_data-sex` = "sex", wait_ = FALSE) - app$set_inputs(`wrangle_data-muac` = "muac", wait_ = FALSE) - - ### Click wrangle button and wait the app to idle ---- - app$click(input = "wrangle_data-apply_wrangle") - app$wait_for_idle(timeout = 40000) - - ### Click on the Prevalence tab and wait the app to idle ---- - app$click(selector = "a[data-value='Prevalence Analysis']") - app$wait_for_idle(timeout = 40000) - - ### Select source of data ---- - app$set_inputs(`prevalence-source` = "survey", wait_ = FALSE) - - ### Select the method ---- - app$set_inputs(`prevalence-amn_method_survey` = "muac", wait_ = TRUE) - app$set_inputs(`prevalence-area1` = "province", wait_ = FALSE) - app$set_inputs(`prevalence-area2` = "strata", wait_ = FALSE) ## Assume sex as grouping var - app$set_inputs(`prevalence-area3` = "sex", wait_ = FALSE) - app$set_inputs(`prevalence-muac` = "muac", wait_ = FALSE) - app$set_inputs(`prevalence-age` = "age", wait_ = FALSE) - app$set_inputs(`prevalence-wts` = "wtfactor", wait_ = FALSE) - app$set_inputs(`prevalence-oedema` = "oedema", wait_ = FALSE) - - ### Click on Estime Prevalence button ---- - app$click(input = "prevalence-estimate") - app$wait_for_value(output = "prevalence-results", timeout = 40000) - - ### Capture JavaScript expressions to return results's cols and values ---- - js_cols <- "$('#prevalence-results thead th').map(function() +testthat::test_that(desc = "Module works well to estimate weighted-MUAC prevalence from survey", code = { + ### Skip test on CRAN ---- + testthat::skip_on_cran() + + ### Initialise mwana app ---- + app <- shinytest2::AppDriver$new( + app_dir = testthat::test_path("fixtures"), + timeout = 120000, + wait = TRUE + ) + + ### Wait the app to idle ---- + app$wait_for_idle(timeout = 40000) + + ### Click in the Data Upload tab ---- + app$click(selector = "a[data-value='Data Upload']") + app$wait_for_idle(timeout = 40000) + + #### Read data ---- + data <- read.csv( + file = testthat::test_path("fixtures", "anthro-01.csv"), + check.names = FALSE + ) + data["sex"] <- ifelse(data$sex == 1, "m", "f") + tempfile <- tempfile(fileext = ".csv") + write.csv(data, tempfile, row.names = FALSE) + + #### Upload onto the app ---- + app$upload_file(`upload_data-upload` = tempfile, wait_ = TRUE) + + ### Click on the data wrangling tab ---- + app$click(selector = "a[data-value='Data Wrangling']") + app$wait_for_idle(timeout = 40000) + + ### Select data wrangling method and wait the app till idles ---- + app$set_inputs(`wrangle_data-wrangle` = "mfaz", wait_ = TRUE) + app$wait_for_idle(timeout = 40000) + + ### Input variables ---- + app$set_inputs(`wrangle_data-dos` = "", wait_ = FALSE) + app$set_inputs(`wrangle_data-dob` = "", wait_ = FALSE) + app$set_inputs(`wrangle_data-age` = "age", wait_ = FALSE) + app$set_inputs(`wrangle_data-sex` = "sex", wait_ = FALSE) + app$set_inputs(`wrangle_data-muac` = "muac", wait_ = FALSE) + + ### Click wrangle button and wait the app to idle ---- + app$click(input = "wrangle_data-apply_wrangle") + app$wait_for_idle(timeout = 40000) + + ### Click on the Prevalence tab and wait the app to idle ---- + app$click(selector = "a[data-value='Prevalence Analysis']") + app$wait_for_idle(timeout = 40000) + + ### Select source of data ---- + app$set_inputs(`prevalence-source` = "survey", wait_ = FALSE) + + ### Select the method ---- + app$set_inputs(`prevalence-amn_method_survey` = "muac", wait_ = TRUE) + app$set_inputs(`prevalence-area1` = "province", wait_ = FALSE) + app$set_inputs(`prevalence-area2` = "strata", wait_ = FALSE) ## Assume sex as grouping var + app$set_inputs(`prevalence-area3` = "sex", wait_ = FALSE) + app$set_inputs(`prevalence-muac` = "muac", wait_ = FALSE) + app$set_inputs(`prevalence-age` = "age", wait_ = FALSE) + app$set_inputs(`prevalence-wts` = "wtfactor", wait_ = FALSE) + app$set_inputs(`prevalence-oedema` = "oedema", wait_ = FALSE) + + ### Click on Estime Prevalence button ---- + app$click(input = "prevalence-estimate") + app$wait_for_value(output = "prevalence-results", timeout = 40000) + + ### Capture JavaScript expressions to return results's cols and values ---- + js_cols <- "$('#prevalence-results thead th').map(function() {return $(this).text();}).get();" - js_values <- "$('#prevalence-results tbody tr').map(function() + js_values <- "$('#prevalence-results tbody tr').map(function() {return $(this).text();}).get();" - ### Get a JS expression ---- - js_result <- app$get_js(js_values) + ### Get a JS expression ---- + js_result <- app$get_js(js_values) - ### Wait/validate that we have at least 3 values - if (length(js_result) < 4) { - #### Add a small delay and retry - Sys.sleep(3) - js_result <- app$get_js(js_values) - } - ### Capture prevalence results of Zambezia Province, Rural Strata ---- - prev <- stringr::str_extract_all(js_result[[3]], "\\d\\.\\d")[[1]] - weighted_pop <- sub("1", "", stringr::str_extract(js_result[[3]], "\\d{7}(?:)")) - - ### Test check ---- - testthat::expect_equal(length(app$get_js(js_cols)[1:19]), 19) - testthat::expect_equal(as.numeric(prev[2]), 7.7) # GAM - testthat::expect_equal(as.numeric(weighted_pop), 307395) - - ### Stop the app ---- - app$stop() + ### Wait/validate that we have at least 3 values + if (length(js_result) < 4) { + #### Add a small delay and retry + Sys.sleep(3) + js_result <- app$get_js(js_values) } -) + ### Capture prevalence results of Zambezia Province, Rural Strata ---- + prev <- stringr::str_extract_all(js_result[[3]], "\\d\\.\\d")[[1]] + weighted_pop <- sub( + "1", + "", + stringr::str_extract(js_result[[3]], "\\d{7}(?:)") + ) + ### Test check ---- + testthat::expect_equal(length(app$get_js(js_cols)[1:19]), 19) + testthat::expect_equal(as.numeric(prev[2]), 7.7) # GAM + testthat::expect_equal(as.numeric(weighted_pop), 307395) -### MUAC unweighted prevalence ---- -testthat::test_that( - desc = "Module works well to estimate unweighted-MUAC prevalence from survey", - code = { - ### Initialise mwana app ---- - app <- shinytest2::AppDriver$new( - app_dir = testthat::test_path("fixtures"), - timeout = 120000, - wait = TRUE - ) + ### Stop the app ---- + app$stop() +}) - ### Wait the app to idle ---- - app$wait_for_idle(timeout = 40000) - ### Click in the Data Upload tab ---- - app$click(selector = "a[data-value='Data Upload']") - app$wait_for_idle(timeout = 40000) - - #### Read data ---- - data <- read.csv( - file = testthat::test_path("fixtures", "anthro-01.csv"), - check.names = FALSE - ) - data["sex"] <- ifelse(data$sex == 1, "m", "f") - tempfile <- tempfile(fileext = ".csv") - write.csv(data, tempfile, row.names = FALSE) - - #### Upload onto the app ---- - app$upload_file(`upload_data-upload` = tempfile, wait_ = TRUE) - - ### Click on the data wrangling tab ---- - app$click(selector = "a[data-value='Data Wrangling']") - app$wait_for_idle(timeout = 40000) - - ### Select data wrangling method and wait the app till idles ---- - app$set_inputs(`wrangle_data-wrangle` = "mfaz", wait_ = TRUE) - app$wait_for_idle(timeout = 40000) - - ### Input variables ---- - app$set_inputs(`wrangle_data-dos` = "", wait_ = FALSE) - app$set_inputs(`wrangle_data-dob` = "", wait_ = FALSE) - app$set_inputs(`wrangle_data-age` = "age", wait_ = FALSE) - app$set_inputs(`wrangle_data-sex` = "sex", wait_ = FALSE) - app$set_inputs(`wrangle_data-muac` = "muac", wait_ = FALSE) - - ### Click wrangle button and wait the app to idle ---- - app$click(input = "wrangle_data-apply_wrangle") - app$wait_for_idle(timeout = 40000) - - ### Click on the Prevalence tab and wait the app to idle ---- - app$click(selector = "a[data-value='Prevalence Analysis']") - app$wait_for_idle(timeout = 40000) - - ### Select source of data ---- - app$set_inputs(`prevalence-source` = "survey", wait_ = FALSE) - - ### Select the method ---- - app$set_inputs(`prevalence-amn_method_survey` = "muac", wait_ = TRUE) - app$set_inputs(`prevalence-area1` = "province", wait_ = FALSE) - app$set_inputs(`prevalence-area2` = "strata", wait_ = FALSE) ## Assume sex as grouping var - app$set_inputs(`prevalence-area3` = "sex", wait_ = FALSE) - app$set_inputs(`prevalence-muac` = "muac", wait_ = FALSE) - app$set_inputs(`prevalence-age` = "age", wait_ = FALSE) - app$set_inputs(`prevalence-wts` = "", wait_ = FALSE) - app$set_inputs(`prevalence-oedema` = "oedema", wait_ = FALSE) - - ### Click on Estime Prevalence button ---- - app$click(input = "prevalence-estimate") - app$wait_for_value(output = "prevalence-results", timeout = 40000) - - ### Capture JavaScript expressions to return results's cols and values ---- - js_cols <- "$('#prevalence-results thead th').map(function() +### MUAC unweighted prevalence ---- +testthat::test_that(desc = "Module works well to estimate unweighted-MUAC prevalence from survey", code = { + ### Skip test on CRAN ---- + testthat::skip_on_cran() + + ### Initialise mwana app ---- + app <- shinytest2::AppDriver$new( + app_dir = testthat::test_path("fixtures"), + timeout = 120000, + wait = TRUE + ) + + ### Wait the app to idle ---- + app$wait_for_idle(timeout = 40000) + + ### Click in the Data Upload tab ---- + app$click(selector = "a[data-value='Data Upload']") + app$wait_for_idle(timeout = 40000) + + #### Read data ---- + data <- read.csv( + file = testthat::test_path("fixtures", "anthro-01.csv"), + check.names = FALSE + ) + data["sex"] <- ifelse(data$sex == 1, "m", "f") + tempfile <- tempfile(fileext = ".csv") + write.csv(data, tempfile, row.names = FALSE) + + #### Upload onto the app ---- + app$upload_file(`upload_data-upload` = tempfile, wait_ = TRUE) + + ### Click on the data wrangling tab ---- + app$click(selector = "a[data-value='Data Wrangling']") + app$wait_for_idle(timeout = 40000) + + ### Select data wrangling method and wait the app till idles ---- + app$set_inputs(`wrangle_data-wrangle` = "mfaz", wait_ = TRUE) + app$wait_for_idle(timeout = 40000) + + ### Input variables ---- + app$set_inputs(`wrangle_data-dos` = "", wait_ = FALSE) + app$set_inputs(`wrangle_data-dob` = "", wait_ = FALSE) + app$set_inputs(`wrangle_data-age` = "age", wait_ = FALSE) + app$set_inputs(`wrangle_data-sex` = "sex", wait_ = FALSE) + app$set_inputs(`wrangle_data-muac` = "muac", wait_ = FALSE) + + ### Click wrangle button and wait the app to idle ---- + app$click(input = "wrangle_data-apply_wrangle") + app$wait_for_idle(timeout = 40000) + + ### Click on the Prevalence tab and wait the app to idle ---- + app$click(selector = "a[data-value='Prevalence Analysis']") + app$wait_for_idle(timeout = 40000) + + ### Select source of data ---- + app$set_inputs(`prevalence-source` = "survey", wait_ = FALSE) + + ### Select the method ---- + app$set_inputs(`prevalence-amn_method_survey` = "muac", wait_ = TRUE) + app$set_inputs(`prevalence-area1` = "province", wait_ = FALSE) + app$set_inputs(`prevalence-area2` = "strata", wait_ = FALSE) ## Assume sex as grouping var + app$set_inputs(`prevalence-area3` = "sex", wait_ = FALSE) + app$set_inputs(`prevalence-muac` = "muac", wait_ = FALSE) + app$set_inputs(`prevalence-age` = "age", wait_ = FALSE) + app$set_inputs(`prevalence-wts` = "", wait_ = FALSE) + app$set_inputs(`prevalence-oedema` = "oedema", wait_ = FALSE) + + ### Click on Estime Prevalence button ---- + app$click(input = "prevalence-estimate") + app$wait_for_value(output = "prevalence-results", timeout = 40000) + + ### Capture JavaScript expressions to return results's cols and values ---- + js_cols <- "$('#prevalence-results thead th').map(function() {return $(this).text();}).get();" - js_values <- "$('#prevalence-results tbody tr').map(function() + js_values <- "$('#prevalence-results tbody tr').map(function() {return $(this).text();}).get();" - ### Get a JS expression ---- - js_result <- app$get_js(js_values) + ### Get a JS expression ---- + js_result <- app$get_js(js_values) - ### Wait/validate that we have at least 3 values - if (length(js_result) < 4) { - #### Add a small delay and retry - Sys.sleep(3) - js_result <- app$get_js(js_values) - } - ### Capture prevalence results of Zambezia Province, Rural Strata ---- - pop <- sub("1", "", stringr::str_extract(js_result[[3]], "\\d{4}")) - prev <- stringr::str_extract(js_result[[3]], "\\d{1}\\.\\d") - - ### Test check ---- - testthat::expect_equal(length(app$get_js(js_cols)[1:19]), 19) - testthat::expect_equal(as.numeric(prev), 8.0) # GAM - testthat::expect_equal(as.numeric(pop), 300) - - ### Stop the app ---- - app$stop() + ### Wait/validate that we have at least 3 values + if (length(js_result) < 4) { + #### Add a small delay and retry + Sys.sleep(3) + js_result <- app$get_js(js_values) } -) - + ### Capture prevalence results of Zambezia Province, Rural Strata ---- + pop <- sub("1", "", stringr::str_extract(js_result[[3]], "\\d{4}")) + prev <- stringr::str_extract(js_result[[3]], "\\d{1}\\.\\d") + ### Test check ---- + testthat::expect_equal(length(app$get_js(js_cols)[1:19]), 19) + testthat::expect_equal(as.numeric(prev), 8.0) # GAM + testthat::expect_equal(as.numeric(pop), 300) -### Combined weighted prevalence ---- -testthat::test_that( - desc = "Module works well to estimate weighted-combined prevalence from survey", - code = { - ### Initialise mwana app ---- - app <- shinytest2::AppDriver$new( - app_dir = testthat::test_path("fixtures"), - timeout = 120000, - wait = TRUE - ) - - ### Wait the app to idle ---- - app$wait_for_idle(timeout = 40000) + ### Stop the app ---- + app$stop() +}) - ### Click in the Data Upload tab ---- - app$click(selector = "a[data-value='Data Upload']") - app$wait_for_idle(timeout = 40000) - #### Read data ---- - data <- read.csv( - file = testthat::test_path("fixtures", "anthro-01.csv"), - check.names = FALSE - ) - data["sex"] <- ifelse(data$sex == 1, "m", "f") - tempfile <- tempfile(fileext = ".csv") - write.csv(data, tempfile, row.names = FALSE) - - #### Upload onto the app ---- - app$upload_file(`upload_data-upload` = tempfile, wait_ = TRUE) - - ### Click on the data wrangling tab ---- - app$click(selector = "a[data-value='Data Wrangling']") - app$wait_for_idle(timeout = 40000) - - ### Select data wrangling method and wait the app till idles ---- - app$set_inputs(`wrangle_data-wrangle` = "combined", wait_ = TRUE) - app$wait_for_idle(timeout = 40000) - - ### Input variables ---- - app$set_inputs(`wrangle_data-dos` = "", wait_ = FALSE) - app$set_inputs(`wrangle_data-dob` = "", wait_ = FALSE) - app$set_inputs(`wrangle_data-age` = "age", wait_ = FALSE) - app$set_inputs(`wrangle_data-sex` = "sex", wait_ = FALSE) - app$set_inputs(`wrangle_data-weight` = "weight", wait_ = FALSE) - app$set_inputs(`wrangle_data-height` = "height", wait_ = FALSE) - app$set_inputs(`wrangle_data-muac` = "muac", wait_ = FALSE) - - ### Click wrangle button and wait the app to idle ---- - app$click(input = "wrangle_data-apply_wrangle") - app$wait_for_idle(timeout = 40000) - - ### Click on the Prevalence tab and wait the app to idle ---- - app$click(selector = "a[data-value='Prevalence Analysis']") - app$wait_for_idle(timeout = 40000) - - ### Select source of data ---- - app$set_inputs(`prevalence-source` = "survey", wait_ = FALSE) - - ### Select the method ---- - app$set_inputs(`prevalence-amn_method_survey` = "combined", wait_ = TRUE) - app$set_inputs(`prevalence-area1` = "province", wait_ = FALSE) - app$set_inputs(`prevalence-area2` = "strata", wait_ = FALSE) ## Assume sex as grouping var - app$set_inputs(`prevalence-area3` = "sex", wait_ = FALSE) - app$set_inputs(`prevalence-wts` = "wtfactor", wait_ = FALSE) - app$set_inputs(`prevalence-oedema` = "oedema", wait_ = FALSE) - - ### Click on Estime Prevalence button ---- - app$click(input = "prevalence-estimate") - app$wait_for_value(output = "prevalence-results", timeout = 40000) - - ### Capture JavaScript expressions to return results's cols and values ---- - js_cols <- "$('#prevalence-results thead th').map(function() +### Combined weighted prevalence ---- +testthat::test_that(desc = "Module works well to estimate weighted-combined prevalence from survey", code = { + ### Skip test on CRAN ---- + testthat::skip_on_cran() + + ### Initialise mwana app ---- + app <- shinytest2::AppDriver$new( + app_dir = testthat::test_path("fixtures"), + timeout = 120000, + wait = TRUE + ) + + ### Wait the app to idle ---- + app$wait_for_idle(timeout = 40000) + + ### Click in the Data Upload tab ---- + app$click(selector = "a[data-value='Data Upload']") + app$wait_for_idle(timeout = 40000) + + #### Read data ---- + data <- read.csv( + file = testthat::test_path("fixtures", "anthro-01.csv"), + check.names = FALSE + ) + data["sex"] <- ifelse(data$sex == 1, "m", "f") + tempfile <- tempfile(fileext = ".csv") + write.csv(data, tempfile, row.names = FALSE) + + #### Upload onto the app ---- + app$upload_file(`upload_data-upload` = tempfile, wait_ = TRUE) + + ### Click on the data wrangling tab ---- + app$click(selector = "a[data-value='Data Wrangling']") + app$wait_for_idle(timeout = 40000) + + ### Select data wrangling method and wait the app till idles ---- + app$set_inputs(`wrangle_data-wrangle` = "combined", wait_ = TRUE) + app$wait_for_idle(timeout = 40000) + + ### Input variables ---- + app$set_inputs(`wrangle_data-dos` = "", wait_ = FALSE) + app$set_inputs(`wrangle_data-dob` = "", wait_ = FALSE) + app$set_inputs(`wrangle_data-age` = "age", wait_ = FALSE) + app$set_inputs(`wrangle_data-sex` = "sex", wait_ = FALSE) + app$set_inputs(`wrangle_data-weight` = "weight", wait_ = FALSE) + app$set_inputs(`wrangle_data-height` = "height", wait_ = FALSE) + app$set_inputs(`wrangle_data-muac` = "muac", wait_ = FALSE) + + ### Click wrangle button and wait the app to idle ---- + app$click(input = "wrangle_data-apply_wrangle") + app$wait_for_idle(timeout = 40000) + + ### Click on the Prevalence tab and wait the app to idle ---- + app$click(selector = "a[data-value='Prevalence Analysis']") + app$wait_for_idle(timeout = 40000) + + ### Select source of data ---- + app$set_inputs(`prevalence-source` = "survey", wait_ = FALSE) + + ### Select the method ---- + app$set_inputs(`prevalence-amn_method_survey` = "combined", wait_ = TRUE) + app$set_inputs(`prevalence-area1` = "province", wait_ = FALSE) + app$set_inputs(`prevalence-area2` = "strata", wait_ = FALSE) ## Assume sex as grouping var + app$set_inputs(`prevalence-area3` = "sex", wait_ = FALSE) + app$set_inputs(`prevalence-wts` = "wtfactor", wait_ = FALSE) + app$set_inputs(`prevalence-oedema` = "oedema", wait_ = FALSE) + + ### Click on Estime Prevalence button ---- + app$click(input = "prevalence-estimate") + app$wait_for_value(output = "prevalence-results", timeout = 40000) + + ### Capture JavaScript expressions to return results's cols and values ---- + js_cols <- "$('#prevalence-results thead th').map(function() {return $(this).text();}).get();" - js_values <- "$('#prevalence-results tbody tr').map(function() + js_values <- "$('#prevalence-results tbody tr').map(function() {return $(this).text();}).get();" - ### Capture prevalence results of Nampula Province, Urban Strata ---- - glued_results <- app$get_js(js_values)[[3]] - prev <- stringr::str_extract_all(glued_results, "\\d{2}\\.\\d")[[1]] - weighted_pop <- sub("1", "", stringr::str_extract(glued_results, "\\d{7}(?:)")) + ### Capture prevalence results of Nampula Province, Urban Strata ---- + glued_results <- app$get_js(js_values)[[3]] + prev <- stringr::str_extract_all(glued_results, "\\d{2}\\.\\d")[[1]] + weighted_pop <- sub( + "1", + "", + stringr::str_extract(glued_results, "\\d{7}(?:)") + ) - ### Test check ---- - testthat::expect_equal(length(app$get_js(js_cols)[1:19]), 19) - testthat::expect_equal(as.numeric(prev[2]), 10.8) # GAM - testthat::expect_equal(as.numeric(weighted_pop), 288534) + ### Test check ---- + testthat::expect_equal(length(app$get_js(js_cols)[1:19]), 19) + testthat::expect_equal(as.numeric(prev[2]), 10.8) # GAM + testthat::expect_equal(as.numeric(weighted_pop), 288534) - ### Stop the app ---- - app$stop() - } -) + ### Stop the app ---- + app$stop() +}) ### Combined unweighted prevalence ---- -testthat::test_that( - desc = "Module works well to estimate unweighted-combined prevalence from survey", - code = { - ### Initialise mwana app ---- - app <- shinytest2::AppDriver$new( - app_dir = testthat::test_path("fixtures"), - timeout = 120000, - wait = TRUE - ) - - ### Wait the app to idle ---- - app$wait_for_idle(timeout = 40000) - - ### Click in the Data Upload tab ---- - app$click(selector = "a[data-value='Data Upload']") - app$wait_for_idle(timeout = 40000) - - #### Read data ---- - data <- read.csv( - file = testthat::test_path("fixtures", "anthro-01.csv"), - check.names = FALSE - ) - data["sex"] <- ifelse(data$sex == 1, "m", "f") - tempfile <- tempfile(fileext = ".csv") - write.csv(data, tempfile, row.names = FALSE) - - #### Upload onto the app ---- - app$upload_file(`upload_data-upload` = tempfile, wait_ = TRUE) - - ### Click on the data wrangling tab ---- - app$click(selector = "a[data-value='Data Wrangling']") - app$wait_for_idle(timeout = 40000) - - ### Select data wrangling method and wait the app till idles ---- - app$set_inputs(`wrangle_data-wrangle` = "combined", wait_ = TRUE) - app$wait_for_idle(timeout = 40000) - - ### Input variables ---- - app$set_inputs(`wrangle_data-dos` = "", wait_ = FALSE) - app$set_inputs(`wrangle_data-dob` = "", wait_ = FALSE) - app$set_inputs(`wrangle_data-age` = "age", wait_ = FALSE) - app$set_inputs(`wrangle_data-sex` = "sex", wait_ = FALSE) - app$set_inputs(`wrangle_data-weight` = "weight", wait_ = FALSE) - app$set_inputs(`wrangle_data-height` = "height", wait_ = FALSE) - app$set_inputs(`wrangle_data-muac` = "muac", wait_ = FALSE) - - ### Click wrangle button and wait the app to idle ---- - app$click(input = "wrangle_data-apply_wrangle") - app$wait_for_idle(timeout = 40000) - - ### Click on the Prevalence tab and wait the app to idle ---- - app$click(selector = "a[data-value='Prevalence Analysis']") - app$wait_for_idle(timeout = 40000) - - ### Select source of data ---- - app$set_inputs(`prevalence-source` = "survey", wait_ = FALSE) - - ### Select the method ---- - app$set_inputs(`prevalence-amn_method_survey` = "combined", wait_ = TRUE) - app$set_inputs(`prevalence-area1` = "province", wait_ = FALSE) - app$set_inputs(`prevalence-area2` = "strata", wait_ = FALSE) ## Assume sex as grouping var - app$set_inputs(`prevalence-area3` = "sex", wait_ = FALSE) - app$set_inputs(`prevalence-wts` = "", wait_ = FALSE) - app$set_inputs(`prevalence-oedema` = "oedema", wait_ = FALSE) - - ### Click on Estime Prevalence button ---- - app$click(input = "prevalence-estimate") - app$wait_for_value(output = "prevalence-results", timeout = 40000) - - ### Capture JavaScript expressions to return results's cols and values ---- - js_cols <- "$('#prevalence-results thead th').map(function() +testthat::test_that(desc = "Module works well to estimate unweighted-combined prevalence from survey", code = { + ### Skip test on CRAN ---- + testthat::skip_on_cran() + + ### Initialise mwana app ---- + app <- shinytest2::AppDriver$new( + app_dir = testthat::test_path("fixtures"), + timeout = 120000, + wait = TRUE + ) + + ### Wait the app to idle ---- + app$wait_for_idle(timeout = 40000) + + ### Click in the Data Upload tab ---- + app$click(selector = "a[data-value='Data Upload']") + app$wait_for_idle(timeout = 40000) + + #### Read data ---- + data <- read.csv( + file = testthat::test_path("fixtures", "anthro-01.csv"), + check.names = FALSE + ) + data["sex"] <- ifelse(data$sex == 1, "m", "f") + tempfile <- tempfile(fileext = ".csv") + write.csv(data, tempfile, row.names = FALSE) + + #### Upload onto the app ---- + app$upload_file(`upload_data-upload` = tempfile, wait_ = TRUE) + + ### Click on the data wrangling tab ---- + app$click(selector = "a[data-value='Data Wrangling']") + app$wait_for_idle(timeout = 40000) + + ### Select data wrangling method and wait the app till idles ---- + app$set_inputs(`wrangle_data-wrangle` = "combined", wait_ = TRUE) + app$wait_for_idle(timeout = 40000) + + ### Input variables ---- + app$set_inputs(`wrangle_data-dos` = "", wait_ = FALSE) + app$set_inputs(`wrangle_data-dob` = "", wait_ = FALSE) + app$set_inputs(`wrangle_data-age` = "age", wait_ = FALSE) + app$set_inputs(`wrangle_data-sex` = "sex", wait_ = FALSE) + app$set_inputs(`wrangle_data-weight` = "weight", wait_ = FALSE) + app$set_inputs(`wrangle_data-height` = "height", wait_ = FALSE) + app$set_inputs(`wrangle_data-muac` = "muac", wait_ = FALSE) + + ### Click wrangle button and wait the app to idle ---- + app$click(input = "wrangle_data-apply_wrangle") + app$wait_for_idle(timeout = 40000) + + ### Click on the Prevalence tab and wait the app to idle ---- + app$click(selector = "a[data-value='Prevalence Analysis']") + app$wait_for_idle(timeout = 40000) + + ### Select source of data ---- + app$set_inputs(`prevalence-source` = "survey", wait_ = FALSE) + + ### Select the method ---- + app$set_inputs(`prevalence-amn_method_survey` = "combined", wait_ = TRUE) + app$set_inputs(`prevalence-area1` = "province", wait_ = FALSE) + app$set_inputs(`prevalence-area2` = "strata", wait_ = FALSE) ## Assume sex as grouping var + app$set_inputs(`prevalence-area3` = "sex", wait_ = FALSE) + app$set_inputs(`prevalence-wts` = "", wait_ = FALSE) + app$set_inputs(`prevalence-oedema` = "oedema", wait_ = FALSE) + + ### Click on Estime Prevalence button ---- + app$click(input = "prevalence-estimate") + app$wait_for_value(output = "prevalence-results", timeout = 40000) + + ### Capture JavaScript expressions to return results's cols and values ---- + js_cols <- "$('#prevalence-results thead th').map(function() {return $(this).text();}).get();" - js_values <- "$('#prevalence-results tbody tr').map(function() + js_values <- "$('#prevalence-results tbody tr').map(function() {return $(this).text();}).get();" - ### Capture prevalence results of Nampula Province, Urban Strata ---- - glued_results <- app$get_js(js_values)[[3]] - pop <- sub("1", "", stringr::str_extract(glued_results, "\\d{4}")) - prev <- stringr::str_extract(glued_results, "\\d{2}\\.\\d") + ### Capture prevalence results of Nampula Province, Urban Strata ---- + glued_results <- app$get_js(js_values)[[3]] + pop <- sub("1", "", stringr::str_extract(glued_results, "\\d{4}")) + prev <- stringr::str_extract(glued_results, "\\d{2}\\.\\d") - ### Test check ---- - testthat::expect_equal(length(app$get_js(js_cols)[1:19]), 19) - testthat::expect_equal(as.numeric(prev), 10.5) # GAM - testthat::expect_equal(as.numeric(pop), 276) + ### Test check ---- + testthat::expect_equal(length(app$get_js(js_cols)[1:19]), 19) + testthat::expect_equal(as.numeric(prev), 10.5) # GAM + testthat::expect_equal(as.numeric(pop), 276) - ### Stop the app ---- - app$stop() - } -) + ### Stop the app ---- + app$stop() +}) ## ---- Screening data --------------------------------------------------------- - ### When age is available ---- -testthat::test_that( - desc = "Module works well to estimate prevalence from screening", - code = { - ### Initialise mwana app ---- - app <- shinytest2::AppDriver$new( - app_dir = testthat::test_path("fixtures"), - timeout = 120000, - wait = TRUE - ) - - ### Wait the app to idle ---- - app$wait_for_idle(timeout = 40000) - - ### Click in the Data Upload tab ---- - app$click(selector = "a[data-value='Data Upload']") - app$wait_for_idle(timeout = 40000) - - #### Read data ---- - data <- read.csv( - file = testthat::test_path("fixtures", "anthro-02.csv"), - check.names = FALSE - ) - ### Make age categories ---- - data <- data |> - transform(oedema = dplyr::recode_values(oedema, "n " ~ "n")) - - tempfile <- tempfile(fileext = ".csv") - write.csv(data, tempfile, row.names = FALSE) - - #### Upload onto the app ---- - app$upload_file(`upload_data-upload` = tempfile, wait_ = TRUE) - - ### Click on the data wrangling tab ---- - app$click(selector = "a[data-value='Data Wrangling']") - app$wait_for_idle(timeout = 40000) - - ### Select data wrangling method and wait the app till idles ---- - app$set_inputs(`wrangle_data-wrangle` = "mfaz", wait_ = TRUE) - app$wait_for_idle(timeout = 40000) - - ### Input variables ---- - app$set_inputs(`wrangle_data-dos` = "", wait_ = FALSE) - app$set_inputs(`wrangle_data-dob` = "", wait_ = FALSE) - app$set_inputs(`wrangle_data-age` = "age", wait_ = FALSE) - app$set_inputs(`wrangle_data-sex` = "sex", wait_ = FALSE) - app$set_inputs(`wrangle_data-muac` = "muac", wait_ = FALSE) - - ### Click wrangle button and wait the app to idle ---- - app$click(input = "wrangle_data-apply_wrangle") - app$wait_for_idle(timeout = 40000) - - ### Click on the Prevalence tab and wait the app to idle ---- - app$click(selector = "a[data-value='Prevalence Analysis']") - app$wait_for_idle(timeout = 40000) - - ### Select source of data ---- - app$set_inputs(`prevalence-source` = "screening", wait_ = TRUE) - - ### Select the method ---- - app$set_inputs(`prevalence-has_age` = "yes", wait_ = TRUE) - app$set_inputs(`prevalence-area1` = "analysis_unit", wait_ = FALSE) - app$set_inputs(`prevalence-area2` = "sex", wait_ = FALSE) ## Assume sex as grouping var - app$set_inputs(`prevalence-area3` = "", wait_ = FALSE) - app$set_inputs(`prevalence-muac` = "muac", wait_ = FALSE) - app$set_inputs(`prevalence-age` = "age", wait = FALSE) - app$set_inputs(`prevalence-oedema` = "oedema", wait_ = FALSE) - - ### Click on Estime Prevalence button ---- - app$click(input = "prevalence-estimate") - app$wait_for_value(output = "prevalence-results", timeout = 40000) - - ### Capture JavaScript expressions to return results's cols and values ---- - js_cols <- "$('#prevalence-results thead th').map(function() +testthat::test_that(desc = "Module works well to estimate prevalence from screening", code = { + ### Skip test on CRAN ---- + testthat::skip_on_cran() + + ### Initialise mwana app ---- + app <- shinytest2::AppDriver$new( + app_dir = testthat::test_path("fixtures"), + timeout = 120000, + wait = TRUE + ) + + ### Wait the app to idle ---- + app$wait_for_idle(timeout = 40000) + + ### Click in the Data Upload tab ---- + app$click(selector = "a[data-value='Data Upload']") + app$wait_for_idle(timeout = 40000) + + #### Read data ---- + data <- read.csv( + file = testthat::test_path("fixtures", "anthro-02.csv"), + check.names = FALSE + ) + ### Make age categories ---- + data <- data |> + transform(oedema = dplyr::recode_values(oedema, "n " ~ "n")) + + tempfile <- tempfile(fileext = ".csv") + write.csv(data, tempfile, row.names = FALSE) + + #### Upload onto the app ---- + app$upload_file(`upload_data-upload` = tempfile, wait_ = TRUE) + + ### Click on the data wrangling tab ---- + app$click(selector = "a[data-value='Data Wrangling']") + app$wait_for_idle(timeout = 40000) + + ### Select data wrangling method and wait the app till idles ---- + app$set_inputs(`wrangle_data-wrangle` = "mfaz", wait_ = TRUE) + app$wait_for_idle(timeout = 40000) + + ### Input variables ---- + app$set_inputs(`wrangle_data-dos` = "", wait_ = FALSE) + app$set_inputs(`wrangle_data-dob` = "", wait_ = FALSE) + app$set_inputs(`wrangle_data-age` = "age", wait_ = FALSE) + app$set_inputs(`wrangle_data-sex` = "sex", wait_ = FALSE) + app$set_inputs(`wrangle_data-muac` = "muac", wait_ = FALSE) + + ### Click wrangle button and wait the app to idle ---- + app$click(input = "wrangle_data-apply_wrangle") + app$wait_for_idle(timeout = 40000) + + ### Click on the Prevalence tab and wait the app to idle ---- + app$click(selector = "a[data-value='Prevalence Analysis']") + app$wait_for_idle(timeout = 40000) + + ### Select source of data ---- + app$set_inputs( + `prevalence-source` = "screening", + wait_ = TRUE, + timeout_ = 40000 + ) + + ### Select the method ---- + app$set_inputs(`prevalence-has_age` = "yes", wait_ = TRUE, timeout_ = 40000) + app$set_inputs(`prevalence-area1` = "analysis_unit", wait_ = FALSE) + app$set_inputs(`prevalence-area2` = "sex", wait_ = FALSE) ## Assume sex as grouping var + app$set_inputs(`prevalence-area3` = "", wait_ = FALSE) + app$set_inputs(`prevalence-muac` = "muac", wait_ = FALSE) + app$set_inputs(`prevalence-age` = "age", wait_ = FALSE) + + ### Click on Estime Prevalence button ---- + app$click(input = "prevalence-estimate") + app$wait_for_value(output = "prevalence-results", timeout = 40000) + + ### Capture JavaScript expressions to return results's cols and values ---- + js_cols <- "$('#prevalence-results thead th').map(function() {return $(this).text();}).get();" - js_values <- "$('#prevalence-results tbody tr').map(function() + js_values <- "$('#prevalence-results tbody tr').map(function() {return $(this).text();}).get();" - ### Capture results ---- - glued_results_unit_a <- app$get_js(js_values)[[1]] - glued_results_unit_b <- app$get_js(js_values)[[2]] + ### Capture results ---- + glued_results_unit_a <- app$get_js(js_values)[[1]] + glued_results_unit_b <- app$get_js(js_values)[[2]] - N_unit_a <- stringr::str_extract_all(glued_results_unit_a, "\\d{3}$")[[1]] - N_unit_b <- stringr::str_extract_all(glued_results_unit_b, "\\d{4}$")[[1]] + N_unit_a <- stringr::str_extract_all(glued_results_unit_a, "\\d{3}$")[[1]] + N_unit_b <- stringr::str_extract_all(glued_results_unit_b, "\\d{4}$")[[1]] - #### Prevalences ---- - prev_unit_a <- stringr::str_extract_all(glued_results_unit_a, "\\d\\.\\d")[[1]] - prev_unit_b <- stringr::str_extract(glued_results_unit_b, "\\d{2}\\.\\d")[[1]] + #### Prevalences ---- + prev_unit_a <- stringr::str_extract_all(glued_results_unit_a, "\\d\\.\\d")[[ + 1 + ]] + prev_unit_b <- stringr::str_extract(glued_results_unit_b, "\\d{2}\\.\\d")[[1]] + ### Test check ---- + testthat::expect_equal(length(app$get_js(js_cols)[1:9]), 9) + testthat::expect_equal(as.numeric(N_unit_a), 608) + testthat::expect_equal(as.numeric(N_unit_b), 1359) + testthat::expect_equal(as.numeric(prev_unit_a)[1], 6.4) # GAM + testthat::expect_equal(as.numeric(prev_unit_a)[2], 1.2) # SAM + testthat::expect_equal(as.numeric(prev_unit_a)[3], 5.3) # MAM + testthat::expect_equal(as.numeric(prev_unit_b), 12.4) # Age-weighted GAM - ### Test check ---- - testthat::expect_equal(length(app$get_js(js_cols)[1:9]), 9) - testthat::expect_equal(as.numeric(N_unit_a), 608) - testthat::expect_equal(as.numeric(N_unit_b), 1359) - testthat::expect_equal(as.numeric(prev_unit_a)[1], 6.4) # GAM - testthat::expect_equal(as.numeric(prev_unit_a)[2], 1.2) # SAM - testthat::expect_equal(as.numeric(prev_unit_a)[3], 5.3) # MAM - testthat::expect_equal(as.numeric(prev_unit_b), 12.4) # Age-weighted GAM - - ### Stop the app ---- - app$stop() - } -) + ### Stop the app ---- + app$stop() +}) ### When age is given in categories ---- -testthat::test_that( - desc = "Prevalence tab works as expected when age is given in categories", - code = { - #### Initialise app ---- - app <- shinytest2::AppDriver$new( - app_dir = testthat::test_path("fixtures"), - timeout = 120000, - wait = TRUE +testthat::test_that(desc = "Prevalence tab works as expected when age is given in categories", code = { + ### Skip test on CRAN ---- + testthat::skip_on_cran() + + #### Initialise app ---- + app <- shinytest2::AppDriver$new( + app_dir = testthat::test_path("fixtures"), + timeout = 120000, + wait = TRUE + ) + + #### Wait app to idle ---- + app$wait_for_idle(timeout = 40000) + + #### Click on the Data Upload tab ---- + app$click(selector = "a[data-value='Data Upload']") + + app$wait_for_idle(timeout = 40000) + + #### Read data ---- + data <- read.csv( + file = testthat::test_path("fixtures", "anthro-02.csv"), + check.names = FALSE + ) + + ### Make age categories ---- + data <- data |> + transform( + age_cat = ifelse(age < 24, "6-23", "24-59"), + oedema = dplyr::recode_values(oedema, "n " ~ "n") ) - #### Wait app to idle ---- - app$wait_for_idle(timeout = 40000) + tempfile <- tempfile(fileext = ".csv") + write.csv(data, tempfile, row.names = FALSE) - #### Click on the Data Upload tab ---- - app$click(selector = "a[data-value='Data Upload']") + #### Upload onto the app ---- + app$upload_file(`upload_data-upload` = tempfile, wait_ = TRUE) - app$wait_for_idle(timeout = 40000) + ### Click on Data Wrangling tab ---- + app$click(selector = "a[data-value='Data Wrangling'") + app$wait_for_idle(timeout = 40000) - #### Read data ---- - data <- read.csv( - file = testthat::test_path("fixtures", "anthro-02.csv"), - check.names = FALSE - ) + #### Select data wrangling method ---- + app$set_inputs("wrangle_data-wrangle" = "muac") + app$wait_for_idle(timeout = 40000) - ### Make age categories ---- - data <- data |> - transform( - age_cat = ifelse(age < 24, "6-23", "24-59"), - oedema = dplyr::recode_values(oedema, "n " ~ "n") - ) - - tempfile <- tempfile(fileext = ".csv") - write.csv(data, tempfile, row.names = FALSE) - - #### Upload onto the app ---- - app$upload_file(`upload_data-upload` = tempfile, wait_ = TRUE) - - ### Click on Data Wrangling tab ---- - app$click(selector = "a[data-value='Data Wrangling'") - app$wait_for_idle(timeout = 40000) - - #### Select data wrangling method ---- - app$set_inputs("wrangle_data-wrangle" = "muac") - app$wait_for_idle(timeout = 40000) - - #### Select variables ---- - app$set_inputs("wrangle_data-sex" = "sex", wait_ = FALSE) - app$set_inputs("wrangle_data-muac" = "muac", wait_ = FALSE) - - #### Click on wrangle button ---- - app$click(input = "wrangle_data-apply_wrangle") - app$wait_for_idle(timeout = 40000) - - #### Click on Prevalence tab ---- - app$click(selector = "a[data-value='Prevalence Analysis']") - app$wait_for_idle(timeout = 40000) - - #### Select source of data ---- - app$set_inputs("prevalence-source" = "screening", wait_ = FALSE) - app$wait_for_idle(timeout = 40000) - - #### Select if age is available ---- - app$set_inputs("prevalence-has_age" = "no", wait_ = TRUE) - - #### Select variables ---- - app$set_inputs("prevalence-area1" = "analysis_unit", wait_ = FALSE) - app$set_inputs("prevalence-area2" = "sex", wait_ = FALSE) - app$set_inputs("prevalence-area3" = "", wait_ = FALSE) - app$set_inputs("prevalence-muac" = "muac", wait_ = FALSE) - app$set_inputs("prevalence-age_cat" = "age_cat", wait_ = FALSE) - app$set_inputs("prevalence-oedema" = "oedema", wait_ = FALSE) - - #### Click on Estimate Prevalence button ---- - app$click(input = "prevalence-estimate") - #### Wait until output has been rendered ---- - app$wait_for_value(output = "prevalence-results", timeout = 40000) - - ### Capture JavaScript expressions to return results's cols and values ---- - js_cols <- "$('#prevalence-results thead th').map(function() - {return $(this).text();}).get();" + #### Select variables ---- + app$set_inputs("wrangle_data-sex" = "sex", wait_ = FALSE) + app$set_inputs("wrangle_data-muac" = "muac", wait_ = FALSE) - js_values <- "$('#prevalence-results tbody tr').map(function() - {return $(this).text();}).get();" + #### Click on wrangle button ---- + app$click(input = "wrangle_data-apply_wrangle") + app$wait_for_idle(timeout = 40000) - ### Capture prevalence ---- - glued_results_unit_a <- app$get_js(js_values)[[1]] - glued_results_unit_b <- app$get_js(js_values)[[2]] + #### Click on Prevalence tab ---- + app$click(selector = "a[data-value='Prevalence Analysis']") + app$wait_for_idle(timeout = 40000) - N_unit_a <- stringr::str_extract_all(glued_results_unit_a, "\\d{3}$")[[1]] - N_unit_b <- stringr::str_extract_all(glued_results_unit_b, "\\d{4}$")[[1]] + #### Select source of data ---- + app$set_inputs("prevalence-source" = "screening", wait_ = FALSE) + app$wait_for_idle(timeout = 40000) - #### Prevalences ---- - prev_unit_a <- stringr::str_extract_all(glued_results_unit_a, "\\d\\.\\d")[[1]] - prev_unit_b <- stringr::str_extract(glued_results_unit_b, "\\d{2}\\.\\d")[[1]] + #### Select if age is available ---- + app$set_inputs("prevalence-has_age" = "no", wait_ = TRUE) + #### Select variables ---- + app$set_inputs("prevalence-area1" = "analysis_unit", wait_ = FALSE) + app$set_inputs("prevalence-area2" = "sex", wait_ = FALSE) + app$set_inputs("prevalence-area3" = "", wait_ = FALSE) + app$set_inputs("prevalence-muac" = "muac", wait_ = FALSE) + app$set_inputs("prevalence-age_cat" = "age_cat", wait_ = FALSE) - ### Test check ---- - testthat::expect_equal(length(app$get_js(js_cols)[1:9]), 9) - testthat::expect_equal(as.numeric(N_unit_a), 612) - testthat::expect_equal(as.numeric(N_unit_b), 1365) - testthat::expect_equal(as.numeric(prev_unit_a)[1], 6.4) # GAM - testthat::expect_equal(as.numeric(prev_unit_a)[2], 1.1) # SAM - testthat::expect_equal(as.numeric(prev_unit_a)[3], 5.2) # MAM - testthat::expect_equal(as.numeric(prev_unit_b), 12.6) # Age-weighted GAM + #### Click on Estimate Prevalence button ---- + app$click(input = "prevalence-estimate") + #### Wait until output has been rendered ---- + app$wait_for_value(output = "prevalence-results", timeout = 40000) - ### Stop the app ---- - app$stop() - } -) + ### Capture JavaScript expressions to return results's cols and values ---- + js_cols <- "$('#prevalence-results thead th').map(function() + {return $(this).text();}).get();" + + js_values <- "$('#prevalence-results tbody tr').map(function() + {return $(this).text();}).get();" + + ### Capture prevalence ---- + glued_results_unit_a <- app$get_js(js_values)[[1]] + glued_results_unit_b <- app$get_js(js_values)[[2]] + + N_unit_a <- stringr::str_extract_all(glued_results_unit_a, "\\d{3}$")[[1]] + N_unit_b <- stringr::str_extract_all(glued_results_unit_b, "\\d{4}$")[[1]] + + #### Prevalences ---- + prev_unit_a <- stringr::str_extract_all(glued_results_unit_a, "\\d\\.\\d")[[ + 1 + ]] + prev_unit_b <- stringr::str_extract(glued_results_unit_b, "\\d{2}\\.\\d")[[1]] + + ### Test check ---- + testthat::expect_equal(length(app$get_js(js_cols)[1:9]), 9) + testthat::expect_equal(as.numeric(N_unit_a), 612) + testthat::expect_equal(as.numeric(N_unit_b), 1365) + testthat::expect_equal(as.numeric(prev_unit_a)[1], 6.4) # GAM + testthat::expect_equal(as.numeric(prev_unit_a)[2], 1.1) # SAM + testthat::expect_equal(as.numeric(prev_unit_a)[3], 5.2) # MAM + testthat::expect_equal(as.numeric(prev_unit_b), 12.6) # Age-weighted GAM + + ### Stop the app ---- + app$stop() +}) diff --git a/tests/testthat/test-module-wrangling.R b/tests/testthat/test-module-wrangling.R index ab3afe2..f4ecf42 100644 --- a/tests/testthat/test-module-wrangling.R +++ b/tests/testthat/test-module-wrangling.R @@ -7,6 +7,9 @@ testthat::test_that(desc = "Server data wrangling works as expected for WFHZ", { + ### Skip test on CRAN ---- + testthat::skip_on_cran() + ## Initialise app ---- app <- shinytest2::AppDriver$new( app_dir = testthat::test_path("fixtures"), @@ -68,6 +71,9 @@ testthat::test_that(desc = "Server data wrangling works as expected for WFHZ", { ### When user supplies dos and dob for age wrangling ---- testthat::test_that(desc = "Server data wrangling wrangles age correctly in WFHZ", { + ### Skip test on CRAN ---- + testthat::skip_on_cran() + ## Initialise app ---- app <- shinytest2::AppDriver$new( app_dir = testthat::test_path("fixtures"), @@ -142,6 +148,9 @@ testthat::test_that(desc = "Server data wrangling wrangles age correctly in WFHZ testthat::test_that(desc = "Server data wrangling works as expected for MFAZ", { + ### Skip test on CRAN ---- + testthat::skip_on_cran() + ## Initialise app ---- app <- shinytest2::AppDriver$new( app_dir = testthat::test_path("fixtures"), @@ -204,6 +213,9 @@ testthat::test_that(desc = "Server data wrangling works as expected for MFAZ", { ### When user supplies dos and dob for age wrangling ---- testthat::test_that(desc = "Server data wrangling wrangles age correctly in MFAZ", { + ### Skip test on CRAN ---- + testthat::skip_on_cran() + ## Initialise app ---- app <- shinytest2::AppDriver$new( app_dir = testthat::test_path("fixtures"), @@ -279,6 +291,9 @@ testthat::test_that(desc = "Server data wrangling wrangles age correctly in MFAZ testthat::test_that( desc = "Server data wrangling works as expected for raw MUAC values", code = { + ### Skip test on CRAN ---- + testthat::skip_on_cran() + #### Initialise app ---- app <- shinytest2::AppDriver$new( app_dir = testthat::test_path("fixtures"), @@ -345,6 +360,9 @@ testthat::test_that( testthat::test_that( desc = "Server data wrangling works as expected for combined wrangling", { + ### Skip test on CRAN ---- + testthat::skip_on_cran() + ## Initialise app ---- app <- shinytest2::AppDriver$new( app_dir = testthat::test_path("fixtures"), @@ -402,6 +420,9 @@ testthat::test_that( ### When user supplies dos and dob for age wrangling ---- testthat::test_that(desc = "Server data wrangling wrangles age correctly in combined data wrangling", { + ### Skip test on CRAN ---- + testthat::skip_on_cran() + ## Initialise app ---- app <- shinytest2::AppDriver$new( app_dir = testthat::test_path("fixtures"),