import { test, expect } from './helpers/fixtures.js'

test.describe('Member dashboard', () => {
  test('dashboard loads for authenticated user', async ({ adminPage }) => {
    await adminPage.goto('/member/dashboard')

    await expect(adminPage.getByText('Welcome back')).toBeVisible({ timeout: 10000 })
  })

  test('shows navigation links', async ({ adminPage }) => {
    await adminPage.goto('/member/dashboard')

    // Wait for dashboard content to render
    await expect(adminPage.getByText('Welcome back')).toBeVisible({ timeout: 10000 })

    // Verify quick action links are present
    await expect(adminPage.getByText('Update your profile')).toBeVisible()
    await expect(adminPage.getByText('Browse members')).toBeVisible()
    await expect(adminPage.getByText('Manage account')).toBeVisible()
  })

  test('unauthenticated shows sign-in prompt', async ({ browser }) => {
    const context = await browser.newContext()
    const page = await context.newPage()

    await page.goto('/member/dashboard')

    // Should show the sign-in required message or a login modal
    await expect(
      page.getByText('Sign in required').or(page.getByText('Sign in to your dashboard'))
    ).toBeVisible({ timeout: 10000 })

    await context.close()
  })
})
