-
-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
503 shinytest2 for
Show R code
modal (#1146)
Part of insightsengineering/coredev-tasks#503 --------- Signed-off-by: Marcin <[email protected]> Co-authored-by: André Veríssimo <[email protected]> Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
- Loading branch information
1 parent
d13a73e
commit ec8fbfc
Showing
1 changed file
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
testthat::test_that("e2e: teal app initializes with Show R Code modal", { | ||
app <- TealAppDriver$new( | ||
data = simple_teal_data(), | ||
modules = example_module(label = "Example Module") | ||
) | ||
app$wait_for_idle(timeout = default_idle_timeout) | ||
|
||
# Check if button exists. | ||
button_selector <- app$active_module_element("rcode-button") | ||
testthat::expect_equal( | ||
app$get_text(button_selector), | ||
"Show R code" | ||
) | ||
|
||
app$click(selector = button_selector) | ||
app$wait_for_idle(timeout = default_idle_timeout) | ||
|
||
# Check header and title content. | ||
testthat::expect_equal( | ||
app$get_text("#shiny-modal div.modal-header > h4"), | ||
"Example Code" | ||
) | ||
|
||
# There are two Dismiss buttons with similar id and the same label. | ||
testthat::expect_setequal( | ||
testthat::expect_length( | ||
app$get_text("#shiny-modal button[data-dismiss]"), | ||
2 | ||
), | ||
"Dismiss" | ||
) | ||
# Check for Copy buttons. | ||
testthat::expect_equal( | ||
app$active_module_element("rcode-copy_button1") %>% | ||
app$get_text(), | ||
"Copy to Clipboard" | ||
) | ||
testthat::expect_equal( | ||
app$active_module_element("rcode-copy_button2") %>% | ||
app$get_text(), | ||
"Copy to Clipboard" | ||
) | ||
|
||
# Check R code output. | ||
r_code <- | ||
app$active_module_element("rcode-verbatim_content") %>% | ||
app$get_text() | ||
|
||
testthat::expect_match(r_code, "# Add any code to install/load your NEST environment here", fixed = TRUE) | ||
testthat::expect_match(r_code, "library(teal.code)", fixed = TRUE) | ||
testthat::expect_match(r_code, "stopifnot(rlang::hash(", fixed = TRUE) | ||
|
||
app$stop() | ||
}) |