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

712 - {shinytest2} for tm_data_table #719

Merged
merged 33 commits into from
Apr 19, 2024
Merged
Show file tree
Hide file tree
Changes from 30 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
4264cca
adding TealAppDriver
kartikeyakirar Apr 11, 2024
9e805e2
[skip roxygen] [skip vbump] Roxygen Man Pages Auto Update
dependabot-preview[bot] Apr 11, 2024
3e33485
adding shinytest2
kartikeyakirar Apr 11, 2024
451a653
Merge branch '712-tm_data_table@main' of https://github.com/insightse…
kartikeyakirar Apr 11, 2024
dd95925
removing the DT feature test
kartikeyakirar Apr 11, 2024
23213cf
update shinytest2
kartikeyakirar Apr 12, 2024
36a6911
[skip style] [skip vbump] Restyle files
github-actions[bot] Apr 12, 2024
abc0ff9
seperate the tests
kartikeyakirar Apr 12, 2024
4da17c1
Merge branch '712-tm_data_table@main' of https://github.com/insightse…
kartikeyakirar Apr 12, 2024
83e7104
removing the snaps
kartikeyakirar Apr 12, 2024
96a3dfe
fixing styling.
kartikeyakirar Apr 12, 2024
10d2106
removing modules call.
kartikeyakirar Apr 12, 2024
85674b1
Update tests/testthat/test-shinytest2-tm_data_table.R
kartikeyakirar Apr 16, 2024
e7c4228
@m7pr suggestions
kartikeyakirar Apr 16, 2024
138e591
Merge branch '712-tm_data_table@main' of https://github.com/insightse…
kartikeyakirar Apr 16, 2024
9146fc5
extending description
kartikeyakirar Apr 16, 2024
034c3cd
Update tests/testthat/test-shinytest2-tm_data_table.R
kartikeyakirar Apr 16, 2024
8b40bbf
[skip style] [skip vbump] Restyle files
github-actions[bot] Apr 16, 2024
6838330
Merge branch 'main' into 712-tm_data_table@main
averissimo Apr 17, 2024
9385e14
updated test description and adding test
kartikeyakirar Apr 17, 2024
2f6ad4e
Merge branch '712-tm_data_table@main' of https://github.com/insightse…
kartikeyakirar Apr 17, 2024
650fb12
fix: replace TealAppDriver with init_teal_app_driver
averissimo Apr 17, 2024
fa3e229
comparing displayed value.
kartikeyakirar Apr 19, 2024
e9b1985
[skip style] [skip vbump] Restyle files
github-actions[bot] Apr 19, 2024
d3d55b5
Merge branch 'main' into 712-tm_data_table@main
m7pr Apr 19, 2024
83e40bd
add tests for distinction
m7pr Apr 19, 2024
e4ad379
Update tests/testthat/test-shinytest2-tm_data_table.R
kartikeyakirar Apr 19, 2024
86bb86f
Merge branch 'main' into 712-tm_data_table@main
m7pr Apr 19, 2024
631c284
[skip style] [skip vbump] Restyle files
github-actions[bot] Apr 19, 2024
de55396
'trigger'
kartikeyakirar Apr 19, 2024
5aaf896
Update tests/testthat/test-shinytest2-tm_data_table.R
m7pr Apr 19, 2024
391902e
fixed the distinct value test
kartikeyakirar Apr 19, 2024
c76d5b7
Merge branch 'main' into 712-tm_data_table@main
kartikeyakirar Apr 19, 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
2 changes: 1 addition & 1 deletion R/tm_data_table.R
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
#' variables_selected = list(
#' iris = c("Sepal.Length", "Sepal.Width", "Petal.Length", "Petal.Width", "Species")
#' ),
#' dt_args = list(caption = "ADSL Table Caption")
#' dt_args = list(caption = "IRIS Table Caption")
#' )
#' )
#' )
Expand Down
2 changes: 1 addition & 1 deletion man/tm_data_table.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

97 changes: 97 additions & 0 deletions tests/testthat/test-shinytest2-tm_data_table.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
app_driver_tm_data_table <- function() {
init_teal_app_driver(
data = simple_teal_data(),
modules = tm_data_table(
label = "Data Table",
variables_selected = list(
iris = c("Sepal.Length", "Sepal.Width", "Petal.Length", "Petal.Width", "Species")
),
datasets_selected = c("iris", "mtcars"),
dt_args = list(caption = "Table Caption"),
dt_options = list(
searching = FALSE, pageLength = 30, lengthMenu = c(5, 15, 30, 100),
scrollX = TRUE
),
server_rendering = FALSE,
pre_output = NULL,
post_output = NULL
),
timeout = 3000
)
}

test_that("e2e - tm_data_table: Initializes without errors", {
skip_if_too_deep(5)
app_driver <- app_driver_tm_data_table()

app_driver$expect_no_shiny_error()

testthat::expect_equal(
app_driver$get_text("#teal-main_ui-root-active_tab > li.active > a"),
"Data Table"
)

app_driver$stop()
})

test_that("e2e - tm_data_table: Verify checkbox displayed over data table", {
skip_if_too_deep(5)
app_driver <- app_driver_tm_data_table()

testthat::expect_false(app_driver$get_active_module_input("if_distinct"))

app_driver$stop()
})

test_that("e2e - tm_data_table: Verify module displays data table", {
skip_if_too_deep(5)
app_driver <- app_driver_tm_data_table()

# table
testthat::expect_match(app_driver$get_active_module_output("iris-data_table"), "Table Caption")
testthat::expect_true(app_driver$is_visible(selector = app_driver$active_module_element("iris-data_table")))

extract_iris_table <- function() {
app_driver$active_module_element("iris-data_table") %>%
app_driver$get_html_rvest() %>%
rvest::html_table(fill = TRUE) %>%
.[[2]] %>%
dplyr::select(-1) %>%
data.frame()
}
# Non-distinct version.
iris_extracted <- extract_iris_table()
iris_subset <- iris %>%
dplyr::mutate(Species = as.character(Species)) %>%
dplyr::slice(1:30)
testthat::expect_equal(iris_extracted, iris_subset)

# Distinct version.
app_driver$set_active_module_input("if_distinct", TRUE)
iris_extracted_distinct <- extract_iris_table()
iris_subset_distinct <- iris_subset %>% mutate(n = 1)
kartikeyakirar marked this conversation as resolved.
Show resolved Hide resolved
testthat::expect_equal(iris_extracted_distinct, iris_subset_distinct)

app_driver$stop()
})

test_that("e2e - tm_data_table: Verify default variable selection and set new selection", {
skip_if_too_deep(5)
app_driver <- app_driver_tm_data_table()

# default variable selection
testthat::expect_equal(
app_driver$get_active_module_input("iris-variables"),
c("Sepal.Length", "Sepal.Width", "Petal.Length", "Petal.Width", "Species")
)

# new variable selection
app_driver$set_active_module_input("iris-variables", c("Petal.Width", "Species"))
app_driver$expect_no_validation_error()
testthat::expect_equal(
app_driver$get_active_module_input("iris-variables"),
c("Petal.Width", "Species")
)

app_driver$stop()
})
Loading