Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
24 changes: 9 additions & 15 deletions inst/shiny/tests/testthat/test-edge-cases.R
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,14 @@ test_that("app does not crash when accessed before uploading Seurat file", {
# ── Bug 1: corrMat double transpose — compound dropdown must show drug names ──

test_that("corrMat upload shows drug names in compound dropdown, not cell barcodes", {
skip_if_not(
file.exists(test_path("fixtures/downsampled_seuratObj.RDS")),
"Seurat fixture not available (requires Git LFS)"
)
fixture <- normalizePath(test_path("fixtures/downsampled_seuratObj.RDS"), mustWork = FALSE)
skip_if_not(file.exists(fixture), "Seurat fixture not available (requires Git LFS)")
drug_names <- c("DrugA", "DrugB", "DrugC")
corr_mat_path <- make_corr_mat_csv(drug_names)

app <- make_app("corr-mat-orientation")

app$upload_file(seurobjRDS = test_path("fixtures/downsampled_seuratObj.RDS"))
app$upload_file(seurobjRDS = fixture)
app$wait_for_value(output = "seuratLoaded", timeout = 30000)

app$set_inputs(uploadCorrelationMatrix = TRUE)
Expand Down Expand Up @@ -96,10 +94,8 @@ test_that("corrMat upload shows drug names in compound dropdown, not cell barcod
# ── Bug 2: duplicate uiOutput — compound dropdown must not be empty ───────────

test_that("reference compound dropdown is populated after corrMat upload", {
skip_if_not(
file.exists(test_path("fixtures/downsampled_seuratObj.RDS")),
"Seurat fixture not available (requires Git LFS)"
)
fixture <- normalizePath(test_path("fixtures/downsampled_seuratObj.RDS"), mustWork = FALSE)
skip_if_not(file.exists(fixture), "Seurat fixture not available (requires Git LFS)")
# uiOutput('referenceCompound_ui') appears in two tabs in ui.R.
# When the same output ID is bound twice, the second binding can
# overwrite the first, leaving one tab's dropdown empty.
Expand All @@ -108,7 +104,7 @@ test_that("reference compound dropdown is populated after corrMat upload", {

app <- make_app("duplicate-ui-output")

app$upload_file(seurobjRDS = test_path("fixtures/downsampled_seuratObj.RDS"))
app$upload_file(seurobjRDS = fixture)
app$wait_for_value(output = "seuratLoaded", timeout = 30000)

app$set_inputs(uploadCorrelationMatrix = TRUE)
Expand Down Expand Up @@ -136,10 +132,8 @@ test_that("reference compound dropdown is populated after corrMat upload", {
# ── Bug 5: lowercase gene names in custom drug signature should not crash ─────

test_that("custom drug signature with lowercase gene names does not crash app", {
skip_if_not(
file.exists(test_path("fixtures/downsampled_seuratObj.RDS")),
"Seurat fixture not available (requires Git LFS)"
)
fixture <- normalizePath(test_path("fixtures/downsampled_seuratObj.RDS"), mustWork = FALSE)
skip_if_not(file.exists(fixture), "Seurat fixture not available (requires Git LFS)")
# If gene names in the uploaded CSV are lowercase (e.g. tp53) but the
# Seurat object uses uppercase (TP53), overlap detection returns 0 and
# the server calls stop(), crashing the reactive chain silently.
Expand All @@ -148,7 +142,7 @@ test_that("custom drug signature with lowercase gene names does not crash app",

app <- make_app("gene-case-mismatch")

app$upload_file(seurobjRDS = test_path("fixtures/downsampled_seuratObj.RDS"))
app$upload_file(seurobjRDS = fixture)
app$wait_for_value(output = "seuratLoaded", timeout = 30000)

app$set_inputs(L1000_Release = "Custom Upload")
Expand Down
13 changes: 7 additions & 6 deletions inst/shiny/tests/testthat/test-upload.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,21 @@ test_that("app loads without errors", {
})

test_that("uploading a valid Seurat RDS shows success message", {
skip_if_not(
file.exists(test_path("fixtures/downsampled_seuratObj.RDS")),
"Seurat fixture not available (requires Git LFS)"
# Resolve to absolute path NOW, before AppDriver can change the working dir
fixture <- normalizePath(
test_path("fixtures/downsampled_seuratObj.RDS"),
mustWork = FALSE
)
skip_if_not(file.exists(fixture), "Seurat fixture not available (requires Git LFS)")

app <- AppDriver$new(
app_dir = system.file("shiny", package = "scFOCAL"),
name = "seurat-upload",
load_timeout = 120000,
timeout = 120000
)

app$upload_file(
seurobjRDS = test_path("fixtures/downsampled_seuratObj.RDS")
)
app$upload_file(seurobjRDS = fixture)

# Wait for seuratLoaded to be TRUE. Ignore NULL (pre-upload) and any
# transient FALSE that may arrive while the 134 MB file is being read.
Expand Down
Loading