test_that("repeated-measures ANOVA audit returns a certificate", {
  skip_if_not_installed("afex")
  set.seed(3)
  dat <- expand.grid(
    rater = factor(seq_len(24)),
    criterion = factor(c("accuracy", "clarity")),
    model = factor(c("A", "B"))
  )
  dat$score <- rnorm(nrow(dat), 70, 8) + 3 * (dat$model == "B")

  out <- statwitness_repeated(
    data = dat,
    outcome = "score",
    id = "rater",
    within = c("criterion", "model"),
    focus = "criterion:model",
    audit_level = "core"
  )

  expect_s3_class(out, "statwitness_audit")
  expect_identical(out$model_type, "repeated_measures_anova")
  expect_true(any(out$tests$id == "rm_design_integrity"))
})
