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

shinytest2 tests #240

Merged
merged 54 commits into from
Apr 26, 2024
Merged
Show file tree
Hide file tree
Changes from 52 commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
aba6883
moving shinytest tests from teal
m7pr Apr 8, 2024
e5a9f0e
add helpers-testing-depth.R
m7pr Apr 8, 2024
11d12c8
table with settings tests
m7pr Apr 8, 2024
10053bf
tests for verbatim popup ui
m7pr Apr 8, 2024
d68cd42
add rvest to Suggests
m7pr Apr 8, 2024
793ee7e
rename files
m7pr Apr 10, 2024
32c0503
pass parameters to app_vpu
m7pr Apr 10, 2024
653b3f2
add class tests
m7pr Apr 10, 2024
a95a077
add screenshot test for verbatim popup
m7pr Apr 10, 2024
1bbfe5a
add wait_for_idle after clicks in tests
m7pr Apr 10, 2024
9ca9e3b
extend tests for plot_with_settings_ui
m7pr Apr 11, 2024
842f354
move ggplot_args shinytest from tmg
m7pr Apr 16, 2024
31e1c5b
test for panel_group and panel_item
m7pr Apr 16, 2024
4421e46
rename app to app_drivers
m7pr Apr 16, 2024
f6373f3
rename app to app_driver
m7pr Apr 17, 2024
119a624
tests for the second button for plots_with_settings
m7pr Apr 17, 2024
d984684
remove screenshot tests
m7pr Apr 17, 2024
a417a6a
[skip style] [skip vbump] Restyle files
github-actions[bot] Apr 17, 2024
f5f5ea9
Empty-Commit
m7pr Apr 18, 2024
9fe385a
fix few tests
m7pr Apr 18, 2024
8eac01e
cleanup tests for plot_with_settings
m7pr Apr 19, 2024
e221ac3
[skip style] [skip vbump] Restyle files
github-actions[bot] Apr 19, 2024
2719369
move driver for verbatim_popup
m7pr Apr 19, 2024
a07681f
add todo
m7pr Apr 19, 2024
f9aa044
merge
m7pr Apr 19, 2024
13e8eee
[skip style] [skip vbump] Restyle files
github-actions[bot] Apr 19, 2024
5ab09e5
move driver to respective files
m7pr Apr 19, 2024
013ecc4
Merge branch 'shinytest2@main' of https://github.com/insightsengineer…
m7pr Apr 19, 2024
2699aae
[skip style] [skip vbump] Restyle files
github-actions[bot] Apr 19, 2024
3355f46
cleanup table_with_settings shinytest2
m7pr Apr 19, 2024
ee3cdd9
Merge branch 'shinytest2@main' of https://github.com/insightsengineer…
m7pr Apr 19, 2024
128c6bb
[skip style] [skip vbump] Restyle files
github-actions[bot] Apr 19, 2024
252e68d
Empty-Commit
m7pr Apr 19, 2024
e368cb0
move plot set inputs to a new test
m7pr Apr 24, 2024
0d2bcd6
finish more advanced tests for plot_with_settings
m7pr Apr 24, 2024
fda4c3d
[skip style] [skip vbump] Restyle files
github-actions[bot] Apr 24, 2024
cff0c70
extend tests for table_with_settings for the ability to download
m7pr Apr 24, 2024
aca7873
Merge branch 'shinytest2@main' of https://github.com/insightsengineer…
m7pr Apr 24, 2024
2412a6a
cleanup
m7pr Apr 24, 2024
c4ce3c0
remove panel_group_ui tests
m7pr Apr 24, 2024
bcf5f76
fix plots with settings tests
m7pr Apr 24, 2024
5f3922e
comment out failing test
m7pr Apr 24, 2024
ed9323d
Update tests/testthat/test-verbatim_popup_ui.R
m7pr Apr 25, 2024
36ec7db
Update tests/testthat/test-table_with_settings_ui.R
m7pr Apr 25, 2024
6df6dd8
Update tests/testthat/test-table_with_settings_ui.R
m7pr Apr 25, 2024
f5d9a04
Update tests/testthat/test-table_with_settings_ui.R
m7pr Apr 25, 2024
35c28c3
Update tests/testthat/test-plot_with_settings_ui.R
m7pr Apr 25, 2024
9134ecf
Update tests/testthat/test-plot_with_settings_ui.R
m7pr Apr 25, 2024
aae61f1
Update tests/testthat/test-plot_with_settings_ui.R
m7pr Apr 25, 2024
83b9163
Update tests/testthat/test-plot_with_settings_ui.R
m7pr Apr 25, 2024
ae77876
lintr
m7pr Apr 25, 2024
c09bf88
divide one test into two
m7pr Apr 25, 2024
dd00eeb
lintr
m7pr Apr 26, 2024
c50115b
remove commented code
m7pr Apr 26, 2024
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
1 change: 1 addition & 0 deletions .github/workflows/check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ jobs:
additional-env-vars: |
_R_CHECK_CRAN_INCOMING_REMOTE_=false
NOT_CRAN=true
TESTING_DEPTH=5
m7pr marked this conversation as resolved.
Show resolved Hide resolved
additional-r-cmd-check-params: --as-cran
enforce-note-blocklist: true
note-blocklist: |
Expand Down
1 change: 1 addition & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ Suggests:
lattice (>= 0.18-4),
magrittr (>= 1.5),
png,
rvest,
shinytest2 (>= 0.2.0),
shinyvalidate,
testthat (>= 3.1.5),
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

