// V94 FULL E2E SCENARIO BUSINESS with Chrome video (Selenium-style via Playwright Chromium) // Creates auth session → walks through 10 pages → records video → screenshots const { chromium } = require('playwright'); const fs = require('fs'); const SESSION_SEED_URL = 'http://127.0.0.1/api/opus-test-session-v94.php?k=WEVADS2026'; const VIDEO_DIR = '/var/www/html/api/blade-tasks/v94-videos/'; const SCREENSHOTS_DIR = '/var/www/html/api/blade-tasks/v94-screenshots/'; const SCENARIO_PAGES = [ { name: 'weval-technology-platform', url: 'https://weval-consulting.com/weval-technology-platform.html', wait: 3000 }, { name: 'enterprise-model', url: 'https://weval-consulting.com/enterprise-model.html', wait: 6000 }, { name: 'wevia-em-big4', url: 'https://weval-consulting.com/wevia-em-big4.html', wait: 5000 }, { name: 'agents-archi', url: 'https://weval-consulting.com/agents-archi.html', wait: 5000 }, { name: 'value-streaming', url: 'https://weval-consulting.com/value-streaming.html', wait: 5000 }, { name: 'wevia-master', url: 'https://weval-consulting.com/wevia-master.html', wait: 3000 }, { name: 'business-kpi-dashboard', url: 'https://weval-consulting.com/business-kpi-dashboard.php', wait: 4000 }, { name: 'wevia-admin-crm', url: 'https://weval-consulting.com/wevia-admin-crm.php', wait: 3000 }, { name: 'wevia-v64-15-departements', url: 'https://weval-consulting.com/wevia-v64-15-departements.html', wait: 3000 }, { name: 'wevia-em-live-kpi', url: 'https://weval-consulting.com/wevia-em-live-kpi.php', wait: 3000 } ]; (async () => { fs.mkdirSync(VIDEO_DIR, { recursive: true }); fs.mkdirSync(SCREENSHOTS_DIR, { recursive: true }); const browser = await chromium.launch({ headless: true, args: ['--no-sandbox', '--disable-setuid-sandbox'] }); const ctx = await browser.newContext({ viewport: { width: 1920, height: 1080 }, recordVideo: { dir: VIDEO_DIR, size: { width: 1920, height: 1080 } } }); // 1. Seed the auth session via localhost endpoint const seedPage = await ctx.newPage(); await seedPage.goto(SESSION_SEED_URL, { waitUntil: 'load' }); await seedPage.waitForTimeout(500); await seedPage.close(); // 2. Main page to navigate scenarios const page = await ctx.newPage(); await page.addInitScript(() => { try { localStorage.setItem('weval_internal', 'yacine-2026'); } catch(e){} }); const errs = []; page.on('pageerror', e => errs.push(`[${page.url()}] ${e.message.substring(0, 200)}`)); page.on('console', m => { if (m.type() === 'error') errs.push(`[${page.url()}] console: ${m.text().substring(0, 150)}`); }); const results = []; for (const p of SCENARIO_PAGES) { const startTime = Date.now(); const pageErrs = []; try { await page.goto(p.url, { waitUntil: 'load', timeout: 30000 }); await page.waitForTimeout(p.wait); const diag = await page.evaluate(() => { const canvases = document.querySelectorAll('canvas'); const svgs = document.querySelectorAll('svg'); const imgs = document.querySelectorAll('img'); const links = document.querySelectorAll('a').length; const buttons = document.querySelectorAll('button').length; // Look for signs of rendering issues const emptyBlocks = document.querySelectorAll('.empty, .placeholder, [class*="empty"]').length; const errorDivs = Array.from(document.querySelectorAll('*')).filter(e => /error|failed|undefined|NaN|null/i.test(e.textContent || '') && e.children.length < 2 && (e.textContent || '').length < 100 ).length; // Check globals const hasAG = typeof AG !== 'undefined' ? AG.length : -1; const hasDP = typeof DP !== 'undefined' ? DP.length : -1; return { final_url: location.href, title: document.title, is_login: location.href.includes('/login'), body_len: document.body.innerText.length, canvas: canvases.length, svg: svgs.length, img: imgs.length, links, buttons, empty_blocks: emptyBlocks, error_divs: errorDivs, AG_length: hasAG, DP_length: hasDP }; }); await page.screenshot({ path: `${SCREENSHOTS_DIR}${p.name}.png`, fullPage: true }); results.push({ name: p.name, url: p.url, ok: !diag.is_login, diag, duration_ms: Date.now() - startTime, js_errors_count: pageErrs.length, js_errors_sample: pageErrs.slice(0, 3) }); } catch (e) { results.push({ name: p.name, url: p.url, ok: false, err: e.message.substring(0, 200), duration_ms: Date.now() - startTime }); } } await ctx.close(); await browser.close(); // Rename videos for clarity const videoFiles = fs.readdirSync(VIDEO_DIR).filter(f => f.endsWith('.webm')); const summary = { ts: new Date().toISOString(), total_pages: SCENARIO_PAGES.length, pages_ok: results.filter(r => r.ok).length, pages_auth_gated: results.filter(r => r.diag && r.diag.is_login).length, pages_errored: results.filter(r => !r.ok && !r.diag).length, total_js_errors: errs.length, video_files: videoFiles, video_dir: VIDEO_DIR, screenshots_dir: SCREENSHOTS_DIR, results, all_js_errors: errs.slice(0, 30) }; fs.writeFileSync('/var/www/html/api/playwright-v94-e2e-full-scenario.json', JSON.stringify(summary, null, 2)); console.log(JSON.stringify({ ok_pages: summary.pages_ok, auth_gated: summary.pages_auth_gated, errored: summary.pages_errored, total_errors: summary.total_js_errors, videos: videoFiles.length, screenshots: SCENARIO_PAGES.length }, null, 2)); })();