"CPAs under the same RNG state are identical"
"Piecemeal and wholesale CPAs are identical"

#' @srrstats {G5.3} Tests for correctness but no explicit test for NA
#' @srrstats {G5.4} Tests compare to R `lm()` output.
spec_lm <- make_jlmer_spec(weight ~ 1 + Diet, ChickWeight)
jlm1 <- to_jlmer(weight ~ 1 + Diet, ChickWeight)
#' @srrstats {RE7.3} Tests for `print()`, `tidy()`, and `glance()`
test_that("direct and indirect fits identical", {
spec_lme <- make_jlmer_spec(weight ~ 1 + Diet + (1 | Chick), ChickWeight)
jlme1 <- to_jlmer(weight ~ 1 + Diet + (1 | Chick), ChickWeight)
test_that("direct and indirect fits identical - mixed", {

"direct and indirect fits identical - mixed"

expect_message(rand_seed <- set_rng_seed(), "Using randomly generated seed")

chickweights_df <- chickweights_df[chickweights_df$Time <= 20, ]
p_str_original <- table(unique(chickweights_spec1$data[, c("Chick", "DietInt")])$DietInt)
permuted <- permute_by_predictor(chickweights_spec1, predictors = "DietInt", predictor_type = "between_participant")
p_str_permuted <- table(unique(permuted[, c("Chick", "DietInt")])$DietInt)
t_str_original <- unname(sort(tapply(chickweights_spec1$data$weight, chickweights_spec1$data$Chick, toString)))
t_str_permuted <- unname(sort(tapply(permuted$weight, permuted$Chick, toString)))
expect_message(spec1_perm1 <- permute_by_predictor(chickweights_spec1, predictors = "DietInt"), "between_participant")
spec1_perm1 <- permute_by_predictor(chickweights_spec1, predictors = "DietInt", predictor_type = "between_participant")
spec1_perm2 <- permute_by_predictor(chickweights_spec1, predictors = "DietInt", predictor_type = "between_participant")
test_that("levels of a category shuffled together", {
expect_message(spec2_perm1 <- permute_by_predictor(chickweights_spec2, predictors = "Diet2", predictor_type = "between_participant"), "Diet3")
spec2_perm2 <- permute_by_predictor(chickweights_spec2, predictors = c("Diet2", "Diet3", "Diet4"), predictor_type = "between_participant")

"levels of a category shuffled together"