Skip to content

Commit

Permalink
Merge branch '503-introduce-shinytest2@main' into tdm@503-introduce-s…
Browse files Browse the repository at this point in the history
…hinytest2@main
  • Loading branch information
averissimo authored Mar 13, 2024
2 parents e44216d + 9c9d903 commit 2f27c69
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 1 deletion.
3 changes: 2 additions & 1 deletion R/TealAppDriver.R
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,9 @@ TealAppDriver <- R6::R6Class( # nolint
#' @return The `TealAppDriver` object invisibly.
navigate_teal_tab = function(tabs) {
for (tab in tabs) {
root <- "root"
self$set_input(
sprintf("teal-main_ui-%s-active_tab", private$modules$label),
sprintf("teal-main_ui-%s-active_tab", root),
get_unique_labels(tab),
wait_ = FALSE
)
Expand Down
44 changes: 44 additions & 0 deletions tests/testthat/test-shinytest2-reporter.R
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,47 @@ testthat::test_that("e2e: reporter tab is only created when a module has reporte
app_without_reporter$stop()
app_with_reporter$stop()
})

testthat::test_that("e2e: adding a report card in a module adds it in the report previewer tab", {
app <- TealAppDriver$new(
data = simple_teal_data(),
modules = report_module(label = "Module with Reporter")
)
app$wait_for_idle(timeout = default_idle_timeout)

app$click(NS(app$active_module_ns(), "reporter-add_report_card_simple-add_report_card_button"))
app$wait_for_idle(timeout = default_idle_timeout)

app$set_input(
NS(app$active_module_ns(), "reporter-add_report_card_simple-label"),
"Card name"
)
app$set_input(
NS(app$active_module_ns(), "reporter-add_report_card_simple-label"),
"Card name"
)
app$set_input(
NS(app$active_module_ns(), "reporter-add_report_card_simple-comment"),
"Card comment"
)

app$click(NS(app$active_module_ns(), "reporter-add_report_card_simple-add_card_ok"))

app$navigate_teal_tab("Report previewer")

accordian_selector <- sprintf("#%s-pcards .accordion-toggle", app$active_module_ns())
app$click(selector = accordian_selector)


testthat::expect_match(
app$get_text(selector = accordian_selector),
"Card 1: Card name"
)

testthat::expect_match(
app$get_text(selector = "#card1 pre"),
"Card comment"
)

app$stop()
})

0 comments on commit 2f27c69

Please sign in to comment.