Skip to content

Commit

Permalink
Fix the e2e test failure in the integration tests (#751)
Browse files Browse the repository at this point in the history
The root cause of the issue was that the chromote browser was unable to
render the PDF file without a plugin with the following error in the
terminal:
```r
  ── Error ('test-shinytest2-tm_file_viewer.R:84:3'): e2e - tm_file_viewer: Shows selected url ──
  Error in `app_wait_for_idle(self, private, duration = duration, timeout = timeout)`: An error occurred while waiting for Shiny to be stable
  Backtrace:
      ▆
   1. └─app_driver$click(selector = "[id= '6_anchor']") at test-shinytest2-tm_file_viewer.R:84:3
   2.   └─self$wait_for_idle()
   3.     └─shinytest2:::app_wait_for_idle(self, private, duration = duration, timeout = timeout)
   4.       └─shinytest2:::app_abort(self, private, "An error occurred while waiting for Shiny to be stable")
   5.         └─rlang::abort(..., app = self, call = call)
```
**Note that this test is a bit flaky, I was only able to reproduce the
error a few times. Sometimes it passed without any error.**

To reproduce this issue you can try the following:
Please make sure you have the dev version of `teal`.
```r
app_driver <- teal:::TealAppDriver$new(
  data = teal.data::teal_data(iris = iris),
  modules = teal.modules.general::tm_file_viewer(
    input_path = list(
      url = "https://fda.gov/files/drugs/published/Portable-Document-Format-Specifications.pdf"
    )
  )
)

app_driver$open_url()
app_driver$view()
```

### The URL in the `app_driver$open_url()` works fine
<img width="1718" alt="Screenshot 2024-05-10 at 3 45 48 PM"
src="https://github.com/insightsengineering/teal.modules.general/assets/49812166/f4e559e8-a215-4fd7-a57d-8e6881b9244c">

### The URL in the `app_driver$view()` shows the error `Couldn't load
plugin.`
<img width="664" alt="Screenshot 2024-05-10 at 3 46 00 PM"
src="https://github.com/insightsengineering/teal.modules.general/assets/49812166/f2c4f37c-890c-4640-a05a-477804c14a68">

The fix is to use some other file format, here we use a `PNG` file to
fix this. In the future, we should test all the files and make sure they
work.
  • Loading branch information
vedhav authored May 16, 2024
1 parent 15e36c4 commit a99ce90
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
8 changes: 5 additions & 3 deletions tests/testthat/test-shinytest2-tm_file_viewer.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
nest_logo_url <- "https://raw.githubusercontent.com/insightsengineering/hex-stickers/main/PNG/nest.png"

app_driver_tm_file_viewer <- function() {
init_teal_app_driver(
data = simple_teal_data(),
Expand All @@ -7,7 +9,7 @@ app_driver_tm_file_viewer <- function() {
folder = system.file("sample_files", package = "teal.modules.general"),
png = system.file("sample_files/sample_file.png", package = "teal.modules.general"),
txt = system.file("sample_files/sample_file.txt", package = "teal.modules.general"),
url = "https://fda.gov/files/drugs/published/Portable-Document-Format-Specifications.pdf"
url = nest_logo_url
)
),
timeout = 3000
Expand Down Expand Up @@ -84,9 +86,9 @@ test_that("e2e - tm_file_viewer: Shows selected url", {
app_driver$click(selector = "[id= '6_anchor']")
testthat::expect_true(app_driver$is_visible(selector = app_driver$active_module_element("output")))

testthat::expect_match(
testthat::expect_equal(
attr(app_driver$get_active_module_input("tree")$url, "ancestry"),
"pdf$"
nest_logo_url
)

app_driver$stop()
Expand Down
1 change: 0 additions & 1 deletion tests/testthat/test-shinytest2-tm_misssing_data.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
app_driver_tm_missing_data <- function() {
data <- within(simple_teal_data(), {
set.seed(123)
require(nestcolor)

add_nas <- function(x) {
x[sample(seq_along(x), floor(length(x) * runif(1, .05, .17)))] <- NA
Expand Down

0 comments on commit a99ce90

Please sign in to comment.