Files
felhom.eu/documentation/audits/website-gallery-2026-10-08/live-check.js
T

53 lines
3.6 KiB
JavaScript

const puppeteer = require('puppeteer');
const sleep = ms => new Promise(r => setTimeout(r, ms));
const state = p => p.evaluate(() => { const b = document.querySelector('.lightbox-overlay');
return { open: !!(b && b.classList.contains('active')), src: b ? (b.querySelector('.lightbox-image').getAttribute('src') || '').split('/').pop() : null,
counter: b ? b.querySelector('.lightbox-counter').textContent : null, closeLabel: b ? b.querySelector('.lightbox-close').getAttribute('aria-label') : null,
focus: document.activeElement && document.activeElement.className, overflow: document.body.style.overflow }; });
(async () => {
const b = await puppeteer.launch({args: ['--no-sandbox']});
const out = [];
// 1-3: dashboard set on /, /en/, /technologiak — open, next, close by clicking the picture
for (const u of ['https://felhom.eu/', 'https://felhom.eu/en/', 'https://felhom.eu/technologiak']) {
const p = await b.newPage(); await p.setViewport({width: 1280, height: 900});
await p.goto(u, {waitUntil: 'networkidle2'});
await p.click('a[data-gallery="dashboard"]'); await sleep(600);
const s1 = await state(p);
await p.click('.lightbox-next'); await sleep(600);
const s2 = await state(p);
await p.screenshot({path: `/out/dash-${u.split('/').filter(Boolean).pop().replace('felhom.eu', 'root')}.png`});
await p.click('.lightbox-image'); await sleep(400);
const s3 = await state(p);
out.push([u, 'opened', s1, 'next', s2, 'after click on picture', s3, 'url', p.url()]); await p.close();
}
// 4-5: app pictures on /alkalmazasok and /en/apps — open Immich, close by clicking the picture
for (const u of ['https://felhom.eu/alkalmazasok', 'https://felhom.eu/en/apps']) {
const p = await b.newPage(); await p.setViewport({width: 1280, height: 900});
await p.goto(u, {waitUntil: 'networkidle2'});
await p.click('a[data-gallery="immich"]'); await sleep(600);
const s1 = await state(p);
await p.click('.lightbox-image'); await sleep(400);
out.push([u, 'opened', s1, 'after click on picture', await state(p), 'url', p.url()]); await p.close();
}
// 6: swipe at 376 px does not close
{ const p = await b.newPage(); await p.setViewport({width: 376, height: 812, isMobile: true, hasTouch: true});
await p.goto('https://felhom.eu/en/apps', {waitUntil: 'networkidle2'});
await p.tap('a[data-gallery="immich"]'); await sleep(600);
const s1 = await state(p);
const c = await p.client ? null : null;
const cdp = await p.target().createCDPSession();
const t = async (type, x) => cdp.send('Input.dispatchTouchEvent', {type, touchPoints: type === 'touchEnd' ? [] : [{x, y: 400}]});
await t('touchStart', 300); for (const x of [250, 200, 150, 100]) { await t('touchMove', x); await sleep(30); } await t('touchEnd', 100); await sleep(600);
const s2 = await state(p);
await p.screenshot({path: '/out/swipe-376.png'});
await p.tap('.lightbox-image'); await sleep(500);
out.push(['376 px /en/apps', 'opened', s1, 'after swipe left', s2, 'after tap on picture', await state(p)]); await p.close(); }
// 7: JavaScript off — the link opens the image file
{ const p = await b.newPage(); await p.setJavaScriptEnabled(false); await p.setViewport({width: 1280, height: 900});
await p.goto('https://felhom.eu/', {waitUntil: 'networkidle2'});
await Promise.all([p.waitForNavigation({waitUntil: 'networkidle2'}), p.click('a[data-gallery="dashboard"]')]);
out.push(['JS off /', 'url after click', p.url()]); await p.close(); }
for (const o of out) console.log(JSON.stringify(o));
await b.close();
})().catch(e => { console.error(e); process.exit(1); });