Skip to content

Commit ed17c6b

Browse files
committed
Update code based on #927
1 parent 949a35b commit ed17c6b

File tree

1 file changed

+11
-32
lines changed

1 file changed

+11
-32
lines changed

tests/testthat/test-shinytest2-tm_missing_data.R

Lines changed: 11 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -38,30 +38,20 @@ app_driver_tm_missing_data <- function() {
3838
}
3939

4040
test_that("e2e - tm_missing_data: Initializes without errors", {
41-
4241
skip_if_too_deep(5)
4342
app_driver <- app_driver_tm_missing_data()
4443

4544
app_driver$expect_no_shiny_error()
45+
testthat::expect_equal(app_driver$get_text(".teal-modules-tree .active"), "Missing data")
4646

47-
48-
testthat::expect_equal(
49-
app_driver$get_text(selector = "#teal-teal_modules-active_module_id > div.dropdown.nav-item-custom > div > ul > li > ul > li > a"),
50-
"Missing data"
51-
)
52-
53-
encoding_dataset <- app_driver$get_text(
54-
app_driver$active_module_element("dataset_encodings .help-block")
55-
)
56-
47+
encoding_dataset <- app_driver$get_text(paste(app_driver$namespaces(TRUE)$wrapper(NULL), ".help-block"))
5748
testthat::expect_match(encoding_dataset, "Datasets.*iris.*mtcars", all = FALSE)
5849

5950

6051
app_driver$stop()
6152
})
6253

6354
test_that("e2e - tm_missing_data: Default settings and visibility of the summary graph", {
64-
6555
skip_if_too_deep(5)
6656
app_driver <- app_driver_tm_missing_data()
6757
# default summary tab
@@ -75,26 +65,22 @@ test_that("e2e - tm_missing_data: Default settings and visibility of the summary
7565
c("Petal.Length", "Sepal.Length", "Petal.Width", "Species", "Sepal.Width")
7666
)
7767

78-
app_driver$click(selector = app_driver$active_module_element("iris-filter_na"))
68+
app_driver$click(selector = app_driver$namespaces(TRUE)$module("iris-filter_na"))
7969
app_driver$expect_no_validation_error()
8070

81-
app_driver$click(selector = app_driver$active_module_element("iris-any_na"))
71+
app_driver$click(selector = app_driver$namespaces(TRUE)$module("iris-any_na"))
8272
app_driver$expect_no_validation_error()
8373

8474
testthat::expect_true(
8575
app_driver$is_visible(
86-
sprintf(
87-
"%s .shiny-plot-output",
88-
app_driver$active_module_element("iris-summary_plot-plot_out_main")
89-
)
76+
app_driver$namespaces(TRUE)$module("iris-summary_plot-plot_out_main .shiny-plot-output")
9077
)
9178
)
9279

9380
app_driver$stop()
9481
})
9582

9683
test_that("e2e - tm_missing_data: Check default settings and visibility of the combinations graph and encodings", {
97-
9884
skip_if_too_deep(5)
9985
app_driver <- app_driver_tm_missing_data()
10086

@@ -106,33 +92,27 @@ test_that("e2e - tm_missing_data: Check default settings and visibility of the c
10692
app_driver$expect_no_validation_error()
10793
testthat::expect_true(
10894
app_driver$is_visible(
109-
sprintf(
110-
"%s .shiny-plot-output",
111-
app_driver$active_module_element("iris-combination_plot-plot_out_main")
112-
)
95+
app_driver$namespaces(TRUE)$module("iris-combination_plot-plot_out_main .shiny-plot-output")
11396
)
11497
)
11598

11699
# combination encoding
117100

118101
testthat::expect_true(
119102
app_driver$is_visible(
120-
sprintf(
121-
"%s .shiny-input-container",
122-
app_driver$active_module_element("iris-cutoff")
123-
)
103+
app_driver$namespaces(TRUE)$module("iris-cutoff .shiny-input-container")
124104
)
125105
)
126106

127-
testthat::expect_equal(app_driver$get_active_module_input("iris-combination_cutoff"), 2L)
107+
testthat::expect_equal(app_driver$get_active_module_input("iris-combination_cutoff"), 1L)
128108
app_driver$set_active_module_input("iris-combination_cutoff", 10L)
109+
testthat::expect_equal(app_driver$get_active_module_input("iris-combination_cutoff"), 10L)
129110
app_driver$expect_no_validation_error()
130111

131112
app_driver$stop()
132113
})
133114

134115
test_that("e2e - tm_missing_data: Validate functionality and UI response for 'By Variable Levels'", {
135-
136116
skip_if_too_deep(5)
137117
app_driver <- app_driver_tm_missing_data()
138118
# By variable levels
@@ -157,18 +137,17 @@ test_that("e2e - tm_missing_data: Validate functionality and UI response for 'By
157137
"counts"
158138
)
159139
app_driver$set_active_module_input("iris-count_type", "proportions")
160-
testthat::expect_true(app_driver$is_visible(app_driver$active_module_element("iris-levels_table")))
140+
testthat::expect_true(app_driver$is_visible(app_driver$namespaces(TRUE)$module("iris-levels_table")))
161141

162142
app_driver$stop()
163143
})
164144

165145
test_that("e2e - tm_missing_data: Validate 'By Variable Levels' table values", {
166-
167146
skip_if_too_deep(5)
168147
app_driver <- app_driver_tm_missing_data()
169148

170149
app_driver$set_active_module_input("iris-summary_type", "By Variable Levels")
171-
levels_table <- app_driver$active_module_element("iris-levels_table") %>%
150+
levels_table <- app_driver$namespaces(TRUE)$module("iris-levels_table") %>%
172151
app_driver$get_html_rvest() %>%
173152
rvest::html_table(fill = TRUE) %>%
174153
.[[1]]

0 commit comments

Comments
 (0)