90 lines
4.2 KiB
JavaScript
90 lines
4.2 KiB
JavaScript
const { chromium } = require('playwright');
|
|
const fs = require('fs');
|
|
|
|
(async () => {
|
|
const browser = await chromium.launch({ headless: true });
|
|
const ctx = await browser.newContext({
|
|
viewport: { width: 1920, height: 1080 },
|
|
recordVideo: { dir: '/tmp/v94-real-videos/', size: { width: 1920, height: 1080 } }
|
|
});
|
|
const page = await ctx.newPage();
|
|
|
|
// 1. LOGIN via proper /login endpoint
|
|
console.log('LOGIN via /login...');
|
|
const loginResp = await page.request.post('https://weval-consulting.com/login', {
|
|
form: { user: 'yacine', pass: 'Weval@2026', r: '/weval-technology-platform.html' },
|
|
maxRedirects: 0
|
|
}).catch(e => ({ status: () => 302, headers: () => ({}) }));
|
|
console.log('Login status:', loginResp.status());
|
|
|
|
// The cookie is now in context
|
|
|
|
const pages = [
|
|
{ name: 'technology-platform', url: 'https://weval-consulting.com/weval-technology-platform.html' },
|
|
{ name: 'enterprise-model', url: 'https://weval-consulting.com/enterprise-model.html' },
|
|
{ name: 'em-big4', url: 'https://weval-consulting.com/wevia-em-big4.html' },
|
|
{ name: 'agents-archi', url: 'https://weval-consulting.com/agents-archi.html' },
|
|
{ name: 'value-streaming', url: 'https://weval-consulting.com/value-streaming.html' }
|
|
];
|
|
|
|
const results = [];
|
|
|
|
for (const p of pages) {
|
|
const localErrs = [];
|
|
const ph = e => localErrs.push('pageerr: ' + e.message.substring(0, 150));
|
|
const ch = m => { if (m.type() === 'error') localErrs.push('con: ' + m.text().substring(0, 150)); };
|
|
page.on('pageerror', ph);
|
|
page.on('console', ch);
|
|
|
|
try {
|
|
await page.goto(p.url, { waitUntil: 'load', timeout: 30000 });
|
|
await page.waitForTimeout(8000); // Let JS run
|
|
|
|
const diag = await page.evaluate(() => {
|
|
const out = {
|
|
url: location.href,
|
|
title: document.title,
|
|
body_len: document.body.innerText.length,
|
|
is_login: location.href.includes('login'),
|
|
canvas_count: document.querySelectorAll('canvas').length,
|
|
svg_count: document.querySelectorAll('svg').length,
|
|
div_count: document.querySelectorAll('div').length,
|
|
has_AG: typeof AG !== 'undefined',
|
|
AG_length: typeof AG !== 'undefined' ? AG.length : 0,
|
|
AG_dead: typeof AG !== 'undefined' ? AG.filter(a => a && a.rm === 'dead').length : 0,
|
|
AG_no_actions: typeof AG !== 'undefined' ? AG.filter(a => a && (!a.act || a.act.length === 0 || (a.act[0] === 'Sync' && a.act.length === 4))).length : 0,
|
|
DP_length: typeof DP !== 'undefined' ? DP.length : 0,
|
|
// Scan global arrays to find agent data in big4/vs
|
|
data_arrays_big: (() => {
|
|
const res = {};
|
|
for (const k of Object.keys(window)) {
|
|
try {
|
|
const v = window[k];
|
|
if (Array.isArray(v) && v.length > 10 && v.length < 3000 && typeof v[0] === 'object' && v[0] !== null) {
|
|
res[k] = { len: v.length, sample_keys: Object.keys(v[0]).slice(0, 8) };
|
|
}
|
|
} catch(e){}
|
|
}
|
|
return res;
|
|
})()
|
|
};
|
|
return out;
|
|
});
|
|
|
|
await page.screenshot({ path: `/tmp/v94-real-${p.name}.png`, fullPage: true });
|
|
results.push({ page: p.name, diag, errs: localErrs.slice(0, 3) });
|
|
console.log(`${p.name}: login=${diag.is_login} body=${diag.body_len} AG=${diag.AG_length} dead=${diag.AG_dead}`);
|
|
} catch (e) {
|
|
results.push({ page: p.name, err: e.message.substring(0, 200) });
|
|
}
|
|
|
|
page.off('pageerror', ph);
|
|
page.off('console', ch);
|
|
}
|
|
|
|
await ctx.close();
|
|
await browser.close();
|
|
fs.writeFileSync('/var/www/html/api/playwright-v94-real-authed.json', JSON.stringify(results, null, 2));
|
|
console.log('Done. Results saved.');
|
|
})();
|