{#- Setup fixture helper functions for R e2e tests #}

# Resolve fixture paths against the repo's `test_documents/` directory.
# testthat sources setup-*.R with the working directory at tests/,
# so test_documents lives three directories up: tests/ -> e2e/r/ -> e2e/ -> repo root.
# Each `test_that()` block has its working directory reset back to tests/, so
# fixture lookups must be performed via this helper rather than relying on `setwd`.
.alef_test_documents <- normalizePath("../../../test_documents", mustWork = FALSE)
.resolve_fixture <- function(path) {
  if (dir.exists(.alef_test_documents)) {
    file.path(.alef_test_documents, path)
  } else {
    path
  }
}
