Conversation
Code Coverage SummaryDiff against mainResults for commit: 484ef4f Minimum allowed coverage is ♻️ This comment has been updated with latest results |
Unit Tests Summary 1 files 16 suites 1m 52s ⏱️ Results for commit 484ef4f. ♻️ This comment has been updated with latest results. |
Unit Test Performance Difference
Additional test case details
Results for commit 641d9b6 ♻️ This comment has been updated with latest results. |
There was a problem hiding this comment.
Looks good but I cannot really test on my computer for the moment (somehow still it doesn't show the output).
But I have 2 comments:
- Will it work with old version of R/shiny? It is not clear from the linked PR on shiny if this is back compatible or not.
- Could you add tests to make sure this works well in the future? Maybe raise this with the shiny maintainer that this broke compatibility with previous existing widgets...
testthat::test_that(
"e2e: teal.widgets::draggable_buckets: initializes without input",
{
skip_if_too_deep(5)
app_driver <- shinytest2::AppDriver$new(
app_driver_db(),
name = "db",
variant = "app_driver_db_ui"
)
values <- app_driver$get_values()
testthat::expect_true(is.null(unlist(values)))
testthat::expect_length(values$output, 0L)
app_driver$stop()
}
)
testthat::test_that(
"e2e: teal.widgets::draggable_buckets: moving element returns values",
{
skip_if_too_deep(5)
app_driver <- shinytest2::AppDriver$new(
app_driver_db(),
name = "db",
variant = "app_driver_db_ui"
)
# Move elements
app_driver$run_js("
const elementToMove = document.getElementById('id-draggable-1');
const targetBucket = document.querySelector(`.bucket[data-label='bucket1']`);
targetBucket.appendChild(elementToMove);
Shiny.onInputChange('id', updatedValue);
")
values <- app_driver$get_values()
testthat::expect_false(is.null(unlist(values)))
app_driver$stop()
}
)
They might need some tweaking as the second one failed locally but you get the idea.
|
Yes, it is backward compatible. I tested with both shiny version |
0eb9328 to
86dd85e
Compare
|
Restarting the computer fixed the issues with displaying the output. Please address add tests and I'll approve the PR. |
|
Hey @llrs-roche as I mentioned in the stand-up. There is no real way to test this with our current testing toolkit. I'm thinking of implementing this in |
|
I don't know what cypress is, it doesn't seem to be an R package. Is this testing suit you refer to? If we can't test the output once the element is moved, let's test at least that the elements are movable. const elementToMove = document.getElementById('iddraggable1');
const targetBucket = document.querySelector(`.bucket[data-label='bucket1']`);
targetBucket.appendChild(elementToMove);To test the output we could create the widget with an element in one of the buckets. Per documentation, something like this should work: app_driver_db <- function() {
ui <- bslib::page_fluid(
draggable_buckets("id", "Choices #1", c("a"), c(bucket1 = "b", bucket2 = NULL))
)
shiny::shinyApp(ui, function(input, output) {})
}Then we can test that "b" is returned as output for bucket1. |
|
I've added the tests as we spoke about. Although they only test the second half of the widget functionality. We can continue the e2e tests in |
llrs-roche
left a comment
There was a problem hiding this comment.
Thanks for adding the tests. Approving, but please make the scope of the 4th test more limited as it fails on my local machine (Perhaps my locales affect the order).
79d0ad4 to
484ef4f
Compare
Closes #308
The subscribe callback now expects an object with the priority after this PR rstudio/shiny#4211. So, if you update to
shiny v1.11.1thedraggable_bucketsdo not work (the init works, but since the subscribe is broken it does not update).In the future we can think about using
sortablepackage to replace a huge chunk of custom css/js code.