const puppeteer = require('puppeteer');

(async () => {
  const browser = await puppeteer.launch({headless: false, args: ['--no-sandbox']});
  const page = await browser.newPage();
  page.on('console', msg => console.log('BROWSER:', msg.text()));

  console.log('Testing main metrics page...');
  await page.goto('http://localhost:5000/metrics/', {waitUntil: 'networkidle2'});
  const chartLoaded = await page.evaluate(() => typeof Chart !== 'undefined');
  console.log('Chart.js loaded on main metrics page:', chartLoaded);

  await new Promise(resolve => setTimeout(resolve, 1000));
  await browser.close();
})();
