110 lines
5.5 KiB
JavaScript
Executable File
110 lines
5.5 KiB
JavaScript
Executable File
|
|
const { chromium } = require('playwright');
|
|
const fs = require('fs');
|
|
|
|
(async () => {
|
|
const browser = await chromium.launch({headless:true, args:['--no-sandbox','--disable-dev-shm-usage','--use-gl=swiftshader']});
|
|
const ctxOpts = {viewport:{width:1440,height:900}};
|
|
if (fs.existsSync('/opt/weval-l99/sso-state.json')) ctxOpts.storageState = '/opt/weval-l99/sso-state.json';
|
|
const ctx = await browser.newContext(ctxOpts);
|
|
const page = await ctx.newPage();
|
|
|
|
const log = [];
|
|
function step(name, ok, details) {
|
|
log.push({name, ok, details});
|
|
console.log((ok?'OK':'FAIL') + ' ' + name + ': ' + (details||''));
|
|
}
|
|
|
|
try {
|
|
await page.goto('https://weval-consulting.com/weval-technology-platform.html', {waitUntil:'domcontentloaded', timeout:30000});
|
|
await page.waitForTimeout(5000);
|
|
step('1.WTP_loads', true, (await page.title()).substring(0,60));
|
|
|
|
step('1b.WTP_mega_banner', !!(await page.$('#wtp-mega-master-banner')), 'banner check');
|
|
step('1c.WTP_kpi_widget', !!(await page.$('#wtp-pilotage-kpi-live')), 'widget check');
|
|
|
|
const kpiVals = await page.$$eval('.wtp-kpi-val, .v80-kpi-val, .v80-kpi', els =>
|
|
els.map(e => e.textContent.trim()).filter(t => t && t.length < 30).slice(0,10));
|
|
step('1d.WTP_kpi_values', kpiVals.length > 5, kpiVals.length + ' vals');
|
|
|
|
// Test 2 amélioré : verify le LIEN existe (sans cliquer dessus, scrolling fail à cause JS)
|
|
const megaLinkExists = await page.$('#wtp-mega-master-banner a[href*="weval-mega-master"]');
|
|
step('2.Mega_link_in_banner', !!megaLinkExists, megaLinkExists ? 'link present clickable' : 'NOT FOUND');
|
|
} catch(e) { step('1-2.WTP_block', false, e.message.substring(0,100)); }
|
|
|
|
try {
|
|
await page.goto('https://weval-consulting.com/weval-mega-master.html', {waitUntil:'domcontentloaded', timeout:30000});
|
|
await page.waitForTimeout(2000);
|
|
await page.fill('#q', 'ethica');
|
|
await page.waitForTimeout(800);
|
|
const visible = await page.$$eval('.lnk', els => els.filter(e => e.offsetParent !== null).length);
|
|
step('3.Mega_search_ethica', visible > 0 && visible < 100, visible + ' results');
|
|
} catch(e) { step('3.Mega', false, e.message.substring(0,80)); }
|
|
|
|
try {
|
|
await page.goto('https://weval-consulting.com/arsenal-master.html', {waitUntil:'domcontentloaded', timeout:30000});
|
|
await page.waitForTimeout(2000);
|
|
const arsenalLinks = await page.$$eval('a.lnk', a => a.length);
|
|
step('4.Arsenal_Master_links', arsenalLinks >= 180, arsenalLinks + ' links');
|
|
const ext = await page.$$('.ext a');
|
|
step('4b.Arsenal_ext_services', ext.length === 3, ext.length + ' ext services');
|
|
} catch(e) { step('4.Arsenal', false, e.message.substring(0,80)); }
|
|
|
|
try {
|
|
await page.goto('https://weval-consulting.com/arsenal-proxy/youtube-factory.html', {waitUntil:'domcontentloaded', timeout:30000});
|
|
await page.waitForTimeout(2500);
|
|
const t = await page.title();
|
|
const content = await page.content();
|
|
const hasHonest = t.toLowerCase().includes('honest');
|
|
const noFakes = !content.includes('58,800') && !content.includes('4,030,000');
|
|
step('5.YouTube_honest', hasHonest && noFakes, 'honest=' + hasHonest + ' no_fakes=' + noFakes);
|
|
} catch(e) { step('5.YT', false, e.message.substring(0,80)); }
|
|
|
|
try {
|
|
await page.goto('https://weval-consulting.com/arsenal-history/', {waitUntil:'domcontentloaded', timeout:20000});
|
|
await page.waitForTimeout(1500);
|
|
const h = await page.$$('.card');
|
|
step('6.History_6_cards', h.length === 6, h.length + ' cards');
|
|
} catch(e) { step('6.History', false, e.message.substring(0,80)); }
|
|
|
|
try {
|
|
await page.goto('https://weval-consulting.com/wevia-master.html', {waitUntil:'domcontentloaded', timeout:30000});
|
|
await page.waitForTimeout(3500);
|
|
const t = await page.title();
|
|
const inp = await page.$('input[type="text"], textarea');
|
|
const btns = await page.$$('button');
|
|
step('7.WEVIA_Master', t.includes('WEVIA') && inp && btns.length > 5, t + ' btns=' + btns.length);
|
|
} catch(e) { step('7.WEVIA', false, e.message.substring(0,80)); }
|
|
|
|
try {
|
|
await page.goto('https://weval-consulting.com/all-ia-hub.html', {waitUntil:'domcontentloaded', timeout:20000});
|
|
await page.waitForTimeout(2500);
|
|
const btns = await page.$$('button');
|
|
step('8.All_IA_Hub', btns.length >= 30, btns.length + ' buttons');
|
|
} catch(e) { step('8.IAHub', false, e.message.substring(0,80)); }
|
|
|
|
try {
|
|
await page.goto('https://weval-consulting.com/e2e-dashboard.html', {waitUntil:'domcontentloaded', timeout:20000});
|
|
await page.waitForTimeout(2000);
|
|
const t = await page.title();
|
|
const shots = await page.$$('img[src*="screenshots"]');
|
|
step('9.E2E_Dashboard_self', t.includes('E2E') && shots.length === 8, t + ' shots=' + shots.length);
|
|
} catch(e) { step('9.E2E', false, e.message.substring(0,80)); }
|
|
|
|
// API tests
|
|
for (const u of ['/api/nonreg-api.php?cat=all', '/api/wevia-v83-business-kpi.php?action=summary', '/api/wevia-v64-departments-kpi.php']) {
|
|
try {
|
|
const r = await page.evaluate(url => fetch(url).then(r => ({ok: r.ok, status: r.status})), u);
|
|
step('API_' + u.split('/').pop().substring(0,30), r.ok, 'HTTP ' + r.status);
|
|
} catch(e) { step('API_check', false, e.message.substring(0,80)); }
|
|
}
|
|
|
|
const passed = log.filter(l => l.ok).length;
|
|
const total = log.length;
|
|
console.log('\n=== ' + passed + '/' + total + ' = ' + Math.round(100*passed/total) + '% ===');
|
|
|
|
fs.writeFileSync('/tmp/scen_final.json', JSON.stringify({passed, total, log, ts: new Date().toISOString()}, null, 2));
|
|
|
|
await browser.close();
|
|
})();
|