/**
 * Login helpers using dev endpoints.
 * These set real httpOnly JWT cookies so all middleware works naturally.
 */

/**
 * Login as admin via the dev test-login endpoint.
 * Creates a test admin user if none exists.
 */
export async function loginAsAdmin(page) {
  await page.goto('/api/dev/test-login')
  await page.waitForURL('**/admin**')
}

/**
 * Login as a specific member by email via the dev member-login endpoint.
 */
export async function loginAsMember(page, email) {
  await page.goto(`/api/dev/member-login?email=${encodeURIComponent(email)}`)
  await page.waitForURL('**/member/**')
}
