const { chromium } = require('@playwright/test'); (async () => { const b = await chromium.launch(); const p = await b.newPage(); const errs=[]; p.on('pageerror',e=>errs.push(e.message)); p.on('console',m=>{if(m.type()==='error')errs.push(m.text());}); await p.route('**/api/admin', r => r.fulfill({ contentType:'application/json', body: JSON.stringify({authenticated:true}) })); await p.goto('http://localhost/geograsim/App/admin-weltkueche.html'); await p.waitForTimeout(2000); const r = await p.evaluate(() => { const dishes = [...document.querySelectorAll('.dish')]; const names = dishes.map(d => d.querySelector('.nm')?.textContent); function dishInfo(namePart){ const d = dishes.find(x => (x.querySelector('.nm')?.textContent||'').toLowerCase().includes(namePart)); if(!d) return null; const rows = [...d.querySelectorAll('tbody tr')].map(tr => ({ ing: tr.querySelector('.ing-nm')?.textContent.replace(/\s+/g,' ').trim(), ok: [...tr.querySelectorAll('.cty.ok')].map(c=>c.textContent.replace(/\s+/g,' ').trim()), dist: [...tr.querySelectorAll('.cty.dist')].map(c=>c.title.split(' · ')[0]), })); return rows; } const groestl = dishInfo('tiroler gröstl'); const kart = groestl && groestl.find(r => /Kartoffel/i.test(r.ing)); const eierRow = groestl && groestl.find(r => /Eier/i.test(r.ing)); return { dishCount: dishes.length, sampleNames: names.slice(0,6), kartoffelOk: kart ? kart.ok : null, eierOk: eierRow ? eierRow.ok : null, warnCount: document.querySelectorAll('.warn').length, }; }); console.log(JSON.stringify({result:r, pageErrors:errs}, null, 2)); await b.close(); })();