@@ -117,12 +117,16 @@ testthat::test_that("e2e - tm_g_barchart_simple: Module initializes in teal with
117117 skip_if_too_deep(5 )
118118
119119 app_driver <- app_driver_tm_g_barchart_simple()
120+ app_driver $ wait_for_idle()
120121 app_driver $ expect_no_shiny_error()
121122 app_driver $ expect_no_validation_error()
122- testthat :: expect_true(
123- app_driver $ is_visible(app_driver $ namespaces(TRUE )$ module(" myplot-plot_out_main" ))
123+ testthat :: expect_match(
124+ app_driver $ get_active_module_plot_output(" myplot" ),
125+ " data:image/png;base64,"
124126 )
125127
128+ # Table is rendered asynchronously, wait a bit more
129+ app_driver $ wait_for_idle()
126130 testthat :: expect_true(app_driver $ is_visible(app_driver $ namespaces(TRUE )$ module(" table" )))
127131
128132 app_driver $ stop()
@@ -134,9 +138,10 @@ testthat::test_that(
134138 {
135139 skip_if_too_deep(5 )
136140 app_driver <- app_driver_tm_g_barchart_simple()
141+ app_driver $ wait_for_idle()
137142
138143 testthat :: expect_equal(
139- trimws( app_driver $ get_text(" #teal-teal_modules-active_tab .active" ) ),
144+ app_driver $ get_text(" a.nav-link .active" ),
140145 " ADAE Analysis (e2e)"
141146 )
142147
@@ -194,8 +199,10 @@ testthat::test_that(
194199 {
195200 skip_if_too_deep(5 )
196201 app_driver <- app_driver_tm_g_barchart_simple()
202+ app_driver $ wait_for_idle()
197203 plot_before <- app_driver $ get_active_module_plot_output(" myplot" )
198- app_driver $ set_input(app_driver $ namespaces(TRUE )$ module(ns_des_input(" x" , " ADSL" , " select" )), " RACE" )
204+ app_driver $ set_active_module_input(ns_des_input(" x" , " ADSL" , " select" ), " RACE" )
205+ app_driver $ wait_for_idle()
199206 testthat :: expect_false(identical(plot_before , app_driver $ get_active_module_plot_output(" myplot" )))
200207 app_driver $ expect_no_validation_error()
201208 app_driver $ stop()
@@ -205,13 +212,14 @@ testthat::test_that(
205212testthat :: test_that(" e2e - tm_g_barchart_simple: Deselection of 'x' throws validation error." , {
206213 skip_if_too_deep(5 )
207214 app_driver <- app_driver_tm_g_barchart_simple()
208- app_driver $ set_input(app_driver $ namespaces(TRUE )$ module(ns_des_input(" x" , " ADSL" , " select" )), character (0L ))
215+ app_driver $ wait_for_idle()
216+ app_driver $ set_active_module_input(ns_des_input(" x" , " ADSL" , " select" ), character (0L ))
209217 app_driver $ expect_validation_error()
210218 testthat :: expect_match(
211219 app_driver $ get_text(app_driver $ namespaces(TRUE )$ module(
212220 sprintf(
213- " %s .shiny-validation-message" ,
214- ns_des_input(" x" , " ADSL" , " select_input " )
221+ " %s_input .shiny-validation-message" ,
222+ ns_des_input(" x" , " ADSL" , " select " )
215223 )
216224 )),
217225 " ^Please select an x-variable$"
@@ -230,11 +238,15 @@ test_dataset_selection <- function(input_id, new_dataset, new_value) {
230238 {
231239 skip_if_too_deep(5 )
232240 app_driver <- app_driver_tm_g_barchart_simple()
241+ app_driver $ wait_for_idle()
233242 plot_before <- app_driver $ get_active_module_plot_output(" myplot" )
234- app_driver $ set_input(app_driver $ namespaces(TRUE )$ module(sprintf(" %s-dataset" , input_id )), new_dataset )
243+ app_driver $ set_active_module_input(sprintf(" %s-dataset" , input_id ), new_dataset )
244+ app_driver $ wait_for_idle()
235245 testthat :: expect_false(identical(plot_before , app_driver $ get_active_module_plot_output(" myplot" )))
236246 testthat :: expect_null(app_driver $ get_active_module_input(ns_des_input(input_id , new_dataset , " select" )))
237- app_driver $ set_input(app_driver $ namespaces(TRUE )$ module(ns_des_input(input_id , new_dataset , " select" )), new_value )
247+ # Wait for UI to update with new dataset options before setting value
248+ app_driver $ wait_for_idle()
249+ app_driver $ set_active_module_input(ns_des_input(input_id , new_dataset , " select" ), new_value )
238250 app_driver $ wait_for_idle()
239251 testthat :: expect_identical(
240252 app_driver $ get_active_module_input(ns_des_input(input_id , new_dataset , " select" )),
@@ -254,8 +266,10 @@ test_dataset_selection <- function(input_id, new_dataset, new_value) {
254266 {
255267 skip_if_too_deep(5 )
256268 app_driver <- app_driver_tm_g_barchart_simple()
269+ app_driver $ wait_for_idle()
257270 plot_before <- app_driver $ get_active_module_plot_output(" myplot" )
258- app_driver $ set_input(app_driver $ namespaces(TRUE )$ module(sprintf(" %s-dataset" , input_id )), character (0L ))
271+ app_driver $ set_active_module_input(sprintf(" %s-dataset" , input_id ), character (0L ))
272+ app_driver $ wait_for_idle()
259273 testthat :: expect_null(app_driver $ get_active_module_input(input_id ))
260274 testthat :: expect_false(identical(plot_before , app_driver $ get_active_module_plot_output(" myplot" )))
261275 app_driver $ expect_no_validation_error()
@@ -279,17 +293,19 @@ for (input_id in c("fill", "x_facet", "y_facet")) {
279293 {
280294 skip_if_too_deep(5 )
281295 app_driver <- app_driver_tm_g_barchart_simple()
282- app_driver $ set_input(app_driver $ namespaces(TRUE )$ module(ns_des_input(" x" , " ADSL" , " select" )), " ACTARM" , wait_ = FALSE )
283- app_driver $ set_input(app_driver $ namespaces(TRUE )$ module(sprintf(" %s-dataset" , input_id )), " ADSL" , wait_ = FALSE )
284- app_driver $ set_input(app_driver $ namespaces(TRUE )$ module(ns_des_input(input_id , " ADSL" , " select" )), " ACTARM" )
296+ app_driver $ wait_for_idle()
297+ app_driver $ set_active_module_input(ns_des_input(" x" , " ADSL" , " select" ), " ACTARM" , wait_ = FALSE )
298+ app_driver $ set_active_module_input(sprintf(" %s-dataset" , input_id ), " ADSL" , wait_ = FALSE )
299+ app_driver $ set_active_module_input(ns_des_input(input_id , " ADSL" , " select" ), " ACTARM" )
300+ app_driver $ wait_for_idle()
285301
286302 app_driver $ expect_validation_error()
287303
288304 testthat :: expect_match(
289305 app_driver $ get_text(app_driver $ namespaces(TRUE )$ module(
290306 sprintf(
291- " %s .shiny-validation-message" ,
292- ns_des_input(" x" , " ADSL" , " select_input " )
307+ " %s_input .shiny-validation-message" ,
308+ ns_des_input(" x" , " ADSL" , " select " )
293309 )
294310 )),
295311 " ^Duplicated value: ACTARM$"
@@ -298,8 +314,8 @@ for (input_id in c("fill", "x_facet", "y_facet")) {
298314 testthat :: expect_match(
299315 app_driver $ get_text(app_driver $ namespaces(TRUE )$ module(
300316 sprintf(
301- " %s .shiny-validation-message" ,
302- ns_des_input(input_id , " ADSL" , " select_input " )
317+ " %s_input .shiny-validation-message" ,
318+ ns_des_input(input_id , " ADSL" , " select " )
303319 )
304320 )),
305321 " ^Duplicated value: ACTARM$"
@@ -320,7 +336,9 @@ test_that_plot_settings <- function(input_id, new_value, setup_fun = function(ap
320336 {
321337 skip_if_too_deep(5 )
322338 app_driver <- app_driver_tm_g_barchart_simple()
339+ app_driver $ wait_for_idle()
323340 setup_fun(app_driver )
341+ app_driver $ wait_for_idle()
324342 plot_before <- app_driver $ get_active_module_plot_output(" myplot" )
325343 app_driver $ set_active_module_input(input_id , new_value )
326344 app_driver $ wait_for_idle()
@@ -345,5 +363,8 @@ test_that_plot_settings("show_n", TRUE)
345363test_that_plot_settings(
346364 " rotate_bar_labels" ,
347365 FALSE ,
348- setup_fun = function (app_driver ) app_driver $ set_input(app_driver $ namespaces(TRUE )$ module(" label_bars" ), TRUE )
366+ setup_fun = function (app_driver ) {
367+ app_driver $ set_active_module_input(" label_bars" , TRUE )
368+ return (NULL )
369+ }
349370)
0 commit comments