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