Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes integration tests when Chrome >=105 is not installed #1202

Merged
merged 15 commits into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions R/TealAppDriver.R
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,33 @@ TealAppDriver <- R6::R6Class( # nolint: object_name.
)
)

# Check for minimum version of Chrome that supports the tests
# - Element.checkVisibility was added on 105
chrome_version <- numeric_version(
gsub(
"[[:alnum:]_]+/", # Prefix that ends with forward slash
"",
self$get_chromote_session()$Browser$getVersion()$product
),
strict = FALSE
)

required_version <- 105

testthat::skip_if(
is.na(chrome_version),
"Problem getting Chrome version, please contact the developers."
)
testthat::skip_if(
chrome_version < required_version,
sprintf(
"Chrome version '%s' is not supported, please upgrade to '%d' or higher",
chrome_version,
required_version
)
)
# end od check

private$set_active_ns()
self$wait_for_idle()
},
Expand Down Expand Up @@ -249,6 +276,7 @@ TealAppDriver <- R6::R6Class( # nolint: object_name.
self$active_filters_ns()
)
)

available_datasets[displayed_datasets_index]
},
#' @description
Expand All @@ -267,6 +295,12 @@ TealAppDriver <- R6::R6Class( # nolint: object_name.
checkmate::assert_flag(content_visibility_auto)
checkmate::assert_flag(opacity_property)
checkmate::assert_flag(visibility_property)

testthat::skip_if_not(
app$get_js("typeof Element.prototype.checkVisibility === 'function'"),
"Element.prototype.checkVisibility is not supported in the current browser."
)

unlist(
self$get_js(
sprintf(
Expand Down
14 changes: 4 additions & 10 deletions tests/testthat/test-shinytest2-filter_panel.R
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ testthat::test_that("e2e: filtering a module-specific filter is refected in othe
)
)

expect_equal(
testthat::expect_setequal(
app$get_active_data_filters("iris")$Species,
c("setosa", "versicolor", "virginica")
)
Expand All @@ -56,7 +56,7 @@ testthat::test_that("e2e: filtering a module-specific filter is refected in othe

app$navigate_teal_tab("Module_1")

expect_equal(
testthat::expect_equal(
app$get_active_data_filters("iris")$Species,
c("setosa")
)
Expand Down Expand Up @@ -84,21 +84,15 @@ testthat::test_that("e2e: filtering a module-specific filter is not refected in
)
)

expect_equal(
app$get_active_data_filters("mtcars")$cyl,
c("4", "6")
)
testthat::expect_setequal(app$get_active_data_filters("mtcars")$cyl, c("4", "6"))

app$navigate_teal_tab("Module_2")

app$set_active_filter_selection("mtcars", "cyl", c("4"))

app$navigate_teal_tab("Module_1")

expect_equal(
app$get_active_data_filters("mtcars")$cyl,
c("4", "6")
)
testthat::expect_setequal(app$get_active_data_filters("mtcars")$cyl, c("4", "6"))

app$stop()
})
30 changes: 15 additions & 15 deletions tests/testthat/test-shinytest2-teal_slices.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,27 @@ testthat::test_that("e2e: teal_slices filters are initialized when global filter
)
)

testthat::expect_identical(
testthat::expect_setequal(
names(app$get_active_data_filters("iris")),
"Species"
)
testthat::expect_identical(
testthat::expect_setequal(
names(app$get_active_data_filters("mtcars")),
c("cyl", "drat", "gear")
)
testthat::expect_identical(
testthat::expect_setequal(
app$get_active_data_filters("iris")$Species,
c("setosa", "versicolor", "virginica")
)
testthat::expect_identical(
testthat::expect_setequal(
app$get_active_data_filters("mtcars")$cyl,
c("4", "6")
)
testthat::expect_identical(
testthat::expect_setequal(
app$get_active_data_filters("mtcars")$drat,
c(3, 4)
)
testthat::expect_identical(
testthat::expect_setequal(
app$get_active_data_filters("mtcars")$gear,
c("3", "4", "5")
)
Expand Down Expand Up @@ -62,19 +62,19 @@ testthat::test_that("e2e: teal_slices filters are initialized when module specif
)
)

testthat::expect_identical(
testthat::expect_setequal(
names(app$get_active_data_filters("iris")),
"Species"
)
testthat::expect_identical(
testthat::expect_setequal(
names(app$get_active_data_filters("mtcars")),
"cyl"
)
testthat::expect_identical(
testthat::expect_setequal(
app$get_active_data_filters("iris")$Species,
c("setosa", "versicolor", "virginica")
)
testthat::expect_identical(
testthat::expect_setequal(
app$get_active_data_filters("mtcars")$cyl,
c("4", "6")
)
Expand All @@ -84,23 +84,23 @@ testthat::test_that("e2e: teal_slices filters are initialized when module specif

app$navigate_teal_tab("Module_2")

testthat::expect_identical(
testthat::expect_setequal(
names(app$get_active_data_filters("iris")),
"Species"
)
testthat::expect_identical(
testthat::expect_setequal(
names(app$get_active_data_filters("mtcars")),
c("drat", "gear")
)
testthat::expect_identical(
testthat::expect_setequal(
app$get_active_data_filters("iris")$Species,
c("setosa", "versicolor", "virginica")
)
testthat::expect_identical(
testthat::expect_setequal(
app$get_active_data_filters("mtcars")$drat,
c(3, 4)
)
testthat::expect_identical(
testthat::expect_setequal(
app$get_active_data_filters("mtcars")$gear,
c("3", "4", "5")
)
Expand Down
Loading