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 errs = [];
  page.on('console', m => { if (m.text().includes('RangeError')||m.text().startsWith('CK_ERROR')) errs.push(m.text().slice(0,120)); });
  page.on('response', r => { if (r.url().includes('get-buy-service')) console.log('  API:', r.url().split('get-buy-service')[1], '→', r.status()); });
  // 试几个 service 参数
  for (const p of ['/buy-service/1/ministore', '/buy-service/1/igoshow', '/buy-service/310/ministore']) {
    errs.length = 0;
    await page.goto('http://127.0.0.1:8099'+p, { waitUntil: 'load' }).catch(()=>{});
    await page.waitForTimeout(6000);
    console.log(p, errs.length ? '✗ '+errs[0] : '✓ OK');
  }
  await browser.close();
})();
