Skip to content

Commit a61d664

Browse files
committed
test: fix e2e tests
1 parent 2423239 commit a61d664

9 files changed

+38
-24
lines changed

tests/testthat/test-shinytest2-tm_a_regression.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ testthat::test_that("e2e - tm_a_regression: Data parameter and module label is p
5252
app_driver$expect_no_shiny_error()
5353

5454
testthat::expect_equal(
55-
app_driver$get_text("#teal-teal_modules-active_tab > li.active > a"),
55+
app_driver$get_text("#teal-teal_modules-active_tab .active"),
5656
"Regression"
5757
)
5858

tests/testthat/test-shinytest2-tm_data_table.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ test_that("e2e - tm_data_table: Initializes without errors", {
2727
app_driver$expect_no_shiny_error()
2828

2929
testthat::expect_equal(
30-
app_driver$get_text("#teal-teal_modules-active_tab > li.active > a"),
30+
app_driver$get_text("#teal-teal_modules-active_tab .active"),
3131
"Data Table"
3232
)
3333

tests/testthat/test-shinytest2-tm_file_viewer.R

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ test_that("e2e - tm_file_viewer: Initializes without errors and shows files tree
3434
)
3535

3636
testthat::expect_equal(
37-
app_driver$get_text("#teal-teal_modules-active_tab > li.active > a"),
37+
app_driver$get_text("#teal-teal_modules-active_tab .active"),
3838
"File Viewer Module"
3939
)
4040

@@ -46,7 +46,7 @@ test_that("e2e - tm_file_viewer: Shows selected image file", {
4646
app_driver <- app_driver_tm_file_viewer()
4747

4848
app_driver$click(selector = "[id= '4_anchor']")
49-
testthat::expect_true(app_driver$is_visible(selector = app_driver$active_module_element("output")))
49+
testthat::expect_true(app_driver$is_visible(sprintf("%s img", app_driver$active_module_element("output"))))
5050

5151
img_src <- app_driver$get_html_rvest(app_driver$active_module_element("output")) %>%
5252
rvest::html_element("img") %>%
@@ -62,7 +62,7 @@ test_that("e2e - tm_file_viewer: Shows selected text file", {
6262
app_driver <- app_driver_tm_file_viewer()
6363

6464
app_driver$click(selector = "[id= '5_anchor']")
65-
testthat::expect_true(app_driver$is_visible(selector = app_driver$active_module_element("output")))
65+
testthat::expect_true(app_driver$is_visible(sprintf("%s pre", app_driver$active_module_element("output"))))
6666

6767
pre_text <- app_driver$get_html_rvest(app_driver$active_module_element("output")) %>%
6868
rvest::html_element("pre") %>%
@@ -84,7 +84,7 @@ test_that("e2e - tm_file_viewer: Shows selected url", {
8484
app_driver <- app_driver_tm_file_viewer()
8585

8686
app_driver$click(selector = "[id= '6_anchor']")
87-
testthat::expect_true(app_driver$is_visible(selector = app_driver$active_module_element("output")))
87+
testthat::expect_true(app_driver$is_visible(sprintf("%s img", app_driver$active_module_element("output"))))
8888

8989
testthat::expect_equal(
9090
attr(app_driver$get_active_module_input("tree")$url, "ancestry"),

tests/testthat/test-shinytest2-tm_front_page.R

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ test_that("e2e - tm_front_page: Initializes without errors and check html elemen
2828
app_driver$expect_no_shiny_error()
2929

3030
testthat::expect_equal(
31-
app_driver$get_text("#teal-teal_modules-active_tab > li.active > a"),
31+
app_driver$get_text("#teal-teal_modules-active_tab .active"),
3232
"Front page"
3333
)
3434

@@ -50,10 +50,10 @@ test_that("e2e - tm_front_page: Verify the module displays tables", {
5050
app_driver <- app_driver_tm_front_page()
5151
# tables
5252
testthat::expect_match(app_driver$get_active_module_output("table_1"), "MTCARS")
53-
testthat::expect_true(app_driver$is_visible(selector = app_driver$active_module_element("table_1")))
53+
testthat::expect_true(app_driver$is_visible(sprintf("%s table", app_driver$active_module_element("table_1"))))
5454

5555
testthat::expect_match(app_driver$get_active_module_output("table_2"), "IRIS")
56-
testthat::expect_true(app_driver$is_visible(selector = app_driver$active_module_element("table_2")))
56+
testthat::expect_true(app_driver$is_visible(sprintf("%s table", app_driver$active_module_element("table_2"))))
5757
app_driver$stop()
5858
})
5959

@@ -63,7 +63,7 @@ test_that("e2e - tm_front_page: Verify the module displays metadata", {
6363

6464
# show metadata
6565
app_driver$click(NS(app_driver$active_module_ns(), "metadata_button"))
66-
testthat::expect_true(app_driver$is_visible(selector = app_driver$active_module_element("metadata_table")))
66+
testthat::expect_true(app_driver$is_visible(sprintf("%s table", app_driver$active_module_element("metadata_table"))))
6767

6868
app_driver$stop()
6969
})

tests/testthat/test-shinytest2-tm_g_scatterplotmatrix.R

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ test_that("e2e - tm_g_scatterplotmatrix: Initializes without errors", {
5151
app_driver$expect_no_shiny_error()
5252

5353
testthat::expect_equal(
54-
app_driver$get_text("#teal-teal_modules-active_tab > li.active > a"),
54+
app_driver$get_text("#teal-teal_modules-active_tab .active"),
5555
"Scatterplot matrix"
5656
)
5757

@@ -66,7 +66,9 @@ test_that("e2e - tm_g_scatterplotmatrix: Verify module displays data table", {
6666
app_driver <- app_driver_tm_g_scatterplotmatrix()
6767

6868
# table
69-
testthat::expect_true(app_driver$is_visible(selector = app_driver$active_module_element("myplot-plot_out_main")))
69+
testthat::expect_true(
70+
app_driver$is_visible(sprintf("%s .shiny-plot-output", app_driver$active_module_element("myplot-plot_out_main")))
71+
)
7072

7173
app_driver$stop()
7274
})

tests/testthat/test-shinytest2-tm_misssing_data.R

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ test_that("e2e - tm_missing_data: Initializes without errors", {
4242
app_driver$expect_no_shiny_error()
4343

4444
testthat::expect_equal(
45-
app_driver$get_text("#teal-teal_modules-active_tab > li.active > a"),
45+
app_driver$get_text("#teal-teal_modules-active_tab .active"),
4646
"Missing data"
4747
)
4848

@@ -78,7 +78,10 @@ test_that("e2e - tm_missing_data: Default settings and visibility of the summary
7878

7979
testthat::expect_true(
8080
app_driver$is_visible(
81-
app_driver$active_module_element("iris-summary_plot-plot_out_main")
81+
sprintf(
82+
"%s .shiny-plot-output",
83+
app_driver$active_module_element("iris-summary_plot-plot_out_main")
84+
)
8285
)
8386
)
8487

@@ -97,15 +100,21 @@ test_that("e2e - tm_missing_data: Check default settings and visibility of the c
97100
app_driver$expect_no_validation_error()
98101
testthat::expect_true(
99102
app_driver$is_visible(
100-
app_driver$active_module_element("iris-combination_plot-plot_out_main")
103+
sprintf(
104+
"%s .shiny-plot-output",
105+
app_driver$active_module_element("iris-combination_plot-plot_out_main")
106+
)
101107
)
102108
)
103109

104110
# combination encoding
105111

106112
testthat::expect_true(
107113
app_driver$is_visible(
108-
app_driver$active_module_element("iris-cutoff")
114+
sprintf(
115+
"%s .shiny-input-container",
116+
app_driver$active_module_element("iris-cutoff")
117+
)
109118
)
110119
)
111120

tests/testthat/test-shinytest2-tm_outliers.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ testthat::test_that("e2e - tm_outliers: Data parameter and module label is passe
5555
app_driver$expect_no_shiny_error()
5656

5757
testthat::expect_equal(
58-
app_driver$get_text("#teal-teal_modules-active_tab > li.active > a"),
58+
app_driver$get_text("#teal-teal_modules-active_tab .active"),
5959
"Outliers Module"
6060
)
6161

tests/testthat/test-shinytest2-tm_t_crosstable.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ test_that("e2e - tm_t_crosstable: Initializes without errors", {
5050
app_driver$expect_no_shiny_error()
5151

5252
testthat::expect_equal(
53-
app_driver$get_text("#teal-teal_modules-active_tab > li.active > a"),
53+
app_driver$get_text("#teal-teal_modules-active_tab .active"),
5454
"Cross Table"
5555
)
5656

tests/testthat/test-shinytest2-tm_variable_browser.R

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,18 @@ testthat::test_that("e2e - tm_variable_browser: content is displayed correctly."
3535

3636
# Test tab name
3737
testthat::expect_equal(
38-
trimws(app_driver$get_text("#teal-teal_modules-active_tab > li.active")),
38+
trimws(app_driver$get_text("#teal-teal_modules-active_tab .active")),
3939
"Variable browser (e2e)"
4040
)
4141

4242
# Plot is visible
4343
testthat::expect_true(
44-
app_driver$is_visible(app_driver$active_module_element("variable_plot-plot_out_main"))
44+
app_driver$is_visible(
45+
sprintf(
46+
"%s .shiny-plot-output",
47+
app_driver$active_module_element("variable_plot-plot_out_main")
48+
)
49+
)
4550
)
4651

4752
# All datanames are available on the left sidebar
@@ -68,7 +73,7 @@ testthat::test_that("e2e - tm_variable_browser: Selecting 'treat variable as fac
6873

6974
# Categorical type have levels table in main output
7075
current_var <- trimws(app_driver$get_text(
71-
sprintf("%s .nav li.active", app_driver$active_module_element("ui_variable_browser"))
76+
sprintf("%s li .active", app_driver$active_module_element("ui_variable_browser"))
7277
))
7378

7479
app_driver$set_active_module_input(
@@ -100,7 +105,7 @@ testthat::test_that("e2e - tm_variable_browser: selection of categorical variabl
100105

101106
# Categorical type have levels table in main output
102107
current_var <- trimws(app_driver$get_text(
103-
sprintf("%s .nav li.active", app_driver$active_module_element("ui_variable_browser"))
108+
sprintf("%s li .active", app_driver$active_module_element("ui_variable_browser"))
104109
))
105110

106111
categorical_selector <- app_driver$active_module_element(
@@ -195,8 +200,6 @@ testthat::test_that("e2e - tm_variable_browser: changing plot setting encodings
195200
app_driver <- app_driver_tm_variable_browser()
196201

197202
# Test changing plot settings
198-
testthat::expect_false(app_driver$is_visible(app_driver$active_module_element("ggplot_theme-selectized")))
199-
200203
app_driver$set_active_module_input("ggplot_theme", "bw")
201204
app_driver$expect_no_validation_error()
202205
app_driver$set_active_module_input("ggplot_theme", "light")

0 commit comments

Comments
 (0)