Files
html/api/v93_video_business.js

237 lines
9.8 KiB
JavaScript

// V93 REAL VIDEO TEST · Selenium Chrome + video recording business scenario
// Tests the ACTUAL business flow post-V91/V92 fixes
const { chromium } = require('playwright');
const fs = require('fs');
(async () => {
const browser = await chromium.launch({
headless: true,
args: ['--disable-blink-features=AutomationControlled']
});
const ctx = await browser.newContext({
viewport: { width: 1920, height: 1080 },
recordVideo: {
dir: '/tmp/v93-videos/',
size: { width: 1920, height: 1080 }
}
});
const page = await ctx.newPage();
// Set internal auth for badge/spotlight visibility
await page.addInitScript(() => {
try { localStorage.setItem('weval_internal', 'yacine-2026'); } catch(e){}
});
const scenarios = [];
const errs = [];
page.on('pageerror', e => errs.push(`[${new Date().toISOString()}] ${e.message}`));
async function scenario(name, fn) {
const t0 = Date.now();
console.log(`▶ Starting: ${name}`);
try {
const r = await fn();
const elapsed = Date.now() - t0;
scenarios.push({ name, status: 'OK', ms: elapsed, ...(r||{}) });
console.log(`${name} (${elapsed}ms)`);
} catch (e) {
scenarios.push({ name, status: 'FAIL', err: e.message.substring(0, 300) });
console.log(`${name}: ${e.message.substring(0, 100)}`);
}
}
// === SCENARIO 1: ENTERPRISE MODEL (post-V91 TDZ fix) ===
await scenario('S1_enterprise_model_post_v91', async () => {
await page.goto('https://weval-consulting.com/enterprise-model.html', { waitUntil: 'load', timeout: 30000 });
await page.waitForTimeout(5000); // Let canvas render
const diag = await page.evaluate(() => {
const canvas = document.querySelector('canvas');
const body = document.body.innerText;
return {
title: document.title,
body_len: body.length,
canvas_exists: !!canvas,
canvas_w: canvas ? canvas.width : 0,
canvas_h: canvas ? canvas.height : 0,
ag_exists: typeof window.AG !== 'undefined',
dp_exists: typeof window.DP !== 'undefined',
ag_count: typeof window.AG !== 'undefined' ? window.AG.length : 0,
dp_count: typeof window.DP !== 'undefined' ? window.DP.length : 0,
};
});
await page.screenshot({ path: '/tmp/v93-01-enterprise-model.png', fullPage: false });
return diag;
});
// === SCENARIO 2: wevia-em-big4 (Big4 VSM) ===
await scenario('S2_wevia_em_big4', async () => {
await page.goto('https://weval-consulting.com/wevia-em-big4.html', { waitUntil: 'load', timeout: 30000 });
await page.waitForTimeout(4000);
const diag = await page.evaluate(() => {
return {
title: document.title,
final_url: location.href,
body_len: document.body.innerText.length,
svg_count: document.querySelectorAll('svg').length,
canvas_count: document.querySelectorAll('canvas').length,
has_agents: document.body.innerText.match(/\d+\s*agents?/i) ? document.body.innerText.match(/\d+\s*agents?/i)[0] : null,
has_domains: ['Finance','HR','Marketing','Sales','Supply','Procurement','Production','IT','QA'].filter(d => document.body.innerText.includes(d)).length,
auth_gated: location.href.includes('/login'),
};
});
await page.screenshot({ path: '/tmp/v93-02-wevia-em-big4.png', fullPage: false });
return diag;
});
// === SCENARIO 3: Business KPI Dashboard (full flow) ===
await scenario('S3_business_kpi_full', async () => {
await page.goto('https://weval-consulting.com/business-kpi-dashboard.php', { waitUntil: 'load', timeout: 30000 });
await page.waitForTimeout(5000);
const diag = await page.evaluate(() => {
return {
title: document.title,
charts_svg: document.querySelectorAll('svg').length,
charts_canvas: document.querySelectorAll('canvas').length,
body_len: document.body.innerText.length,
has_revenue: document.body.innerText.includes('Revenue') || document.body.innerText.includes('MRR'),
badge_loaded: window.__WEVAL_META_BADGE_LOADED === true,
};
});
// Scroll to capture full page
await page.evaluate(() => window.scrollTo(0, document.body.scrollHeight));
await page.waitForTimeout(2000);
await page.screenshot({ path: '/tmp/v93-03-business-kpi.png', fullPage: true });
return diag;
});
// === SCENARIO 4: WEVIA Master chat interaction ===
await scenario('S4_wevia_master_interact', async () => {
await page.goto('https://weval-consulting.com/wevia-master.html', { waitUntil: 'load', timeout: 30000 });
await page.waitForTimeout(4000);
// Find chat input
const chatInput = await page.$('textarea, input[type="text"]');
const hasInput = chatInput !== null;
if (hasInput) {
await chatInput.fill('nr status');
await page.waitForTimeout(1000);
// Submit (try Enter or submit button)
await chatInput.press('Enter');
await page.waitForTimeout(5000); // Wait for response
}
const diag = await page.evaluate(() => {
return {
title: document.title,
hasChatInput: !!document.querySelector('textarea, input[type="text"]'),
responseCount: document.body.innerText.split('\n').filter(l => l.length > 20).length,
bodyLen: document.body.innerText.length,
};
});
await page.screenshot({ path: '/tmp/v93-04-wevia-master.png', fullPage: false });
return { ...diag, submitted: hasInput };
});
// === SCENARIO 5: CRM business data ===
await scenario('S5_crm_unified', async () => {
await page.goto('https://weval-consulting.com/crm.html', { waitUntil: 'load', timeout: 30000 });
await page.waitForTimeout(3000);
const diag = await page.evaluate(() => {
return {
title: document.title,
body_len: document.body.innerText.length,
has_deals: /deal|pipeline|opportunité|opportunity/i.test(document.body.innerText),
has_contacts: /contact|company|société/i.test(document.body.innerText),
};
});
await page.screenshot({ path: '/tmp/v93-05-crm.png', fullPage: true });
return diag;
});
// === SCENARIO 6: 15 Depts KPI ===
await scenario('S6_depts_data', async () => {
const r = await page.request.get('https://weval-consulting.com/api/wevia-v64-departments-kpi.php');
const j = await r.json();
return {
http: r.status(),
agents: `${j.summary.agents_wired}/${j.summary.agents_needed}`,
gap_pct: j.summary.gap_ratio_pct,
global_maturity: j.summary.global_maturity_pct,
depts_count: j.departments ? j.departments.length : 0,
};
});
// === SCENARIO 7: Manifest system health ===
await scenario('S7_manifest_health', async () => {
const r = await page.request.get('https://weval-consulting.com/api/weval-archi-manifest.php');
const j = await r.json();
return {
http: r.status(),
nr: `${j.meta_health.nr_combined.pass}/${j.meta_health.nr_combined.total}`,
sigma: j.meta_health.nr_combined.sigma,
disk_pct: j.meta_health.disk.used_pct,
servers: (j.servers || []).length,
databases: (j.databases || []).length,
dashboards: (j.dashboards || []).length,
};
});
// === SCENARIO 8: WTP point entrée ===
await scenario('S8_WTP_entry', async () => {
await page.goto('https://weval-consulting.com/weval-technology-platform.html', { waitUntil: 'load', timeout: 30000 });
await page.waitForTimeout(3000);
const diag = await page.evaluate(() => {
return {
title: document.title,
final_url: location.href,
has_login: location.href.includes('/login') || !!document.querySelector('input[type="password"]'),
};
});
await page.screenshot({ path: '/tmp/v93-08-wtp.png', fullPage: false });
return diag;
});
await ctx.close(); // Close context to flush video
await browser.close();
const summary = {
ts: new Date().toISOString(),
test: 'V93 REAL VIDEO BUSINESS SCENARIO',
scenarios,
js_errors: errs.slice(0, 10),
total_ok: scenarios.filter(s => s.status === 'OK').length,
total_fail: scenarios.filter(s => s.status === 'FAIL').length,
video_dir: '/tmp/v93-videos/',
screenshots: [
'/tmp/v93-01-enterprise-model.png',
'/tmp/v93-02-wevia-em-big4.png',
'/tmp/v93-03-business-kpi.png',
'/tmp/v93-04-wevia-master.png',
'/tmp/v93-05-crm.png',
'/tmp/v93-08-wtp.png',
],
};
fs.writeFileSync('/var/www/html/api/playwright-v93-video-business.json', JSON.stringify(summary, null, 2));
console.log('');
console.log('=== V93 SUMMARY ===');
console.log(`OK: ${summary.total_ok}/${scenarios.length} · FAIL: ${summary.total_fail}`);
console.log(`JS errors: ${errs.length}`);
console.log(`Video dir: ${summary.video_dir}`);
})();