Skip to content

Commit

Permalink
added validationn test for inputs.
Browse files Browse the repository at this point in the history
  • Loading branch information
kartikeyakirar committed May 2, 2024
1 parent 5de6063 commit ad3b5fc
Showing 1 changed file with 95 additions and 0 deletions.
95 changes: 95 additions & 0 deletions tests/testthat/test-shinytest2-tm_t_exposure.R
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,98 @@ testthat::test_that(
app_driver$stop()
}
)

testthat::test_that("e2e - tm_t_exposure: Selecting paramcd-level changes the table and does not throw validation errors.", {

Check warning on line 96 in tests/testthat/test-shinytest2-tm_t_exposure.R

View workflow job for this annotation

GitHub Actions / SuperLinter 🦸‍♀️ / Lint R code 🧶

file=tests/testthat/test-shinytest2-tm_t_exposure.R,line=96,col=121,[line_length_linter] Lines should not be more than 120 characters. This line is 125 characters.
skip_if_too_deep(5)
app_driver <- app_driver_tm_t_exposure()
table_before <- app_driver$get_active_module_tws_output("table")
app_driver$set_active_module_input("paramcd-dataset_ADEX_singleextract-filter1-vals", "DOSE")
testthat::expect_false(identical(table_before, app_driver$get_active_module_tws_output("table")))
app_driver$expect_no_validation_error()
app_driver$stop()
})

testthat::test_that("e2e - tm_t_exposure: Deselection of paramcd-level throws validation error.", {
skip_if_too_deep(5)
app_driver <- app_driver_tm_t_exposure()
app_driver$set_active_module_input("paramcd-dataset_ADEX_singleextract-filter1-vals", NULL)
testthat::expect_identical(app_driver$get_active_module_tws_output("table"), data.frame())
app_driver$expect_validation_error()
testthat::expect_equal(
app_driver$active_module_element_text("paramcd-dataset_ADEX_singleextract-filter1-vals_input .shiny-validation-message"),

Check warning on line 113 in tests/testthat/test-shinytest2-tm_t_exposure.R

View workflow job for this annotation

GitHub Actions / SuperLinter 🦸‍♀️ / Lint R code 🧶

file=tests/testthat/test-shinytest2-tm_t_exposure.R,line=113,col=121,[line_length_linter] Lines should not be more than 120 characters. This line is 125 characters.
"Please select a parameter value."
)
app_driver$stop()
})

testthat::test_that("e2e - tm_t_exposure: Selecting parcat-level changes the table and does not throw validation errors.", {

Check warning on line 119 in tests/testthat/test-shinytest2-tm_t_exposure.R

View workflow job for this annotation

GitHub Actions / SuperLinter 🦸‍♀️ / Lint R code 🧶

file=tests/testthat/test-shinytest2-tm_t_exposure.R,line=119,col=121,[line_length_linter] Lines should not be more than 120 characters. This line is 124 characters.
skip_if_too_deep(5)
app_driver <- app_driver_tm_t_exposure()
table_before <- app_driver$get_active_module_tws_output("table")
app_driver$set_active_module_input("parcat-dataset_ADEX_singleextract-filter1-vals", "Drug B")
testthat::expect_false(identical(table_before, app_driver$get_active_module_tws_output("table")))
app_driver$expect_no_validation_error()
app_driver$stop()
})

testthat::test_that("e2e - tm_t_exposure: Deselection of parcat-level throws validation error.", {
skip_if_too_deep(5)
app_driver <- app_driver_tm_t_exposure()
app_driver$set_active_module_input("parcat-dataset_ADEX_singleextract-filter1-vals", NULL)
testthat::expect_identical(app_driver$get_active_module_tws_output("table"), data.frame())
app_driver$expect_validation_error()
testthat::expect_equal(
app_driver$active_module_element_text("parcat-dataset_ADEX_singleextract-filter1-vals_input .shiny-validation-message"),

Check warning on line 136 in tests/testthat/test-shinytest2-tm_t_exposure.R

View workflow job for this annotation

GitHub Actions / SuperLinter 🦸‍♀️ / Lint R code 🧶

file=tests/testthat/test-shinytest2-tm_t_exposure.R,line=136,col=121,[line_length_linter] Lines should not be more than 120 characters. This line is 124 characters.
"Please select a parameter category value."
)
app_driver$stop()
})

