99 lines
4.6 KiB
JavaScript
99 lines
4.6 KiB
JavaScript
const { chromium } = require('playwright');
|
|
const fs = require('fs');
|
|
|
|
(async () => {
|
|
// Read creds from file (doctrine: never echo password)
|
|
const passFile = '/var/www/html/api/weval-passwords.json';
|
|
if (!fs.existsSync(passFile)) { console.error('no creds'); process.exit(1); }
|
|
const users = JSON.parse(fs.readFileSync(passFile, 'utf8'));
|
|
const USER = 'yacine';
|
|
const PASS = users[USER].password;
|
|
|
|
const browser = await chromium.launch({ headless: true });
|
|
const ctx = await browser.newContext({
|
|
viewport: { width: 1920, height: 1080 },
|
|
recordVideo: { dir: '/tmp/v94-videos/', size: { width: 1920, height: 1080 } }
|
|
});
|
|
const page = await ctx.newPage();
|
|
|
|
const results = [];
|
|
const errs = {};
|
|
|
|
// 1. LOGIN via API
|
|
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:', loginData.ok ? 'SUCCESS' : 'FAIL');
|
|
if (!loginData.ok) { process.exit(1); }
|
|
|
|
// Cookie is now in the context
|
|
|
|
// 2. Scenario business: navigate each critical page + screenshot + diagnose
|
|
const pages = [
|
|
{ name: 'weval-technology-platform', url: 'https://weval-consulting.com/weval-technology-platform.html' },
|
|
{ name: 'enterprise-model', url: 'https://weval-consulting.com/enterprise-model.html' },
|
|
{ name: 'wevia-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' }
|
|
];
|
|
|
|
for (const p of pages) {
|
|
const localErrs = [];
|
|
const pagerr = e => localErrs.push('pageerr: ' + e.message.substring(0, 200));
|
|
const conerr = m => { if (m.type() === 'error') localErrs.push('con: ' + m.text().substring(0, 200)); };
|
|
page.on('pageerror', pagerr);
|
|
page.on('console', conerr);
|
|
|
|
try {
|
|
await page.goto(p.url, { waitUntil: 'load', timeout: 30000 });
|
|
await page.waitForTimeout(7000);
|
|
|
|
const diag = await page.evaluate(() => {
|
|
const diag = {
|
|
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,
|
|
// Check AG/DP exposure for agents-viewing pages
|
|
has_AG: typeof AG !== 'undefined',
|
|
AG_length: typeof AG !== 'undefined' ? AG.length : 0,
|
|
has_DP: typeof DP !== 'undefined',
|
|
DP_length: typeof DP !== 'undefined' ? DP.length : 0,
|
|
// Dead / empty stats
|
|
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,
|
|
AG_anonymous: typeof AG !== 'undefined' ? AG.filter(a => !a || !a.n || !a.n.trim()).length : 0,
|
|
// Generic data arrays
|
|
data_arrays: (() => {
|
|
const res = {};
|
|
for (const k of Object.keys(window)) {
|
|
const v = window[k];
|
|
if (Array.isArray(v) && v.length > 5 && v.length < 2000 && typeof v[0] === 'object') {
|
|
res[k] = v.length;
|
|
}
|
|
}
|
|
return res;
|
|
})()
|
|
};
|
|
return diag;
|
|
});
|
|
|
|
await page.screenshot({ path: `/tmp/v94-${p.name}.png`, fullPage: true });
|
|
results.push({ page: p.name, diag, errs: localErrs.slice(0, 3) });
|
|
} catch (e) {
|
|
results.push({ page: p.name, err: e.message.substring(0, 200) });
|
|
}
|
|
|
|
page.off('pageerror', pagerr);
|
|
page.off('console', conerr);
|
|
}
|
|
|
|
await ctx.close();
|
|
await browser.close();
|
|
fs.writeFileSync('/var/www/html/api/playwright-v94-selenium-authed.json', JSON.stringify(results, null, 2));
|
|
console.log(JSON.stringify(results, null, 2));
|
|
})();
|