Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into 1352_accept_function@…
Browse files Browse the repository at this point in the history
…main
  • Loading branch information
gogonzo committed Oct 25, 2024
2 parents 9fb1ddb + b3e607d commit 2528629
Show file tree
Hide file tree
Showing 4 changed files with 109 additions and 4 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Type: Package
Package: teal
Title: Exploratory Web Apps for Analyzing Clinical Trials Data
Version: 0.15.2.9074
Date: 2024-10-23
Version: 0.15.2.9075
Date: 2024-10-25
Authors@R: c(
person("Dawid", "Kaledkowski", , "[email protected]", role = c("aut", "cre"),
comment = c(ORCID = "0000-0001-9533-457X")),
Expand Down
2 changes: 1 addition & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# teal 0.15.2.9074
# teal 0.15.2.9075

### New features

Expand Down
2 changes: 1 addition & 1 deletion R/module_filter_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ srv_filter_data <- function(id, datasets, active_datanames, data_rv, is_active)
data,
paste0(
".raw_data <- list2env(list(",
toString(sprintf("%1$s = %1$s", datanames)),
toString(sprintf("%1$s = %1$s", sapply(datanames, as.name))),
"))\n",
"lockEnvironment(.raw_data) #@linksto .raw_data" # this is environment and it is shared by qenvs. CAN'T MODIFY!
)
Expand Down
105 changes: 105 additions & 0 deletions tests/testthat/test-module_teal.R
Original file line number Diff line number Diff line change
Expand Up @@ -2238,3 +2238,108 @@ testthat::describe("srv_teal snapshot manager", {
)
})
})

testthat::describe("Datanames with special symbols", {
testthat::it("are detected as datanames when defined as 'all'", {
shiny::testServer(
app = srv_teal,
args = list(
id = "test",
data = teal.data::teal_data(
iris = iris,
`%a_pipe%` = function(lhs, rhs) paste(lhs, rhs)
),
modules = modules(module("module_1", server = function(id, data) data)),
filter = teal_slices(
module_specific = TRUE
)
),
expr = {
session$setInputs("teal_modules-active_tab" = "module_1")
session$flushReact()

testthat::expect_setequal(
ls(
teal.code::get_env(modules_output$module_1()()),
all.names = TRUE
),
c(".raw_data", "iris", "%a_pipe%")
)
}
)
})

testthat::it("are present in datanames when used in pre-processing code", {
shiny::testServer(
app = srv_teal,
args = list(
id = "test",
data = within(
teal.data::teal_data(),
{
iris <- iris
mtcars <- mtcars
`_a variable with spaces_` <- "new_column" # nolint: object_name.
iris <- cbind(iris, data.frame(`_a variable with spaces_`))
}
),
modules = modules(
module("module_1", server = function(id, data) data, datanames = c("iris", "_a variable with spaces_"))
)
),
expr = {
session$setInputs("teal_modules-active_tab" = "module_1")
session$flushReact()
testthat::expect_setequal(
ls(
teal.code::get_env(modules_output$module_1()()),
all.names = TRUE
),
c(".raw_data", "iris", "_a variable with spaces_")
)
}
)
})

testthat::it("(when used as non-native pipe) are present in datanames in the pre-processing code", {
testthat::expect_warning(
shiny::testServer(
app = srv_teal,
args = list(
id = "test",
data = within(
teal.data::teal_data(),
{
iris <- iris
mtcars <- mtcars
`%cbind%` <- function(lhs, rhs) cbind(lhs, rhs)
iris <- iris %cbind% data.frame("new_column")
}
),
modules = modules(
module("module_1", server = function(id, data) data, , datanames = c("iris"))
),
filter = teal_slices(
module_specific = TRUE
)
),
expr = {
session$setInputs("teal_modules-active_tab" = "module_1")
session$flushReact()

testthat::expect_contains(
strsplit(
x = teal.code::get_code(modules_output$module_1()()),
split = "\n"
)[[1]],
c(
"`%cbind%` <- function(lhs, rhs) cbind(lhs, rhs)",
".raw_data <- list2env(list(iris = iris))"
)
)
}
),
"'package:teal' may not be available when loading"
)
})
})

0 comments on commit 2528629

Please sign in to comment.