const { chromium } = require('playwright');

(async () => {
  const browser = await chromium.launch();
  const page = await browser.newPage();

  try {
    await page.goto('http://localhost:3002/dashboard', { waitUntil: 'networkidle', timeout: 10000 });

    // Take full page screenshot
    await page.screenshot({ path: 'dashboard-charts-full.png', fullPage: true });
    console.log('✓ Saved dashboard-charts-full.png');

    // Check for console errors
    const errors = [];
    page.on('console', msg => {
      if (msg.type() === 'error') {
        errors.push(msg.text());
      }
    });

    // Wait a bit for any errors
    await page.waitForTimeout(2000);

    console.log(`Console errors: ${errors.length}`);
    if (errors.length > 0) {
      console.log('Errors:', errors);
    }

  } catch (error) {
    console.error('Error:', error.message);
  }

  await browser.close();
})();
