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

Resolve todos #1410

Merged
merged 11 commits into from
Nov 22, 2024
6 changes: 0 additions & 6 deletions R/module_data_summary.R
Original file line number Diff line number Diff line change
Expand Up @@ -157,12 +157,6 @@ get_filter_overview_wrapper <- function(teal_data) {
datanames,
function(dataname) {
parent <- teal.data::parent(joinkeys, dataname)
# todo: what should we display for a parent dataset?
# - Obs and Subjects
# - Obs only
# - Subjects only
# todo (for later): summary table should be displayed in a way that child datasets
# are indented under their parent dataset to form a tree structure
subject_keys <- if (length(parent) > 0) {
names(joinkeys[dataname, parent])
} else {
Expand Down
1 change: 0 additions & 1 deletion R/module_filter_manager.R
Original file line number Diff line number Diff line change
Expand Up @@ -388,4 +388,3 @@ methods::setOldClass("reactivevalues")
}
)
)
# todo: prevent any teal_slices attribute except mapping
8 changes: 0 additions & 8 deletions R/module_nested_tabs.R
Original file line number Diff line number Diff line change
Expand Up @@ -319,14 +319,6 @@ srv_teal_module.teal_module <- function(id,
# When previewer is delayed, cards are bookmarked only if previewer has been initiated (visited).
module_out(.call_teal_module(modules, datasets, module_teal_data, reporter))
}

# todo: (feature request) add a ReporterCard to the reporter as an output from the teal_module
# how to determine if module returns a ReporterCard so that reportPreviewer is needed?
# Should we insertUI of the ReportPreviewer then?
# What about attr(module, "reportable") - similar to attr(module, "bookmarkable")
if ("report" %in% names(module_out)) {
# (reactively) add card to the reporter
}
})

module_out
Expand Down
1 change: 0 additions & 1 deletion R/module_snapshot_manager.R
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,6 @@ srv_snapshot_manager <- function(id, slices_global) {
s <- "Initial application state"
### Begin restore procedure. ###
snapshot <- snapshot_history()[[s]]
# todo: as.teal_slices looses module-mapping if is not global
snapshot_state <- as.teal_slices(snapshot)
slices_global$slices_set(snapshot_state)
removeModal()
Expand Down
1 change: 0 additions & 1 deletion R/module_teal.R
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,6 @@ srv_teal <- function(id, data, modules, filter = teal_slices()) {
data_load_status <- reactive({
if (inherits(data_pulled(), "teal_data")) {
"ok"
# todo: should we hide warnings on top for a data?
} else if (inherits(data, "teal_data_module")) {
"teal_data_module failed"
} else {
Expand Down
2 changes: 1 addition & 1 deletion R/module_transform_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ ui_transform_data <- function(id, transformers = list(), class = "well") {
function(name) {
data_mod <- transformers[[name]]
wrapper_id <- ns(sprintf("wrapper_%s", name))
div( # todo: accordion?
div(
# class .teal_validated changes the color of the boarder on error in ui_validate_reactive_teal_data
# For details see tealValidate.js file.
class = c(class, "teal_validated"),
Expand Down
33 changes: 33 additions & 0 deletions tests/testthat/test-module_teal.R
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,39 @@ testthat::describe("srv_teal teal_modules", {
)
})

testthat::it("receives data with code limited to lines needed only for datanames", {
shiny::testServer(
app = srv_teal,
args = list(
id = "test",
data = reactive(
within(teal_data(), {
n_iris <- 10
mtcars <- mtcars
iris <- head(iris, n_iris)
mtcars <- head(mtcars)
})
),
modules = modules(
module("module_1", server = function(id, data) data, datanames = c("iris"))
)
),
expr = {
session$setInputs(`teal_modules-active_tab` = "module_1")
testthat::expect_identical(
teal.code::get_code(modules_output$module_1()()),
paste(
"n_iris <- 10",
"iris <- head(iris, n_iris)",
"stopifnot(rlang::hash(iris) == \"3d48747b41945d02625fe9740bf8e98c\") # @linksto iris",
".raw_data <- list2env(list(iris = iris))\nlockEnvironment(.raw_data) # @linksto .raw_data",
sep = "\n"
)
)
}
)
})

testthat::describe("warnings on missing datanames", {
testthat::it("warns when dataname is not available", {
testthat::skip_if_not_installed("rvest")
Expand Down
11 changes: 0 additions & 11 deletions tests/testthat/test-rcode_utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,3 @@ testthat::test_that("get_rcode_libraries returns current session packages", {
)
)
})

testthat::test_that("get_datasets_code returns code only for specified datanames", {
# todo: need to use code dependency? Or test it later via public functions/modules
datasets <- teal.slice::init_filtered_data(
list(
IRIS = iris,
MTCARS = mtcars
)
)
testthat::expect_true(TRUE)
})
Loading