Skip to content

Commit

Permalink
tests(313): Fix bslib full screen card selector (#193)
Browse files Browse the repository at this point in the history
  • Loading branch information
gadenbuie authored Jul 13, 2023
1 parent 9e1fc39 commit 85665a7
Showing 1 changed file with 22 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,20 @@ expect_focus <- function(app, selector) {
expect_card_full_screen <- function(app, id) {
id <- sub("^#", "", id)
app$wait_for_js('document.body.matches(".bslib-has-full-screen")')
# The expected card is expanded in full screen mode
expect_equal(
app$get_js('document.querySelector(".bslib-full-screen").id'),
id
app$get_js(sprintf(
"document.getElementById('%s').getAttribute('data-full-screen')",
id
)),
"true"
)
# Only one card is expanded to full screen
expect_equal(
app$get_js("document.querySelectorAll('.bslib-full-screen').length"),
app$get_js("document.querySelectorAll('.bslib-card[data-full-screen=\"true\"]').length"),
1
)
# The overlay (behind card and above UI) is present
expect_equal(
app$get_js("document.querySelectorAll('#bslib-full-screen-overlay').length"),
1
Expand All @@ -59,12 +65,22 @@ expect_card_full_screen <- function(app, id) {
invisible(app)
}

expect_no_full_screen <- function(app) {
expect_no_full_screen <- function(app, id = NULL) {
app$wait_for_js('!document.body.matches(".bslib-has-full-screen")')
expect_equal(
app$get_js("document.querySelectorAll('.bslib-full-screen').length"),
app$get_js("document.querySelectorAll('.bslib-card[data-full-screen=\"true\"]').length"),
0
)
if (is.null(id)) return(invisible(app))

expect_equal(
app$get_js(sprintf(
"document.getElementById('%s').getAttribute('data-full-screen')",
id
)),
"false"
)

invisible(app)
}

Expand Down Expand Up @@ -168,7 +184,7 @@ test_that("fullscreen card without internal focusable elements", {

# Exit full screen
key_press("Enter")
expect_no_full_screen(app)
expect_no_full_screen(app, id = "card-no-inputs")
})

# Test enter/exit methods ------------------------------------------
Expand Down

0 comments on commit 85665a7

Please sign in to comment.