Skip to content

Commit

Permalink
working tables
Browse files Browse the repository at this point in the history
  • Loading branch information
azimov committed Jul 27, 2023
1 parent d7eb235 commit 742809b
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 78 deletions.
5 changes: 3 additions & 2 deletions R/components-largeTableViewer.R
Original file line number Diff line number Diff line change
Expand Up @@ -266,8 +266,9 @@ largeTableServer <- function(id,
}

minNum <- format(((pageNum() - 1) * pageSize()) + 1, big.mark = ",", scientific = FALSE)
maxNum <- format((pageNum() - 1) * pageSize() + pageSize(), big.mark = ",", scientific = FALSE)
return(paste(minNum, "-", min(maxNum, rc), "of", rc, "rows"))
maxNum <- min((pageNum() - 1) * pageSize() + pageSize(), rowCount())
maxNum <- format(maxNum, big.mark = ",", scientific = FALSE)
return(paste(minNum, "-", maxNum, "of", rc, "rows"))
})

dataPage <- shiny::reactive({
Expand Down
51 changes: 0 additions & 51 deletions testApp.R

This file was deleted.

1 change: 0 additions & 1 deletion tests/testthat/test-cohort-diagnostics-characterization.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ shiny::testServer(characterizationModule, args = list(
generateRaw = 1,
generateReport = 1,
characterizationDomainIdFilter = domainIdOptions,
characterizationAnalysisNameFilter = analysisNameOptions,
timeIdChoices = tids$temporalChoices,
characterizationColumnFilters = "Mean"
)
Expand Down
48 changes: 24 additions & 24 deletions tests/testthat/test-components-largeTableViewer.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ test_that("Large Data Table R6 Class works", {
expect_equal(ldt$getPage(2, 10, min_row = 1) %>% nrow(), 10)
expect_error(LargeDataTable$new(ch, "SELECT 1; SELECT 2;"))
expect_error(LargeDataTable$new(ch, query, "SELECT 1; SELECT 2;"))
expect_error(LargeDataTable$new(ch, query))

ldt2 <- LargeDataTable$new(ch, query, countQuery = NULL)
checkmate::expect_string(ldt2$countQuery)
Expand All @@ -40,35 +39,36 @@ test_that("Large Data Table R6 Class works", {
df %>% dplyr::mutate(fizzBuzz = ifelse(.data$rowId %% 3 == 0, "fizz", "buzz"))
},
columns = list(row_id = reactable::colDef("row id")
),
expr = {
)
),
expr = {

session$setInputs(pageSize = 10)
session$setInputs(pageSize = 10)

expect_equal(rowCount(), ldt$getCount(min_row = 1))
expect_equal(pageNum(), 1)
expect_equal(pageCount(), ceiling(ldt$getCount(min_row = 1) / 10))
expect_equal(rowCount(), ldt$getCount(min_row = 1))
expect_equal(pageNum(), 1)
expect_equal(pageCount(), ceiling(ldt$getCount(min_row = 1) / 10))


session$setInputs(pageSize = 100)
expect_equal(pageNum(), 1)
expect_equal(pageCount(), ceiling(ldt$getCount(min_row = 1) / 100))
session$setInputs(pageSize = 100)
expect_equal(pageNum(), 1)
expect_equal(pageCount(), ceiling(ldt$getCount(min_row = 1) / 100))

session$setInputs(pageNum = 5)
expect_equal(pageNum(), 5)
expect_equal(output$pageNumber, "401 - 500 of 1,000,000 rows")
session$setInputs(pageNum = 5)
expect_equal(pageNum(), 5)
expect_equal(output$pageNumber, "401 - 500 of 1,000,000 rows")

checkmate::expect_data_frame(dataPage(), nrow = 100, ncols = 3)
checkmate::expect_names(colnames(dataPage()), must.include = c("rowId", "value", "fizzBuzz"))
expect_true(all(dataPage()$fizzBuzz == ifelse(dataPage()$rowId %% 3 == 0, "fizz", "buzz")))
checkmate::expect_data_frame(dataPage(), nrow = 100, ncols = 3)
checkmate::expect_names(colnames(dataPage()), must.include = c("rowId", "value", "fizzBuzz"))
expect_true(all(dataPage()$fizzBuzz == ifelse(dataPage()$rowId %% 3 == 0, "fizz", "buzz")))

checkmate::expect_class(output$tableView, "json")
checkmate::expect_class(output$pageActionButtons, "list")
checkmate::expect_class(output$tableView, "json")
checkmate::expect_class(output$pageActionButtons, "list")

session$setInputs(pageSize = 1e6)
expect_equal(pageCount(), 1)
checkmate::expect_class(output$pageActionButtons, "list")
checkmate::expect_file_exists(output$downloadFull)
}
)
session$setInputs(pageSize = 1e6)
expect_equal(pageCount(), 1)
checkmate::expect_class(output$pageActionButtons, "list")
checkmate::expect_file_exists(output$downloadFull)
}
)
})

0 comments on commit 742809b

Please sign in to comment.