shot-edition-prototype.mjs 1.5 KB

12345678910111213141516171819202122232425262728293031
  1. // 个人版/企业版原型截图(2026-12-01):两版 × 两端 × 5 页,输出到 test-results/edition-split-20261201/
  2. import fs from 'node:fs';
  3. import path from 'node:path';
  4. import { pathToFileURL } from 'node:url';
  5. import { chromium } from 'playwright';
  6. const OUT = 'test-results/edition-split-20261201';
  7. const PAGE = pathToFileURL(path.resolve('prototypes/edition-split-20261201/index.html')).href;
  8. fs.mkdirSync(OUT, { recursive: true });
  9. const browser = await chromium.launch({ channel: 'chrome' });
  10. const problems = [];
  11. for (const end of ['mobile', 'desktop']) {
  12. const ctx = await browser.newContext(end === 'mobile'
  13. ? { viewport: { width: 390, height: 844 }, deviceScaleFactor: 2 }
  14. : { viewport: { width: 1280, height: 800 } });
  15. const page = await ctx.newPage();
  16. page.on('pageerror', (e) => problems.push(`${end}: ${e.message}`));
  17. for (const p of ['contacts', 'mine', 'agent', 'groups', 'nav']) {
  18. for (const edition of ['personal', 'enterprise']) {
  19. await page.goto(`${PAGE}?capture=1&end=${end}&page=${p}&edition=${edition}`);
  20. await page.evaluate(() => document.fonts.ready);
  21. const overflow = await page.evaluate(() => document.documentElement.scrollWidth > innerWidth);
  22. if (overflow) problems.push(`${end}/${p}/${edition}: 横向溢出`);
  23. await page.screenshot({ path: `${OUT}/${end}-${p}-${edition}.png`, fullPage: true });
  24. }
  25. }
  26. await ctx.close();
  27. }
  28. await browser.close();
  29. console.log(problems.length ? problems.join('\n') : '20 张截图完成,无脚本错误、无横向溢出');