// Screenshots für README und Projektseite – NUR gegen eine Demo-Instanz (DEMO_DATA=true) laufen lassen! // npm i playwright && npx playwright install chromium // BASE_URL=http://localhost:8000 OUT=./shots node tools/screenshots/screenshots.js // Logins: Demo-Benutzer (Passwort demo1234) und der Admin aus der .env (ADMIN_PASSWORD). const { chromium } = require('playwright'); const fs = require('fs'); const BASE = process.env.BASE_URL || 'http://localhost:8000'; const OUT = process.env.OUT || 'shots'; const ADMIN_PW = process.env.ADMIN_PASSWORD || 'admin12345'; fs.mkdirSync(OUT, { recursive: true }); const DESKTOP = { viewport: { width: 1280, height: 800 }, deviceScaleFactor: 2 }; const TABLET = { viewport: { width: 1024, height: 720 }, deviceScaleFactor: 2, hasTouch: true }; const PHONE = { viewport: { width: 390, height: 780 }, deviceScaleFactor: 3, isMobile: true, hasTouch: true }; async function session(browser, opts, user, pw = 'demo1234') { const ctx = await browser.newContext({ ...opts, locale: 'de-DE' }); const page = await ctx.newPage(); page.on('pageerror', e => console.error('JS-Fehler:', e.message)); if (user) { await page.goto(BASE + '/login'); await page.fill('input[name=username]', user); await page.fill('input[name=password]', pw); await Promise.all([page.waitForNavigation(), page.click('button[type=submit]')]); } return { ctx, page }; } async function shot(page, path, name, { full = false, before } = {}) { await page.goto(BASE + path); await page.waitForLoadState('networkidle'); if (before) await before(page); await page.evaluate(() => document.querySelectorAll('.flash, .flashes').forEach(e => e.remove())); await page.screenshot({ path: `${OUT}/${name}.png`, fullPage: full }); console.log('✓', name); } (async () => { // deutsche Datums- und Dateifelder const b = await chromium.launch({ args: ['--lang=de-DE'], env: { ...process.env, LANG: 'de_DE.UTF-8' } }); // Praxisleitung am PC let { page } = await session(b, DESKTOP, 'lhoffmann'); await shot(page, '/', 'uebersicht'); await shot(page, '/geraete/1', 'geraet'); await shot(page, '/pruefungen', 'pruefungen'); await shot(page, '/temperatur/7', 'temperatur'); await shot(page, '/qm', 'qm'); await shot(page, '/qm/1', 'qm-dokument'); await shot(page, '/personal/uebersicht/matrix', 'matrix'); await shot(page, '/urlaub', 'urlaub'); await shot(page, '/suche?q=steri', 'suche'); await shot(page, '/etiketten', 'etiketten'); // Mitarbeiterin: Steri und Zeiterfassung ({ page } = await session(b, DESKTOP, 'syilmaz')); await shot(page, '/steri', 'steri'); await shot(page, '/zeit', 'zeit'); // Admin: Einstellungen; danach dieses (Tablet-)Gerät freischalten -> PIN-Anmeldung ({ page } = await session(b, TABLET, 'admin', ADMIN_PW)); await shot(page, '/einstellungen', 'einstellungen', { full: true }); page.on('dialog', d => d.accept()); await page.goto(BASE + '/admin'); await page.fill('form[action="/admin/kiosk/einrichten"] input[name=name]', 'Tablet Steri-Raum'); await Promise.all([page.waitForNavigation(), page.click('form[action="/admin/kiosk/einrichten"] button')]); await shot(page, '/kiosk', 'tablet-pin'); ({ page } = await session(b, TABLET, 'syilmaz')); await shot(page, '/steri/neu', 'tablet-steri'); // Handy ({ page } = await session(b, PHONE, 'tkraus')); await shot(page, '/', 'handy-uebersicht'); await shot(page, '/scan', 'handy-scan'); await shot(page, '/temperatur', 'handy-temperatur'); await shot(page, '/geraete/1', 'handy-geraet'); await b.close(); })();