88 lines
4.2 KiB
JavaScript
88 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/v95-videos/', size: { width: 1920, height: 1080 } }
|
|
});
|
|
const page = await ctx.newPage();
|
|
|
|
// Read creds (never echo)
|
|
const users = JSON.parse(fs.readFileSync('/var/www/html/api/weval-passwords.json', 'utf8'));
|
|
const USER = 'yacine';
|
|
const PASS = users[USER].password;
|
|
|
|
// Login via UNIFIED endpoint /api/weval-auth-session.php (now sets both keys + HMAC cookie)
|
|
const loginResp = await page.request.post('https://weval-consulting.com/api/weval-auth-session.php', {
|
|
form: { action: 'login', user: USER, pass: PASS, redirect: '/weval-technology-platform.html' }
|
|
});
|
|
const loginData = await loginResp.json();
|
|
console.log('LOGIN unified:', JSON.stringify(loginData));
|
|
|
|
const pages = [
|
|
{ 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' },
|
|
{ name: 'enterprise-model', url: 'https://weval-consulting.com/enterprise-model.html' }
|
|
];
|
|
|
|
const results = [];
|
|
for (const p of pages) {
|
|
const localErrs = [];
|
|
const ph = e => localErrs.push('pageerr: ' + e.message.substring(0, 200));
|
|
page.on('pageerror', ph);
|
|
|
|
try {
|
|
await page.goto(p.url, { waitUntil: 'load', timeout: 30000 });
|
|
await page.waitForTimeout(8000);
|
|
|
|
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,
|
|
// Global arrays
|
|
data_arrays: (() => {
|
|
const res = {};
|
|
for (const k of Object.keys(window)) {
|
|
try {
|
|
const v = window[k];
|
|
if (Array.isArray(v) && v.length > 5 && v.length < 3000 && typeof v[0] === 'object' && v[0] !== null) {
|
|
const keys = Object.keys(v[0]).slice(0, 8);
|
|
const hasDead = v.some(x => x && x.rm === 'dead');
|
|
res[k] = { len: v.length, keys: keys, hasDead: hasDead };
|
|
}
|
|
} catch(e){}
|
|
}
|
|
return res;
|
|
})()
|
|
};
|
|
return out;
|
|
});
|
|
|
|
await page.screenshot({ path: `/tmp/v95-${p.name}.png`, fullPage: true });
|
|
results.push({ page: p.name, diag, errs: localErrs.slice(0, 2) });
|
|
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);
|
|
}
|
|
|
|
await ctx.close();
|
|
await browser.close();
|
|
fs.writeFileSync('/var/www/html/api/playwright-v95-unified.json', JSON.stringify(results, null, 2));
|
|
console.log('DONE');
|
|
})();
|