import { auth } from "../src/lib/auth"

async function simulateLogin() {
  const email = process.env.TEST_LOGIN_EMAIL ?? "admin@sistema.dev"
  const password = process.env.TEST_LOGIN_PASSWORD ?? "admin123"

  const result = await auth.api.signInEmail({
    body: {
      email,
      password,
      rememberMe: true,
    },
    returnHeaders: true,
  })

  console.log("HTTP", result.response ? 200 : "unknown")
  console.log("Session token", result.response?.token)
  console.log("User", result.response?.user)
  console.log("Cookies", Array.from(result.headers.entries()))
}

simulateLogin().catch((error) => {
  console.error("Failed to simulate login:", error)
  process.exit(1)
})
