auto-sync-opus46
This commit is contained in:
123
v89_e2e_business.js
Normal file
123
v89_e2e_business.js
Normal file
@@ -0,0 +1,123 @@
|
|||||||
|
// V89 E2E Business Scenario · Selenium/Playwright · login → WTP → CRM → KPIs
|
||||||
|
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/v89-videos/' }
|
||||||
|
});
|
||||||
|
const page = await ctx.newPage();
|
||||||
|
|
||||||
|
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();
|
||||||
|
const elapsed = Date.now() - t0;
|
||||||
|
results.push({ name, status: 'OK', ms: elapsed, ...(r||{}) });
|
||||||
|
console.log(`✓ ${name} (${elapsed}ms)`);
|
||||||
|
} catch (e) {
|
||||||
|
results.push({ name, status: 'FAIL', err: e.message });
|
||||||
|
console.log(`✗ ${name}: ${e.message}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// STEP 1: Login WTP
|
||||||
|
await step('S1_login_wtp', async () => {
|
||||||
|
await page.goto('https://weval-consulting.com/weval-technology-platform.html', { waitUntil: 'domcontentloaded', timeout: 30000 });
|
||||||
|
const title = await page.title();
|
||||||
|
const url = page.url();
|
||||||
|
// Detect login form
|
||||||
|
const hasLoginForm = await page.$('input[type="password"]') !== null;
|
||||||
|
return { title, url, hasLoginForm };
|
||||||
|
});
|
||||||
|
|
||||||
|
// STEP 2: If login page, authenticate
|
||||||
|
await step('S2_authenticate', async () => {
|
||||||
|
const loginInput = await page.$('input[type="password"]');
|
||||||
|
if (!loginInput) return { skipped: true, reason: 'no login required' };
|
||||||
|
// Try common fields
|
||||||
|
const userInput = await page.$('input[name="username"],input[type="email"],input[type="text"]');
|
||||||
|
if (userInput) await userInput.fill('yacine@weval-consulting.com');
|
||||||
|
await loginInput.fill('WEVAL2026');
|
||||||
|
const btn = await page.$('button[type="submit"],button');
|
||||||
|
if (btn) await btn.click();
|
||||||
|
await page.waitForTimeout(3000);
|
||||||
|
return { url: page.url() };
|
||||||
|
});
|
||||||
|
|
||||||
|
// STEP 3: Load business KPI dashboard
|
||||||
|
await step('S3_business_kpi', async () => {
|
||||||
|
await page.goto('https://weval-consulting.com/business-kpi-dashboard.php', { waitUntil: 'domcontentloaded', timeout: 20000 });
|
||||||
|
await page.waitForTimeout(2000);
|
||||||
|
const bodyText = await page.textContent('body');
|
||||||
|
const hasKPI = bodyText.includes('Revenue') || bodyText.includes('KPI') || bodyText.includes('MRR');
|
||||||
|
await page.screenshot({ path: '/tmp/v89-biz-kpi.png' });
|
||||||
|
return { textLen: bodyText.length, hasKPI };
|
||||||
|
});
|
||||||
|
|
||||||
|
// STEP 4: CRM bridge V68
|
||||||
|
await step('S4_crm_bridge', async () => {
|
||||||
|
await page.goto('https://weval-consulting.com/wevia-admin-crm-v68.php', { waitUntil: 'domcontentloaded', timeout: 20000 });
|
||||||
|
await page.waitForTimeout(2000);
|
||||||
|
await page.screenshot({ path: '/tmp/v89-crm.png' });
|
||||||
|
return { url: page.url() };
|
||||||
|
});
|
||||||
|
|
||||||
|
// STEP 5: WEVIA Master chat
|
||||||
|
await step('S5_wevia_master', async () => {
|
||||||
|
await page.goto('https://weval-consulting.com/wevia-master.html', { waitUntil: 'domcontentloaded', timeout: 20000 });
|
||||||
|
await page.waitForTimeout(3000);
|
||||||
|
const hasChat = await page.$('[id*="chat"],[class*="chat"],textarea,input[type="text"]') !== null;
|
||||||
|
await page.screenshot({ path: '/tmp/v89-master.png' });
|
||||||
|
return { hasChat };
|
||||||
|
});
|
||||||
|
|
||||||
|
// STEP 6: 15 Depts KPI
|
||||||
|
await step('S6_depts_kpi', async () => {
|
||||||
|
const r = await page.goto('https://weval-consulting.com/api/wevia-v64-departments-kpi.php', { timeout: 15000 });
|
||||||
|
const status = r.status();
|
||||||
|
const body = await r.text();
|
||||||
|
const j = JSON.parse(body);
|
||||||
|
return { status, agents_pct: j.summary.gap_ratio_pct, global_maturity: j.summary.global_maturity_pct };
|
||||||
|
});
|
||||||
|
|
||||||
|
// STEP 7: Archi Manifest
|
||||||
|
await step('S7_manifest', async () => {
|
||||||
|
const r = await page.goto('https://weval-consulting.com/api/weval-archi-manifest.php', { timeout: 10000 });
|
||||||
|
const body = await r.text();
|
||||||
|
const j = JSON.parse(body);
|
||||||
|
return { status: r.status(), nr: `${j.meta_health.nr_combined.pass}/${j.meta_health.nr_combined.total}` };
|
||||||
|
});
|
||||||
|
|
||||||
|
// STEP 8: em-live-kpi perf check (V85 cached)
|
||||||
|
await step('S8_em_live_cached', async () => {
|
||||||
|
const t0 = Date.now();
|
||||||
|
const r = await page.goto('https://weval-consulting.com/api/em-live-kpi.php', { timeout: 15000 });
|
||||||
|
const ms = Date.now() - t0;
|
||||||
|
return { status: r.status(), fetch_ms: ms, cache_hit: ms < 1000 };
|
||||||
|
});
|
||||||
|
|
||||||
|
await ctx.close();
|
||||||
|
await browser.close();
|
||||||
|
|
||||||
|
const summary = {
|
||||||
|
ts: new Date().toISOString(),
|
||||||
|
test: 'V89 E2E Business Scenario',
|
||||||
|
steps: results,
|
||||||
|
page_errors: errs,
|
||||||
|
total_ok: results.filter(r => r.status === 'OK').length,
|
||||||
|
total_fail: results.filter(r => r.status === 'FAIL').length,
|
||||||
|
videos_dir: '/tmp/v89-videos/',
|
||||||
|
screenshots: ['v89-biz-kpi.png', 'v89-crm.png', 'v89-master.png']
|
||||||
|
};
|
||||||
|
|
||||||
|
fs.writeFileSync('/var/www/html/api/playwright-v89-business-latest.json', JSON.stringify(summary, null, 2));
|
||||||
|
console.log('\n=== SUMMARY ===');
|
||||||
|
console.log(`OK: ${summary.total_ok}/${results.length} · FAIL: ${summary.total_fail} · errors: ${errs.length}`);
|
||||||
|
})();
|
||||||
Reference in New Issue
Block a user