This file was deleted.

51 changes: 51 additions & 0 deletions tests/testthat/helpers-testing-depth.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#' Returns testing depth set by session option or by environmental variable.
#'
#' @details Looks for the session option `TESTING_DEPTH` first.
#' If not set, takes the system environmental variable `TESTING_DEPTH`.
#' If neither is set, then returns 3 by default.
#' If the value of `TESTING_DEPTH` is not a numeric of length 1, then returns 3.
#'
#' @return `numeric(1)` the testing depth.
#'
get_testing_depth <- function() {
default_depth <- 3
depth <- getOption("TESTING_DEPTH", Sys.getenv("TESTING_DEPTH", default_depth))
depth <- tryCatch(
as.numeric(depth),
error = function(error) default_depth,
warning = function(warning) default_depth
)
if (length(depth) != 1) depth <- default_depth
depth
}

#' Skipping tests in the testthat pipeline under specific scope
#' @description This function should be used per each `testthat::test_that` call.
#' Each of the call should specify an appropriate depth value.
#' The depth value will set the appropriate scope so more/less time consuming tests could be recognized.
#' The environment variable `TESTING_DEPTH` is used for changing the scope of `testthat` pipeline.
#' `TESTING_DEPTH` interpretation for each possible value:
#' \itemize{
#' \item{0}{no tests at all}
#' \item{1}{fast - small scope - executed on every commit}
#' \item{3}{medium - medium scope - daily integration pipeline}
#' \item{5}{slow - all tests - daily package tests}
#' }
#' @param depth `numeric` the depth of the testing evaluation,
#' has opposite interpretation to environment variable `TESTING_DEPTH`.
#' So e.g. `0` means run it always and `5` means a heavy test which should be run rarely.
#' If the `depth` argument is larger than `TESTING_DEPTH` then the test is skipped.
#' @importFrom testthat skip
#' @return `NULL` or invoke an error produced by `testthat::skip`
#' @note By default `TESTING_DEPTH` is equal to 3 if there is no environment variable for it.
#' By default `depth` argument lower or equal to 3 will not be skipped because by default `TESTING_DEPTH`
#' is equal to 3. To skip <= 3 depth tests then the environment variable has to be lower than 3 respectively.
skip_if_too_deep <- function(depth) { # nolintr
checkmate::assert_numeric(depth, len = 1, lower = 0, upper = 5)
testing_depth <- get_testing_depth() # by default 3 if there are no env variable
if (testing_depth < depth) {
testthat::skip(paste("testing depth", testing_depth, "is below current testing specification", depth))
}
}

default_idle_timeout <- 20000
30 changes: 30 additions & 0 deletions tests/testthat/helpers-utils.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#' Function to check if a function has a side effect of drawing something
#' @param `function` function which possibly draws something.
#' @return `logical(1)` whether the function has a side effect of drawing a plot.
#' @note reference to https://stackoverflow.com/questions/74615694/check-if-a-function-draw-plot-something
#' @keywords internal
is_draw <- function(plot_fun) {
checkmate::assert_function(plot_fun)
grDevices::graphics.off() # close any current graphics devices
cdev <- grDevices::dev.cur()
plot_fun()
if (cdev != grDevices::dev.cur()) {
on.exit(grDevices::dev.off())
return(TRUE)
}
return(FALSE)
}


is_visible <- function(element, app_driver) {
any(
unlist(
app_driver$get_js(
sprintf(
"Array.from(document.querySelectorAll('%s')).map(el => el.checkVisibility())",
element
)
)
)
)
}
97 changes: 0 additions & 97 deletions tests/testthat/helpers-with-settings.R

This file was deleted.

Loading
Loading