-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
125 additions
and
551 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 |
---|---|---|
|
@@ -31,7 +31,6 @@ Imports: | |
styler | ||
Suggests: | ||
knitr, | ||
lattice, | ||
magrittr, | ||
rmarkdown, | ||
shinytest2, | ||
|
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
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,24 @@ | ||
library(shiny) | ||
library(rtables) | ||
library(magrittr) | ||
library(teal.widgets) | ||
|
||
shinyApp( | ||
ui = fluidPage( | ||
table_with_settings_ui( | ||
id = "table_with_settings" | ||
) | ||
), | ||
server = function(input, output, session) { | ||
table_r <- reactive({ | ||
l <- basic_table() %>% | ||
split_cols_by("ARM") %>% | ||
analyze(c("SEX", "AGE")) | ||
|
||
tbl <- build_table(l, DM) | ||
|
||
tbl | ||
}) | ||
table_with_settings_srv(id = "table_with_settings", table_r = table_r) | ||
} | ||
) |
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 @@ | ||
shinytest2::test_app() |
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,12 @@ | ||
# {shinytest2} snapshotting inputs | ||
|
||
"\n \n \n A: Drug X\n B: Placebo\n C: Combination\n \n \n SEX\n \n \n \n \n \n F\n 70\n 56\n 61\n \n \n M\n 51\n 50\n 68\n \n \n U\n 0\n 0\n 0\n \n \n UNDIFFERENTIATED\n 0\n 0\n 0\n \n \n AGE\n \n \n \n \n \n Mean\n 34.91\n 33.02\n 34.57\n \n \n \n \n \n \n \n \n " | ||
|
||
# {shinytest2} txt csv download | ||
|
||
"tab1.csv" | ||
|
||
--- | ||
|
||
"tab2.txt" | ||
|
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,8 @@ | ||
"1","","A: Drug X","B: Placebo","C: Combination" | ||
"2","SEX","","","" | ||
"3","F","70","56","61" | ||
"4","M","51","50","68" | ||
"5","U","0","0","0" | ||
"6","UNDIFFERENTIATED","0","0","0" | ||
"7","AGE","","","" | ||
"8","Mean","34.91","33.02","34.57" |
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,9 @@ | ||
A: Drug X B: Placebo C: Combination | ||
———————————————————————————————————————————————————————————— | ||
SEX | ||
F 70 56 61 | ||
M 51 50 68 | ||
U 0 0 0 | ||
UNDIFFERENTIATED 0 0 0 | ||
AGE | ||
Mean 34.91 33.02 34.57 |
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,2 @@ | ||
# Load application support files into testing environment | ||
shinytest2::load_app_env() |
45 changes: 14 additions & 31 deletions
45
tests/testthat/test-tws.R → inst/tws/tests/testthat/test-shinytest2.R
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 |
---|---|---|
@@ -1,45 +1,28 @@ | ||
library(shinytest2) | ||
library(testthat) | ||
|
||
# launch app for all tests | ||
tws <- app_tws() | ||
app <- AppDriver$new(tws, name = "tws") | ||
|
||
# Testing snapshots | ||
testthat::test_that("file name and table content", { | ||
skip_on_cran() | ||
skip_on_ci() | ||
|
||
# default file name | ||
file_name <- app$get_value(input = "table_with_settings-downbutton-file_name") | ||
file_name <- sub("_\\d{6}$", "", file_name) | ||
expected_file_name <- paste0("table_", strftime(Sys.Date(), | ||
format = "%Y%m%d" | ||
)) | ||
testthat::expect_equal(file_name, expected_file_name) | ||
|
||
# check for table content | ||
app$expect_text("table") | ||
}) | ||
|
||
# downloading tables | ||
testthat::test_that("txt and csv download", { | ||
skip_on_cran() | ||
skip_on_ci() | ||
|
||
# download table in .csv | ||
test_that("{shinytest2} txt/csv download", { | ||
app <- AppDriver$new(name = "tws", height = 820, width = 1551) | ||
app$click("table_with_settings-downbutton-dwnl") | ||
app$set_inputs(`table_with_settings-downbutton-dwnl_state` = TRUE) | ||
app$set_inputs(`table_with_settings-downbutton-file_format` = ".csv") | ||
app$set_inputs(`table_with_settings-downbutton-dwnl_state` = FALSE) | ||
app$set_inputs(`table_with_settings-downbutton-file_name` = "tab1") | ||
app$expect_download("table_with_settings-downbutton-data_download") | ||
|
||
# download table in .txt | ||
app$set_inputs(`table_with_settings-downbutton-file_format` = ".txt") | ||
app$set_inputs(`table_with_settings-downbutton-dwnl_state` = TRUE) | ||
app$set_inputs(`table_with_settings-downbutton-file_name` = "tab2") | ||
app$expect_download("table_with_settings-downbutton-data_download") | ||
app$set_inputs(`table_with_settings-downbutton-dwnl_state` = FALSE) | ||
}) | ||
|
||
app$stop() | ||
test_that("{shinytest2} snapshotting inputs", { | ||
app <- AppDriver$new(name = "tws_filename") | ||
file_name <- app$get_value(input = "table_with_settings-downbutton-file_name") | ||
file_name <- sub("_\\d{6}$", "", file_name) | ||
expected_file_name <- paste0("table_", strftime(Sys.Date(), | ||
format = "%Y%m%d" | ||
)) | ||
testthat::expect_equal(file_name, expected_file_name) | ||
app$expect_text("table") | ||
app$stop() | ||
}) |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.