wayBetter for X
This commit is contained in:
commit
2f1e35ba20
720 changed files with 147465 additions and 0 deletions
38
apps/desktop/scripts/i18n-shots.mjs
Normal file
38
apps/desktop/scripts/i18n-shots.mjs
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
// Screenshots of the shell and the wayBetter panel in other languages, through the dev preview
|
||||
// harnesses (`/?shell`, `/?panel`, `?lang=<tag>`, mocked native commands) against a running
|
||||
// `vite dev`. Usage: node scripts/i18n-shots.mjs [baseUrl] [outDir] [lang...]
|
||||
// Set CHANNEL=chrome to drive an installed Google Chrome instead of Playwright's Chromium.
|
||||
import { chromium } from 'playwright';
|
||||
import { mkdirSync } from 'node:fs';
|
||||
import { join } from 'node:path';
|
||||
|
||||
const [base = 'http://127.0.0.1:1433', out = join(import.meta.dirname, '..', '..', '..', 'verification', 'i18n'), ...langs] = process.argv.slice(2);
|
||||
mkdirSync(out, { recursive: true });
|
||||
|
||||
const WIDE = { width: 1440, height: 860 };
|
||||
const shots = [
|
||||
['shell-tabs', '?shell&tabs=5&update=ready'],
|
||||
['shell-newtab', '?shell&tabs=4&open=newtab'],
|
||||
['shell-palette', '?shell&tabs=5&open=palette'],
|
||||
['panel-settings', '?panel§ion=settings'],
|
||||
['panel-drafts', '?panel'],
|
||||
];
|
||||
const browser = await chromium.launch(process.env.CHANNEL ? { channel: process.env.CHANNEL } : {});
|
||||
const errors = [];
|
||||
for (const lang of langs.length ? langs : ['tr', 'ar', 'ja', 'de']) {
|
||||
for (const [name, query] of shots) {
|
||||
const page = await browser.newPage({ viewport: WIDE, deviceScaleFactor: 1, reducedMotion: 'reduce', colorScheme: 'dark' });
|
||||
page.on('pageerror', error => errors.push(`${lang}/${name}: ${error.message}`));
|
||||
page.on('console', message => { if (message.type() === 'error') errors.push(`${lang}/${name}: ${message.text()}`); });
|
||||
page.on('response', response => { if (response.status() >= 400) errors.push(`${lang}/${name}: HTTP ${response.status()} ${response.url()}`); });
|
||||
await page.goto(`${base}/${query}&lang=${lang}`);
|
||||
await page.waitForTimeout(1500);
|
||||
const state = await page.evaluate(() => ({ lang: document.documentElement.lang, dir: document.documentElement.dir }));
|
||||
if (state.lang !== lang) errors.push(`${lang}/${name}: <html lang> is ${state.lang}`);
|
||||
await page.screenshot({ path: join(out, `${lang}-${name}.png`) });
|
||||
console.log(`${lang}-${name}`, state.dir);
|
||||
await page.close();
|
||||
}
|
||||
}
|
||||
await browser.close();
|
||||
console.log(errors.length ? errors.join('\n') : 'no page errors');
|
||||
Loading…
Add table
Add a link
Reference in a new issue