import { describe, it, expect } from 'vitest'
import { setup, createPage } from '@nuxt/test-utils/e2e'

describe('login page', async () => {
  await setup({
    host: 'http://localhost:3000',
    browser: true
  })

  it('shows the email input and OAuth provider buttons', { timeout: 30_000 }, async () => {
    // createPage() without a path skips the internal waitForHydration call
    // (which hangs on SPAs because window.useNuxtApp is not exposed)
    const page = await createPage()
    await page.goto('http://localhost:3000/login', { waitUntil: 'networkidle' })

    // Email field rendered by UAuthForm
    expect(await page.locator('input[type="text"]').first().isVisible()).toBe(true)

    // OAuth buttons for Google and Apple
    expect(await page.getByText('Google').isVisible()).toBe(true)
    expect(await page.getByText('Apple').isVisible()).toBe(true)
  })
})
