92 lines
3.9 KiB
JavaScript
92 lines
3.9 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: 1440, height: 900 },
|
||
recordVideo: { dir: '/tmp/v90-videos/' }
|
||
});
|
||
const page = await ctx.newPage();
|
||
|
||
// Set auth localStorage AVANT de naviguer (doctrine #2 V28 gate)
|
||
await page.addInitScript(() => {
|
||
try { localStorage.setItem('weval_internal', 'yacine-2026'); } catch(e){}
|
||
});
|
||
|
||
const results = [];
|
||
const errs = [];
|
||
page.on('pageerror', e => errs.push(e.message));
|
||
|
||
async function step(name, fn) {
|
||
const t0 = Date.now();
|
||
try {
|
||
const r = await fn();
|
||
results.push({ name, status: 'OK', ms: Date.now()-t0, ...(r||{}) });
|
||
} catch (e) {
|
||
results.push({ name, status: 'FAIL', err: e.message.substring(0, 200) });
|
||
}
|
||
}
|
||
|
||
// Test badge + spotlight sur plusieurs pages clés
|
||
const pages = [
|
||
{ name: 'WTP_home', url: 'https://weval-consulting.com/weval-technology-platform.html' },
|
||
{ name: 'Master_chat', url: 'https://weval-consulting.com/wevia-master.html' },
|
||
{ name: 'CRM_V68', url: 'https://weval-consulting.com/wevia-admin-crm-v68.php' },
|
||
{ name: 'Business_KPI', url: 'https://weval-consulting.com/business-kpi-dashboard.php' }
|
||
];
|
||
|
||
for (const p of pages) {
|
||
await step(`BADGE_${p.name}`, async () => {
|
||
await page.goto(p.url, { waitUntil: 'load', timeout: 30000 });
|
||
await page.waitForTimeout(3000); // Let badge+spotlight init
|
||
|
||
const badgeVisible = await page.evaluate(() => {
|
||
// Badge creates fixed bottom-right element
|
||
return document.body.innerHTML.includes('NR ') &&
|
||
(document.body.innerHTML.includes('6σ') || document.body.innerHTML.includes('6sigma') || document.body.innerHTML.includes('disk'));
|
||
});
|
||
|
||
const spotlightLoaded = await page.evaluate(() => {
|
||
return window.__WEVAL_SPOTLIGHT_LOADED === true ||
|
||
!!document.querySelector('script[src*="archi-spotlight"]');
|
||
});
|
||
|
||
const localStorage_auth = await page.evaluate(() => {
|
||
try { return localStorage.getItem('weval_internal'); } catch(e) { return 'err'; }
|
||
});
|
||
|
||
await page.screenshot({ path: `/tmp/v90-${p.name}.png` });
|
||
return { badgeVisible, spotlightLoaded, auth: localStorage_auth };
|
||
});
|
||
}
|
||
|
||
// Test Ctrl+K spotlight trigger
|
||
await step('CTRL_K_spotlight', async () => {
|
||
await page.goto('https://weval-consulting.com/weval-technology-platform.html', { waitUntil: 'load', timeout: 30000 });
|
||
await page.waitForTimeout(2500);
|
||
await page.keyboard.press('Control+K');
|
||
await page.waitForTimeout(1500);
|
||
const overlayOpen = await page.evaluate(() => {
|
||
return !!document.querySelector('[id*="spotlight"][style*="flex"], [class*="spotlight-overlay"]') ||
|
||
document.body.innerHTML.includes('spotlight');
|
||
});
|
||
await page.screenshot({ path: '/tmp/v90-ctrlk.png' });
|
||
return { overlayOpen };
|
||
});
|
||
|
||
await ctx.close();
|
||
await browser.close();
|
||
|
||
const summary = {
|
||
ts: new Date().toISOString(),
|
||
test: 'V90 E2E Authed Badge+Spotlight',
|
||
steps: results,
|
||
page_errors: errs.slice(0, 5),
|
||
total_ok: results.filter(r=>r.status==='OK').length,
|
||
total_fail: results.filter(r=>r.status==='FAIL').length
|
||
};
|
||
fs.writeFileSync('/var/www/html/api/playwright-v90-badge-spotlight.json', JSON.stringify(summary, null, 2));
|
||
console.log(`V90 E2E: OK=${summary.total_ok}/${results.length} FAIL=${summary.total_fail} errs=${errs.length}`);
|
||
})();
|