- /api/wired-pending/intent-opus4-chrome_cdp_autoheal_w309.php - Cron */5min installe sur /etc/cron.d/wevia-chrome-autoheal - Load guard 45 threshold + circuit breaker +5 - 8/8 CDP stable verified - Doctrine 309
98 lines
4.6 KiB
JavaScript
Executable File
98 lines
4.6 KiB
JavaScript
Executable File
// Doctrine 170: Playwright UX overlap audit COMPLET - toutes pages enrichies doctrine 60
|
|
const { chromium } = require('playwright');
|
|
const fs = require('fs');
|
|
const { execSync } = require('child_process');
|
|
|
|
const TS = new Date().toISOString().replace(/[:.]/g, '-').slice(0, 19);
|
|
const OUTDIR = `/var/www/html/proofs/wevia-ux-overlap-v2-${TS}`;
|
|
const SHOTS = `${OUTDIR}/shots`;
|
|
const ZOOMS = `${OUTDIR}/zooms`;
|
|
const VIDEOS = `${OUTDIR}/videos`;
|
|
[OUTDIR, SHOTS, ZOOMS, VIDEOS].forEach(d => fs.mkdirSync(d, { recursive: true }));
|
|
|
|
// Get all pages enriched doctrine 60
|
|
const enrichedPages = execSync(`grep -l "DOCTRINE-60-UX-ENRICH" /var/www/html/*.html 2>/dev/null`).toString().trim().split('\n')
|
|
.map(p => p.replace('/var/www/html/', '').replace('.html', ''))
|
|
.slice(0, 15); // limit to 15 to stay reasonable
|
|
|
|
(async () => {
|
|
const browser = await chromium.launch({ headless: true, args: ['--no-sandbox', '--disable-gpu'] });
|
|
const context = await browser.newContext({
|
|
viewport: { width: 1440, height: 900 },
|
|
recordVideo: { dir: VIDEOS, size: { width: 1440, height: 900 } },
|
|
extraHTTPHeaders: { 'X-Agent-Token': 'wevia-ux-audit-doctrine170' }
|
|
});
|
|
|
|
const results = [];
|
|
for (const name of enrichedPages) {
|
|
const url = `https://weval-consulting.com/${name}.html`;
|
|
const pg = await context.newPage();
|
|
const r = { hub: name, url, ok: false };
|
|
try {
|
|
await pg.goto(url, { waitUntil: 'domcontentloaded', timeout: 12000 });
|
|
await pg.waitForTimeout(2000);
|
|
await pg.screenshot({ path: `${SHOTS}/${name}-full.png`, fullPage: false });
|
|
await pg.screenshot({ path: `${ZOOMS}/${name}-top-right.png`, clip: { x: 1040, y: 0, width: 400, height: 400 } });
|
|
await pg.screenshot({ path: `${ZOOMS}/${name}-bot-right.png`, clip: { x: 1040, y: 500, width: 400, height: 400 } });
|
|
|
|
const overlaps = await pg.evaluate(() => {
|
|
const findInZone = (x1, y1, x2, y2) => {
|
|
const all = document.querySelectorAll('button, .btn, .toggle, [class*="toggle"], [class*="btn"], .chip, .badge, .fab, [style*="position:fixed"], [style*="position:absolute"]');
|
|
const hits = [];
|
|
for (const el of all) {
|
|
const rect = el.getBoundingClientRect();
|
|
if (rect.width < 2 || rect.height < 2) continue;
|
|
const cx = rect.x + rect.width/2, cy = rect.y + rect.height/2;
|
|
if (cx >= x1 && cx <= x2 && cy >= y1 && cy <= y2) {
|
|
hits.push({ tag: el.tagName, cls: (el.className||'').toString().slice(0,60), text: (el.textContent||'').trim().slice(0,30) });
|
|
}
|
|
}
|
|
return hits;
|
|
};
|
|
return {
|
|
tr: findInZone(1040, 0, 1440, 400),
|
|
br: findInZone(1040, 500, 1440, 900)
|
|
};
|
|
});
|
|
r.tr_count = overlaps.tr.length;
|
|
r.br_count = overlaps.br.length;
|
|
r.has_overlap_tr = overlaps.tr.length > 1;
|
|
r.has_overlap_br = overlaps.br.length > 1;
|
|
r.ok = true;
|
|
} catch (e) { r.error = e.message.slice(0, 150); }
|
|
await pg.close();
|
|
results.push(r);
|
|
}
|
|
await context.close();
|
|
await browser.close();
|
|
|
|
const summary = {
|
|
doctrine: '170',
|
|
ts: new Date().toISOString(),
|
|
pages_count: enrichedPages.length,
|
|
viewport: '1440x900',
|
|
results,
|
|
overlap_alerts: results.filter(r => r.has_overlap_tr || r.has_overlap_br)
|
|
};
|
|
fs.writeFileSync(`${OUTDIR}/summary.json`, JSON.stringify(summary, null, 2));
|
|
|
|
// Simple HTML index
|
|
const html = `<!DOCTYPE html><html><head><title>UX Audit v2 ${TS}</title><style>body{background:#0a0e1a;color:#e6edf3;font-family:system-ui;padding:20px}.card{background:#151a26;border:1px solid #2a3444;padding:12px;margin:10px 0;border-radius:8px}img{max-width:380px;margin:4px;border:1px solid #2a3444;border-radius:4px}.ok{color:#10b981}.warn{color:#f59e0b}</style></head><body>
|
|
<h1>🎯 UX Overlap Audit v2 Doctrine 170 · ${TS}</h1>
|
|
<p>${enrichedPages.length} pages enrichies doctrine 60 auditées · Viewport 1440x900</p>
|
|
${results.map(r => `<div class="card"><h3>${r.hub} <span class="${r.has_overlap_tr||r.has_overlap_br?'warn':'ok'}">${r.has_overlap_tr||r.has_overlap_br?'⚠ OVERLAP':'✅ OK'}</span></h3>
|
|
<p>TR: ${r.tr_count||0} · BR: ${r.br_count||0}</p>
|
|
<img src="zooms/${r.hub}-top-right.png"> <img src="zooms/${r.hub}-bot-right.png"></div>`).join('')}
|
|
</body></html>`;
|
|
fs.writeFileSync(`${OUTDIR}/index.html`, html);
|
|
|
|
console.log(JSON.stringify({
|
|
ok: true,
|
|
doctrine: '170',
|
|
outdir: OUTDIR.replace('/var/www/html', ''),
|
|
url: `https://weval-consulting.com${OUTDIR.replace('/var/www/html', '')}/index.html`,
|
|
pages: enrichedPages.length,
|
|
overlaps_detected: summary.overlap_alerts.length
|
|
}));
|
|
})();
|