Skip to content

Commit 1a74548

Browse files
osenanosenanllrs-rochem7pr
authored
wip: fix e2e test on tm_g_pp functions (#1446)
# Fix e2e tests Fixes #1440 Companion #1441 To verify the result of tests, you should do the following: 1. Install [this branch](insightsengineering/teal#1653) of teal 2. Install teal modules clinical on this version 3. ``` devtools::load_all() library(shinytest2) source("tests/testthat/helper-TealAppDriver.R") source("tests/testthat/helper-testing-depth.R") testthat::test_file("tests/testthat/test-shinytest2-tm_g_pp_patient_timeline.R") testthat::test_file("tests/testthat/test-shinytest2-tm_g_pp_vitals.R") testthat::test_file("tests/testthat/test-shinytest2-tm_g_pp_therapy.R") testthat::test_file("tests/testthat/test-shinytest2-tm_g_pp_adverse_events.R") ``` --------- Co-authored-by: osenan <[email protected]> Co-authored-by: Lluís Revilla <[email protected]> Co-authored-by: Marcin <[email protected]>
1 parent 40b5489 commit 1a74548

File tree

4 files changed

+17
-17
lines changed

4 files changed

+17
-17
lines changed

tests/testthat/test-shinytest2-tm_g_pp_adverse_events.R

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ testthat::test_that(
7474
skip_if_too_deep(5)
7575
app_driver <- app_driver_tm_g_pp_adverse_events()
7676
testthat::expect_equal(
77-
app_driver$get_text("#teal-teal_modules-active_tab .active > a"),
77+
app_driver$get_text("a.nav-link.active"),
7878
"Adverse Events"
7979
)
8080

@@ -152,10 +152,10 @@ testthat::test_that(
152152
skip_if_too_deep(5)
153153
app_driver <- app_driver_tm_g_pp_adverse_events()
154154
input_id <- "patient_id"
155-
app_driver$set_active_module_input(input_id, "")
155+
app_driver$set_active_module_input(input_id, NULL)
156156
app_driver$expect_validation_error()
157157
testthat::expect_identical(
158-
app_driver$namespaces(TRUE)$module(sprintf("%s_input .shiny-validation-message", input_id)),
158+
app_driver$get_text(app_driver$namespaces(TRUE)$module(sprintf("%s_input .shiny-validation-message", input_id))),
159159
"Please select a patient"
160160
)
161161
app_driver$stop()
@@ -197,7 +197,7 @@ testthat::test_that(
197197
app_driver$set_active_module_input(input_id, "")
198198
app_driver$expect_validation_error()
199199
testthat::expect_identical(
200-
app_driver$namespaces(TRUE)$module(sprintf("%s_input .shiny-validation-message", input_id)),
200+
app_driver$get_text(app_driver$namespaces(TRUE)$module(sprintf("%s_input .shiny-validation-message", input_id))),
201201
"Please select AETERM variable."
202202
)
203203
app_driver$stop()
@@ -239,7 +239,7 @@ testthat::test_that(
239239
app_driver$set_active_module_input(input_id, "")
240240
app_driver$expect_validation_error()
241241
testthat::expect_identical(
242-
app_driver$namespaces(TRUE)$module(sprintf("%s_input .shiny-validation-message", input_id)),
242+
app_driver$get_text(app_driver$namespaces(TRUE)$module(sprintf("%s_input .shiny-validation-message", input_id))),
243243
"Please select AETOXGR variable."
244244
)
245245
app_driver$stop()
@@ -281,7 +281,7 @@ testthat::test_that(
281281
app_driver$set_active_module_input(input_id, "")
282282
app_driver$expect_validation_error()
283283
testthat::expect_identical(
284-
app_driver$namespaces(TRUE)$module(sprintf("%s_input .shiny-validation-message", input_id)),
284+
app_driver$get_text(app_driver$namespaces(TRUE)$module(sprintf("%s_input .shiny-validation-message", input_id))),
285285
"Please select AEREL variable."
286286
)
287287
app_driver$stop()
@@ -323,7 +323,7 @@ testthat::test_that(
323323
app_driver$set_active_module_input(input_id, "")
324324
app_driver$expect_validation_error()
325325
testthat::expect_identical(
326-
app_driver$namespaces(TRUE)$module(sprintf("%s_input .shiny-validation-message", input_id)),
326+
app_driver$get_text(app_driver$namespaces(TRUE)$module(sprintf("%s_input .shiny-validation-message", input_id))),
327327
"Please select AEOUT variable."
328328
)
329329
app_driver$stop()
@@ -365,7 +365,7 @@ testthat::test_that(
365365
app_driver$set_active_module_input(input_id, "")
366366
app_driver$expect_validation_error()
367367
testthat::expect_identical(
368-
app_driver$namespaces(TRUE)$module(sprintf("%s_input .shiny-validation-message", input_id)),
368+
app_driver$get_text(app_driver$namespaces(TRUE)$module(sprintf("%s_input .shiny-validation-message", input_id))),
369369
"Please select AEACN variable."
370370
)
371371
app_driver$stop()
@@ -407,7 +407,7 @@ testthat::test_that(
407407
app_driver$set_active_module_input(input_id, "")
408408
app_driver$expect_validation_error()
409409
testthat::expect_identical(
410-
app_driver$namespaces(TRUE)$module(sprintf("%s_input .shiny-validation-message", input_id)),
410+
app_driver$get_text(app_driver$namespaces(TRUE)$module(sprintf("%s_input .shiny-validation-message", input_id))),
411411
"Please select ASTDY variable."
412412
)
413413
app_driver$stop()

tests/testthat/test-shinytest2-tm_g_pp_patient_timeline.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ testthat::test_that(
111111
app_driver <- app_driver_tm_g_pp_patient_timeline()
112112

113113
testthat::expect_equal(
114-
app_driver$get_text("#teal-teal_modules-active_tab .active > a"),
114+
app_driver$get_text("a.nav-link.active"),
115115
"Patient Timeline"
116116
)
117117
testthat::expect_equal(

tests/testthat/test-shinytest2-tm_g_pp_therapy.R

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ testthat::test_that("e2e - tm_g_pp_therapy: Module initializes in teal without e
9696
app_driver$expect_no_validation_error()
9797

9898
testthat::expect_true(
99-
app_driver$is_visible(app_driver$namespaces(TRUE)$module("therapy_plot-plot_out_main"))
99+
app_driver$is_visible(app_driver$namespaces(TRUE)$module("therapy_plot-plot_main"))
100100
)
101101
testthat::expect_true(
102102
app_driver$is_visible(app_driver$namespaces(TRUE)$module("therapy_table"))
@@ -113,7 +113,7 @@ testthat::test_that(
113113
app_driver <- app_driver_tm_g_pp_therapy()
114114

115115
testthat::expect_equal(
116-
trimws(app_driver$get_text("#teal-teal_modules-active_tab .active")),
116+
trimws(app_driver$get_text("a.nav-link.active")),
117117
"Therapy (e2e)"
118118
)
119119

@@ -155,15 +155,15 @@ test_different_selection <- function(input_name, input_id, new_value) {
155155
app_driver <- app_driver_tm_g_pp_therapy()
156156
plot_before <- list(
157157
app_driver$get_active_module_plot_output("therapy_plot"),
158-
app_driver$namespaces(TRUE)$module("therapy_table")
158+
app_driver$get_active_module_table_output("therapy_table")
159159
)
160160
app_driver$set_active_module_input(input_id, new_value)
161161
testthat::expect_false(
162162
identical(
163163
plot_before,
164164
list(
165165
app_driver$get_active_module_plot_output("therapy_plot"),
166-
app_driver$namespaces(TRUE)$module("therapy_table")
166+
app_driver$get_active_module_table_output("therapy_table")
167167
)
168168
)
169169
)
@@ -211,12 +211,12 @@ test_delection_validation <- function(input_name, input_id, deselect_message) {
211211
app_driver$set_active_module_input(input_id, NULL)
212212
app_driver$expect_validation_error()
213213
testthat::expect_equal(
214-
app_driver$namespaces(TRUE)$module(
214+
app_driver$get_text(app_driver$namespaces(TRUE)$module(
215215
sprintf(
216216
"%s_input .shiny-validation-message",
217217
input_id
218218
)
219-
),
219+
)),
220220
deselect_message
221221
)
222222
app_driver$stop()

tests/testthat/test-shinytest2-tm_g_pp_vitals.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ testthat::test_that(
5959
app_driver <- app_driver_tm_g_pp_vitals()
6060

6161
testthat::expect_equal(
62-
app_driver$get_text("#teal-teal_modules-active_tab .active > a"),
62+
app_driver$get_text("a.nav-link.active"),
6363
"Vitals"
6464
)
6565
testthat::expect_equal(

0 commit comments

Comments
 (0)