Files
shiny/tests/testthat/test-busy-indication.R
Carson Sievert 3d66940402 Add busy indication (#4040)
* First pass at a proper state machine for managing output progress state

* `yarn build` (GitHub Actions)

* Add useBusyIndicators(), spinnerOptions(), and pulseOptions()

* Bring in new spinner defaults

* Use an actual div instead of a pseudo-element since chromium can't be trusted to show them when animated

* Revert "Use an actual div instead of a pseudo-element since chromium can't be trusted to show them when animated"

This reverts commit 6167c1dfd7.

* Embed animation inside svg (to avoid Chromium bug). Consolidate options into a singular busyIndicatorOptions()

* Add to pkgdown reference

* `devtools::document()` (GitHub Actions)

* `yarn build` (GitHub Actions)

* Bump version

* `yarn build` (GitHub Actions)

* Sync package version (GitHub Actions)

* Apply suggestions from code review

Co-authored-by: Garrick Aden-Buie <garrick@adenbuie.com>

* Update snapshots

* `devtools::document()` (GitHub Actions)

* Address feedback

* Bring in more spinner type options

* fix use of fs

* Code review

* `devtools::document()` (GitHub Actions)

* Sync package version (GitHub Actions)

* Update snapshots

* Fix comments

* Make snapshot consistent cross-platform

* Fix namespace issue

* Reduce specificity of position relative

* Skip snapshot on windows; update news

* Whoops

* Scope spinner customizations to parent element by default

* Update snapshots

* Reorder spinner types

* Set a private random seed in tests

* Better id naming

---------

Co-authored-by: cpsievert <cpsievert@users.noreply.github.com>
Co-authored-by: Garrick Aden-Buie <garrick@adenbuie.com>
2024-05-10 14:58:43 -05:00

65 lines
1.9 KiB
R

test_that("useBusyIndicators()", {
expect_snapshot(
tagList(
useBusyIndicators(),
useBusyIndicators(spinners = FALSE),
useBusyIndicators(pulse = FALSE),
useBusyIndicators(spinners = FALSE, pulse = FALSE),
)
)
expect_error(useBusyIndicators("foo"))
expect_error(useBusyIndicators(foo = "bar"))
})
busy_indicator_options <- function(...) {
withPrivateSeed(set.seed(100))
busyIndicatorOptions(...)
}
test_that("busyIndicatorOptions()", {
expect_snapshot(
tagList(
busy_indicator_options(),
busy_indicator_options(spinner_type = "bars"),
busy_indicator_options(spinner_type = "pulse"),
busy_indicator_options(spinner_type = "dots"),
busy_indicator_options(spinner_color = "red"),
busy_indicator_options(spinner_size = "10px"),
busy_indicator_options(spinner_delay = "1s"),
busy_indicator_options(pulse_background = "blue"),
busy_indicator_options(pulse_height = "10px"),
busy_indicator_options(pulse_speed = "1s"),
busy_indicator_options(
spinner_color = "red",
spinner_size = "10px",
spinner_delay = "1s",
pulse_background = "blue",
pulse_height = "10px",
pulse_speed = "1s"
)
)
)
expect_error(busy_indicator_options("foo"))
expect_error(busy_indicator_options(foo = "bar"))
expect_error(busy_indicator_options(spinner_type = "dsflds"))
expect_error(busy_indicator_options(spinner_color = "dsflds"))
expect_error(busy_indicator_options(spinner_size = "dsflds"))
expect_error(busy_indicator_options(pulse_height = "dsflds"))
})
test_that("Can provide svg file for busyIndicatorOptions(spinner_type)", {
skip_if(.Platform$OS.type == "windows")
tmpsvg <- tempfile(fileext = ".svg")
writeLines("<svg></svg>", tmpsvg)
on.exit(unlink(tmpsvg))
expect_snapshot(
busy_indicator_options(spinner_type = tmpsvg)
)
})