31 lines
1.1 KiB
JavaScript
31 lines
1.1 KiB
JavaScript
import { chromium } from 'playwright';
|
|
|
|
const BASE = process.env.BASE || 'http://127.0.0.1:5173';
|
|
const API = process.env.API || 'http://127.0.0.1:8010';
|
|
const OUT = process.argv[2] || 'shots-sidebar';
|
|
|
|
const login = await (await fetch(`${API}/api/auth/login/`, {
|
|
method: 'POST',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
body: JSON.stringify({ username: 'airshelf', password: 'Restraint2026' })
|
|
})).json();
|
|
const tok = login.token;
|
|
|
|
const browser = await chromium.launch();
|
|
const ctx = await browser.newContext({ viewport: { width: 440, height: 800 }, deviceScaleFactor: 2 });
|
|
await ctx.addInitScript((t) => localStorage.setItem('airshelf_token', t), tok);
|
|
const page = await ctx.newPage();
|
|
|
|
async function shot(url, name) {
|
|
await page.goto(`${BASE}${url}`, { waitUntil: 'networkidle', timeout: 40000 });
|
|
await page.waitForTimeout(800);
|
|
await page.screenshot({ path: `${OUT}-${name}.png`, clip: { x: 0, y: 0, width: 220, height: 780 } });
|
|
console.log('shot', name);
|
|
}
|
|
|
|
await shot('/projects', 'projects');
|
|
await shot('/team', 'team');
|
|
await shot('/settings', 'settings');
|
|
|
|
await browser.close();
|