const { chromium } = require('playwright');
(async () => {
  const browser = await chromium.launch({ headless: true });
  const page = await (await browser.newContext({viewport:{width:1280,height:900}})).newPage();
  const logs = [];
  page.on('console', m => logs.push(m.text()));
  page.on('pageerror', e => logs.push('PAGEERR: ' + e.message.slice(0,150)));
  page.on('response', async r => { if (r.url().includes('get-buy-service')) console.log('API:', r.status()); });
  await page.goto('http://127.0.0.1:8099/buy-service/1/pos', { waitUntil: 'load' }).catch(()=>{});
  await page.waitForTimeout(9000);
  console.log('--- RangeError 相关 console ---');
  logs.filter(l => l.includes('RangeError') || l.includes('CK_ERROR') || l.startsWith('PAGEERR')).slice(0,5).forEach(l => console.log(l.slice(0,180)));
  await browser.close();
})();
