/**
 * Debug Error Test
 */

import { test, expect } from '@playwright/test'

test('capture console errors', async ({ page }) => {
  const errors: string[] = []

  page.on('console', msg => {
    if (msg.type() === 'error') {
      errors.push(msg.text())
    }
  })

  page.on('pageerror', error => {
    errors.push(`Page Error: ${error.message}`)
  })

  await page.goto('/zh-TW')
  await page.waitForTimeout(3000)

  await page.screenshot({
    path: 'test-results/debug-error.png',
    fullPage: true,
  })

  console.log('=== Console Errors ===')
  errors.forEach((e, i) => console.log(`${i + 1}. ${e}`))
  console.log('======================')
})
