test_that("PipeOpFDARandomEffect - basic properties", {
  pop = po("fda.random_effect")
  expect_pipeop(pop)
  expect_identical(pop$id, "fda.random_effect")
})

test_that("PipeOpFDARandomEffect works", {
  skip_if_not_installed("lme4")

  task = tsk("fuel")
  pop = po("fda.random_effect")
  task_fre = suppressWarnings(train_pipeop(pop, list(task))[[1L]])
  new_data = task_fre$data()
  expect_task(task_fre)
  expect_shape(new_data, dim = c(129L, 6L))
  expect_named(
    new_data,
    c("heatan", "h2o", "NIR_random_intercept", "NIR_random_slope", "UVVIS_random_intercept", "UVVIS_random_slope")
  )

  # irregular data works
  task = tsk("dti")
  pop = po("fda.random_effect")
  task_fre = train_pipeop(pop, list(task))[[1L]]
  new_data = task_fre$data()
  expect_task(task_fre)
  expect_shape(new_data, dim = c(340L, 6L))
  expect_named(
    new_data,
    c("pasat", "sex", "cca_random_intercept", "cca_random_slope", "rcst_random_intercept", "rcst_random_slope")
  )
})