testthat::test_that("e2e - tm_t_exposure: Selecting col_by_var-variable changes the table and does not throw validation errors.", {

Check warning on line 142 in tests/testthat/test-shinytest2-tm_t_exposure.R

View workflow job for this annotation

GitHub Actions / SuperLinter 🦸‍♀️ / Lint R code 🧶

file=tests/testthat/test-shinytest2-tm_t_exposure.R,line=142,col=121,[line_length_linter] Lines should not be more than 120 characters. This line is 131 characters.
skip_if_too_deep(5)
app_driver <- app_driver_tm_t_exposure()
table_before <- app_driver$get_active_module_tws_output("table")
app_driver$set_active_module_input("col_by_var-dataset_ADSL_singleextract-select", "ARM")
testthat::expect_false(identical(table_before, app_driver$get_active_module_tws_output("table")))
app_driver$expect_no_validation_error()
app_driver$stop()
})

# TODO: update validation message once this bug is fixed
# https://github.com/insightsengineering/teal.modules.clinical/issues/1175
#
# testthat::test_that("e2e - tm_t_exposure: Deselection of col_by_var-variable throws validation error.", {
# skip_if_too_deep(5)

Check warning on line 156 in tests/testthat/test-shinytest2-tm_t_exposure.R

View workflow job for this annotation

GitHub Actions / SuperLinter 🦸‍♀️ / Lint R code 🧶

file=tests/testthat/test-shinytest2-tm_t_exposure.R,line=156,col=5,[commented_code_linter] Commented code should be removed.
# app_driver <- app_driver_tm_t_exposure()

Check warning on line 157 in tests/testthat/test-shinytest2-tm_t_exposure.R

View workflow job for this annotation

GitHub Actions / SuperLinter 🦸‍♀️ / Lint R code 🧶

file=tests/testthat/test-shinytest2-tm_t_exposure.R,line=157,col=5,[commented_code_linter] Commented code should be removed.
# app_driver$set_active_module_input("col_by_var-dataset_ADSL_singleextract-select", NULL)

Check warning on line 158 in tests/testthat/test-shinytest2-tm_t_exposure.R

View workflow job for this annotation

GitHub Actions / SuperLinter 🦸‍♀️ / Lint R code 🧶

file=tests/testthat/test-shinytest2-tm_t_exposure.R,line=158,col=5,[commented_code_linter] Commented code should be removed.
# testthat::expect_identical(app_driver$get_active_module_tws_output("table"), data.frame())

Check warning on line 159 in tests/testthat/test-shinytest2-tm_t_exposure.R

View workflow job for this annotation

GitHub Actions / SuperLinter 🦸‍♀️ / Lint R code 🧶

file=tests/testthat/test-shinytest2-tm_t_exposure.R,line=159,col=5,[commented_code_linter] Commented code should be removed.
# app_driver$expect_validation_error()

Check warning on line 160 in tests/testthat/test-shinytest2-tm_t_exposure.R

View workflow job for this annotation

GitHub Actions / SuperLinter 🦸‍♀️ / Lint R code 🧶

file=tests/testthat/test-shinytest2-tm_t_exposure.R,line=160,col=5,[commented_code_linter] Commented code should be removed.
# testthat::expect_equal(
# app_driver$active_module_element_text("col_by_var-dataset_ADSL_singleextract-select_input .shiny-validation-message"),
# "XXXX"
# )
# app_driver$stop()
# })

testthat::test_that("e2e - tm_t_exposure: Selecting row_by_var_var-variable changes the table and does not throw validation errors.", {
skip_if_too_deep(5)
app_driver <- app_driver_tm_t_exposure()
table_before <- app_driver$get_active_module_tws_output("table")
app_driver$set_active_module_input("row_by_var-dataset_ADEX_singleextract-select", "REGION1")
testthat::expect_false(identical(table_before, app_driver$get_active_module_tws_output("table")))
app_driver$expect_no_validation_error()
app_driver$stop()
})

testthat::test_that("e2e - tm_t_exposure: Deselection of row_by_var-variable throws validation error.", {
skip_if_too_deep(5)
app_driver <- app_driver_tm_t_exposure()
app_driver$set_active_module_input("row_by_var-dataset_ADEX_singleextract-select", NULL)
testthat::expect_identical(app_driver$get_active_module_tws_output("table"), data.frame())
app_driver$expect_validation_error()
testthat::expect_equal(
app_driver$active_module_element_text("row_by_var-dataset_ADEX_singleextract-select_input .shiny-validation-message"),
"Please select a row by variable."
)
app_driver$stop()
})

0 comments on commit ad3b5fc

Please sign in to comment.