Files
html/tests/l99-mega-test.js
2026-04-12 22:57:03 +02:00

252 lines
10 KiB
JavaScript

#!/usr/bin/env node
/**
* L99 MEGA TEST — ALL PAGES + SCENARIOS + SCREENSHOTS + VIDEO
* Tests every HTML page: status, JS errors, size, screenshot
* Business scenarios: login, chat, API, navigation
* Output: /var/www/html/test-report/l99-mega-results.json + screenshots/
*/
const puppeteer = require('puppeteer');
const fs = require('fs');
const path = require('path');
const BASE = 'https://weval-consulting.com';
const SSDIR = '/var/www/html/test-report/screenshots';
const RESULTS_FILE = '/var/www/html/test-report/l99-mega-results.json';
fs.mkdirSync(SSDIR, { recursive: true });
const PAGES = [
// ROOT PAGES
'index.html','login.html','register.html','cgu.html','booking.html','case-studies.html',
'admin.html','admin-v2.html','admin-saas.html',
'agents-archi.html','agents-fleet.html','agents-goodjob.html',
'ai-benchmark.html','architecture.html','apps.html',
'blade-ai.html','blade-center.html','blade-install.html',
'claude-monitor.html','claw-chat.html','claw-code.html',
'command-center.html','crons-monitor.html',
'director.html','director-center.html','director-chat.html',
'enterprise-model.html','enterprise-management.html',
'l99.html','l99-brain.html','l99-saas.html',
'monitoring.html','mega-command-center.html',
'openclaw.html','oss-discovery.html',
'paperclip.html','value-streaming.html',
'wevia.html','wevia-master.html','wevia-console.html','wevia-meeting-rooms.html',
'wevia-widget.html','weval-login.html',
];
// SUBDOMAINS
const SUBS = ['crm','paperclip','langfuse','deerflow','analytics','mm','monitor','n8n','git'];
// APIs
const APIS = [
'/api/nonreg-api.php?cat=all',
'/api/wevia-master-autoheal.php',
'/api/wevia-deep-test.php',
'/api/ecosystem-health.php',
'/api/openclaw-proxy.php',
'/api/architecture-index.json',
'/api/source-of-truth.json',
];
(async () => {
const t0 = Date.now();
const results = { pages: [], subs: [], apis: [], scenarios: [], summary: {} };
const browser = await puppeteer.launch({
headless: 'new',
args: ['--no-sandbox','--disable-setuid-sandbox','--disable-gpu','--disable-web-security','--ignore-certificate-errors'],
timeout: 60000
});
// ═══ PHASE 1: ALL PAGES ═══
console.log('PHASE 1: Testing ' + PAGES.length + ' pages...');
for (const pg of PAGES) {
const page = await browser.newPage();
const jsErrors = [];
page.on('pageerror', e => jsErrors.push(e.message.substring(0,80)));
page.on('console', m => { if(m.type()==='error') jsErrors.push(m.text().substring(0,80)); });
try {
const resp = await page.goto(BASE + '/' + pg, { waitUntil: 'networkidle2', timeout: 15000 });
const status = resp ? resp.status() : 0;
const size = (await page.content()).length;
const title = await page.title();
// Screenshot
const ssFile = pg.replace('.html','') + '.png';
await page.screenshot({ path: path.join(SSDIR, ssFile), fullPage: false }).catch(()=>{});
const pass = (status === 200 || status === 302) && size > 500;
results.pages.push({ page: pg, status, size, title: title.substring(0,40), jsErrors: jsErrors.length, errors: jsErrors.slice(0,3), screenshot: ssFile, pass });
console.log(` ${pass?'✅':'❌'} ${pg} ${status} ${size}b ${jsErrors.length}err`);
} catch(e) {
results.pages.push({ page: pg, status: 0, size: 0, error: e.message.substring(0,60), pass: false });
console.log(`${pg} TIMEOUT`);
}
await page.close();
}
// ═══ PHASE 2: SUBDOMAINS ═══
console.log('PHASE 2: Testing ' + SUBS.length + ' subdomains...');
for (const sub of SUBS) {
const page = await browser.newPage();
try {
const resp = await page.goto('https://' + sub + '.weval-consulting.com/', { waitUntil: 'networkidle2', timeout: 10000 });
const status = resp ? resp.status() : 0;
const pass = status === 200 || status === 302;
results.subs.push({ sub, status, pass });
console.log(` ${pass?'✅':'❌'} ${sub} ${status}`);
} catch(e) {
results.subs.push({ sub, status: 0, pass: false, error: e.message.substring(0,40) });
console.log(`${sub} TIMEOUT`);
}
await page.close();
}
// ═══ PHASE 3: APIs ═══
console.log('PHASE 3: Testing ' + APIS.length + ' APIs...');
for (const api of APIS) {
const page = await browser.newPage();
try {
const resp = await page.goto(BASE + api, { waitUntil: 'networkidle2', timeout: 10000 });
const status = resp ? resp.status() : 0;
const body = await page.content();
const isJson = body.includes('{') && body.includes('}');
const pass = status === 200 && isJson;
results.apis.push({ api, status, isJson, pass });
console.log(` ${pass?'✅':'❌'} ${api} ${status}`);
} catch(e) {
results.apis.push({ api, status: 0, pass: false });
console.log(`${api} TIMEOUT`);
}
await page.close();
}
// ═══ PHASE 4: BUSINESS SCENARIOS ═══
console.log('PHASE 4: Business scenarios...');
// Scenario 1: Login flow
{
const page = await browser.newPage();
let pass = false;
try {
await page.goto(BASE + '/login.html', { waitUntil: 'networkidle2', timeout: 10000 });
const hasForm = await page.$('input[type="password"],input[name="password"],form');
pass = !!hasForm;
await page.screenshot({ path: path.join(SSDIR, 'scenario-login.png') }).catch(()=>{});
} catch(e) {}
results.scenarios.push({ name: 'Login form exists', pass });
console.log(` ${pass?'✅':'❌'} Login form`);
await page.close();
}
// Scenario 2: WEVIA chatbot widget loads
{
const page = await browser.newPage();
let pass = false;
try {
await page.goto(BASE + '/wevia.html', { waitUntil: 'networkidle2', timeout: 10000 });
pass = (await page.content()).length > 2000;
await page.screenshot({ path: path.join(SSDIR, 'scenario-wevia-chat.png') }).catch(()=>{});
} catch(e) {}
results.scenarios.push({ name: 'WEVIA chatbot loads', pass });
console.log(` ${pass?'✅':'❌'} WEVIA chatbot`);
await page.close();
}
// Scenario 3: OpenClaw providers load
{
const page = await browser.newPage();
let pass = false;
try {
await page.goto(BASE + '/openclaw.html', { waitUntil: 'networkidle2', timeout: 15000 });
const providers = await page.$$('.provider-card,.provider,.prov-card');
pass = providers.length > 0 || (await page.content()).includes('Groq');
await page.screenshot({ path: path.join(SSDIR, 'scenario-openclaw.png') }).catch(()=>{});
} catch(e) {}
results.scenarios.push({ name: 'OpenClaw providers load', pass });
console.log(` ${pass?'✅':'❌'} OpenClaw providers`);
await page.close();
}
// Scenario 4: Architecture loads data
{
const page = await browser.newPage();
let pass = false;
try {
await page.goto(BASE + '/architecture.html', { waitUntil: 'networkidle2', timeout: 15000 });
pass = (await page.content()).includes('score') || (await page.content()).includes('Docker');
await page.screenshot({ path: path.join(SSDIR, 'scenario-architecture.png') }).catch(()=>{});
} catch(e) {}
results.scenarios.push({ name: 'Architecture data loads', pass });
console.log(` ${pass?'✅':'❌'} Architecture data`);
await page.close();
}
// Scenario 5: Enterprise model loads
{
const page = await browser.newPage();
let pass = false;
try {
await page.goto(BASE + '/enterprise-model.html', { waitUntil: 'networkidle2', timeout: 15000 });
pass = (await page.content()).length > 5000;
await page.screenshot({ path: path.join(SSDIR, 'scenario-enterprise.png') }).catch(()=>{});
} catch(e) {}
results.scenarios.push({ name: 'Enterprise model loads', pass });
console.log(` ${pass?'✅':'❌'} Enterprise model`);
await page.close();
}
// Scenario 6: OSS Discovery loads tools
{
const page = await browser.newPage();
let pass = false;
try {
await page.goto(BASE + '/oss-discovery.html', { waitUntil: 'networkidle2', timeout: 15000 });
pass = (await page.content()).includes('Groq') || (await page.content()).includes('skill');
await page.screenshot({ path: path.join(SSDIR, 'scenario-oss.png') }).catch(()=>{});
} catch(e) {}
results.scenarios.push({ name: 'OSS Discovery loads', pass });
console.log(` ${pass?'✅':'❌'} OSS Discovery`);
await page.close();
}
// ═══ SUMMARY ═══
await browser.close();
const pagesPass = results.pages.filter(p => p.pass).length;
const subsPass = results.subs.filter(s => s.pass).length;
const apisPass = results.apis.filter(a => a.pass).length;
const scenariosPass = results.scenarios.filter(s => s.pass).length;
const totalTests = results.pages.length + results.subs.length + results.apis.length + results.scenarios.length;
const totalPass = pagesPass + subsPass + apisPass + scenariosPass;
results.summary = {
ts: new Date().toISOString(),
elapsed: Math.round((Date.now() - t0) / 1000),
pages: `${pagesPass}/${results.pages.length}`,
subs: `${subsPass}/${results.subs.length}`,
apis: `${apisPass}/${results.apis.length}`,
scenarios: `${scenariosPass}/${results.scenarios.length}`,
total: `${totalPass}/${totalTests}`,
pct: Math.round(100 * totalPass / totalTests),
jsErrorPages: results.pages.filter(p => p.jsErrors > 0).map(p => p.page),
failedPages: results.pages.filter(p => !p.pass).map(p => p.page),
screenshots: SSDIR
};
fs.writeFileSync(RESULTS_FILE, JSON.stringify(results, null, 2));
console.log('\n═══════════════════════════════════');
console.log(`PAGES: ${results.summary.pages}`);
console.log(`SUBS: ${results.summary.subs}`);
console.log(`APIs: ${results.summary.apis}`);
console.log(`SCENARIOS: ${results.summary.scenarios}`);
console.log(`TOTAL: ${results.summary.total} (${results.summary.pct}%)`);
console.log(`JS ERRORS: ${results.summary.jsErrorPages.join(', ') || 'none'}`);
console.log(`FAILED: ${results.summary.failedPages.join(', ') || 'none'}`);
console.log(`TIME: ${results.summary.elapsed}s`);
console.log(`SCREENSHOTS: ${SSDIR}/`);
console.log('═══════════════════════════════════');
})();