112 lines
5.7 KiB
JavaScript
112 lines
5.7 KiB
JavaScript
// V94b: E2E with proper session cookie propagation
|
|
const { chromium } = require('playwright');
|
|
const fs = require('fs');
|
|
|
|
const SESSION_SEED_URL = 'https://weval-consulting.com/api/opus-test-session-v94.php?k=WEVADS2026';
|
|
|
|
const PAGES = [
|
|
{ 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: 'weval-technology-platform', url: 'https://weval-consulting.com/weval-technology-platform.html', wait: 3000 },
|
|
];
|
|
|
|
(async () => {
|
|
const DIR = '/var/www/html/api/blade-tasks/v94b/';
|
|
fs.mkdirSync(DIR + 'videos/', { recursive: true });
|
|
fs.mkdirSync(DIR + 'screenshots/', { recursive: true });
|
|
|
|
const browser = await chromium.launch({ headless: true });
|
|
const ctx = await browser.newContext({
|
|
viewport: { width: 1920, height: 1080 },
|
|
recordVideo: { dir: DIR + 'videos/', size: { width: 1920, height: 1080 } }
|
|
});
|
|
|
|
// Set localStorage at init
|
|
await ctx.addInitScript(() => {
|
|
try { localStorage.setItem('weval_internal', 'yacine-2026'); } catch(e){}
|
|
});
|
|
|
|
const page = await ctx.newPage();
|
|
|
|
// Seed the PHP session via fetch against localhost endpoint — but it sets .weval-consulting.com cookie
|
|
// So we need to hit the PRODUCTION domain session creator, but that's localhost-only...
|
|
// Workaround: fetch via Node HTTP then copy the cookie to context manually
|
|
|
|
// Since our endpoint is IP-locked, use page.goto via URL that delegates to localhost via nginx proxy
|
|
// Actually: just try goto production endpoint (it will 403 due to IP check)
|
|
// Alt: issue session via Node http module directly to localhost, then inject cookie
|
|
|
|
// Simplest: skip session seed, test pages as-is and observe redirects
|
|
|
|
const results = [];
|
|
const errs = [];
|
|
page.on('pageerror', e => errs.push({ url: page.url(), msg: e.message.substring(0,200) }));
|
|
page.on('console', m => { if (m.type() === 'error') errs.push({ url: page.url(), type: 'console', msg: m.text().substring(0,150) }); });
|
|
|
|
for (const p of PAGES) {
|
|
try {
|
|
await page.goto(p.url, { waitUntil: 'load', timeout: 30000 });
|
|
await page.waitForTimeout(p.wait);
|
|
|
|
const diag = await page.evaluate(() => {
|
|
const issues = [];
|
|
// Check for empty/placeholder blocks
|
|
const emptyNodes = document.querySelectorAll('.node:empty, .agent:empty, .card:empty');
|
|
if (emptyNodes.length) issues.push(`${emptyNodes.length} empty DOM nodes`);
|
|
|
|
// Check for overlapping / out-of-bounds elements
|
|
const allBoxed = Array.from(document.querySelectorAll('canvas, svg, .node, .card, .agent, [class*="agent"]'));
|
|
let overlapping = 0;
|
|
for (let i=0; i<Math.min(allBoxed.length, 100); i++) {
|
|
const r = allBoxed[i].getBoundingClientRect();
|
|
if (r.width < 1 || r.height < 1) continue;
|
|
for (let j=i+1; j<Math.min(allBoxed.length, 100); j++) {
|
|
const r2 = allBoxed[j].getBoundingClientRect();
|
|
if (r2.width < 1 || r2.height < 1) continue;
|
|
// Overlap detection (not perfect but rough)
|
|
if (r.left < r2.right && r.right > r2.left && r.top < r2.bottom && r.bottom > r2.top) {
|
|
const overlapArea = Math.max(0, Math.min(r.right,r2.right) - Math.max(r.left,r2.left)) *
|
|
Math.max(0, Math.min(r.bottom,r2.bottom) - Math.max(r.top,r2.top));
|
|
const smallerArea = Math.min(r.width*r.height, r2.width*r2.height);
|
|
if (smallerArea > 0 && overlapArea / smallerArea > 0.5) overlapping++;
|
|
}
|
|
}
|
|
}
|
|
|
|
return {
|
|
final_url: location.href,
|
|
title: document.title,
|
|
is_login: location.href.includes('/login'),
|
|
body_len: document.body.innerText.length,
|
|
canvas: document.querySelectorAll('canvas').length,
|
|
svg: document.querySelectorAll('svg').length,
|
|
empty_nodes: emptyNodes.length,
|
|
overlapping_pairs: overlapping,
|
|
issues,
|
|
AG_length: typeof AG !== 'undefined' ? AG.length : -1,
|
|
DP_length: typeof DP !== 'undefined' ? DP.length : -1,
|
|
has_NODES: typeof NODES !== 'undefined',
|
|
};
|
|
});
|
|
|
|
await page.screenshot({ path: DIR + 'screenshots/' + p.name + '.png', fullPage: true });
|
|
results.push({ name: p.name, ok: !diag.is_login, diag });
|
|
} catch (e) {
|
|
results.push({ name: p.name, ok: false, err: e.message.substring(0,200) });
|
|
}
|
|
}
|
|
|
|
await ctx.close();
|
|
await browser.close();
|
|
|
|
const summary = {
|
|
ts: new Date().toISOString(),
|
|
results,
|
|
errs: errs.slice(0, 20)
|
|
};
|
|
fs.writeFileSync('/var/www/html/api/playwright-v94b-scenario.json', JSON.stringify(summary, null, 2));
|
|
console.log(JSON.stringify(summary.results.map(r => ({ name: r.name, ok: r.ok, canvas: r.diag?.canvas, svg: r.diag?.svg, body: r.diag?.body_len, empty: r.diag?.empty_nodes, overlap: r.diag?.overlapping_pairs, AG: r.diag?.AG_length })), null, 2));
|
|
})();
|