test_that("selectionplot errors on invalid longitrees object", {
  expect_error(
    selectionplot(list(), metric = "PE", nth = 1),
    "longitrees must be a longitrees object"
  )
})

test_that("selectionplot errors on invalid metric", {
  mock_wt <- structure(
    list(
      plottree = data.frame(rand = c(0.3, 0.5), loss = c(0.4, 0.6),
                            ari12 = c(0.2, 0.3), ari13 = c(0.3, 0.4),
                            ari23 = c(0.4, 0.5)),
      treenumber = data.frame(treenumber1 = c(1L, 1L), treenumber2 = c(2L, 2L),
                              treenumber3 = c(3L, 3L)),
      .meta = list(mins = 40L)
    ),
    class = "longitrees"
  )
  pdf(NULL)
  on.exit(dev.off(), add = TRUE)
  expect_error(
    selectionplot(mock_wt, metric = "INVALID", nth = 1),
    "metric must be 'PE' or 'ARI'"
  )
})
