Spec v1.2, Logosmental-based design direction and tokens, pnpm monorepo (apps/demo, packages/data|features|i18n|db/seed), student + admin screens in 4 locales, simulated ArifPay checkout on the real order state machine, artifact inline/check tools, domain rule checks and UI audit fixes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
57 lines
4.2 KiB
JavaScript
57 lines
4.2 KiB
JavaScript
// Click-everything smoke test (SPEC §13.5, L3) against the inlined demo with an in-memory runtime.
|
|
// Usage: node packages/db/seed/demo-seed.mjs /tmp/seed && node tools/preview/smoke.mjs "$PWD/dist/demo.html" /tmp/seed
|
|
// Needs puppeteer-core and a local Chrome (not wired into CI yet; W1-14 replaces this with Playwright).
|
|
import puppeteer from 'puppeteer-core'; import fs from 'fs'; import path from 'path';
|
|
const [file, seedDir] = process.argv.slice(2);
|
|
const seed = {}; for (const col of fs.readdirSync(seedDir)) for (const f of fs.readdirSync(path.join(seedDir, col))) seed[`${col}/${f.replace('.json', '')}`] = JSON.parse(fs.readFileSync(path.join(seedDir, col, f), 'utf8'));
|
|
seed['students/u_reviewer'] = { ...seed['students/sample-2'], id: 'u_reviewer', name: 'Kirubel Kibru', isSample: false };
|
|
const mock = fs.readFileSync(new URL('./runtime-mock.js', import.meta.url), 'utf8');
|
|
const routes = [
|
|
['', 1], ['#/am/signin', 1], ['#/am'], ['#/am/courses'], ['#/en/course/makeup-foundations'], ['#/am/course/bridal-makeup'], ['#/am/learn/makeup-foundations/les-f3'],
|
|
['#/am/learn/bridal-makeup/les-b4'], ['#/am/checkout/bridal-makeup'], ['#/am/my'], ['#/am/progress'], ['#/am/notifications'], ['#/am/help'], ['#/am/profile'],
|
|
['#/admin'], ['#/admin/analytics'], ['#/admin/courses'], ['#/admin/courses/crs-foundations/details'], ['#/admin/courses/crs-foundations/curriculum'], ['#/admin/courses/crs-business/details'],
|
|
['#/admin/categories'], ['#/admin/students'], ['#/admin/students/sample-1'], ['#/admin/orders'], ['#/admin/notifications'], ['#/admin/issues'], ['#/admin/settings'], ['#/admin/admins'], ['#/admin/audit'],
|
|
];
|
|
const b = await puppeteer.launch({ executablePath: '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome', headless: true });
|
|
const problems = []; let clicks = 0;
|
|
async function open(p, hash, signedOut) {
|
|
await p.goto('about:blank');
|
|
await p.goto('file://' + file + hash, { waitUntil: 'domcontentloaded' }); await new Promise((r) => setTimeout(r, 500));
|
|
}
|
|
async function worker(list) {
|
|
const p = await b.newPage(); await p.setViewport({ width: 1280, height: 900 });
|
|
let errs = []; p.on('pageerror', (e) => errs.push(e.message));
|
|
await p.evaluateOnNewDocument((s) => { window.__SEED__ = s; }, seed);
|
|
await p.evaluateOnNewDocument(mock);
|
|
for (const [hash, signedOut] of list) {
|
|
await p.evaluateOnNewDocument((so) => { try { so ? localStorage.setItem('lms.signedOut', '1') : localStorage.removeItem('lms.signedOut'); } catch {} }, !!signedOut);
|
|
await open(p, hash, signedOut);
|
|
if (errs.length) { problems.push(`${hash} LOAD ERROR ${errs}`); errs = []; }
|
|
const main = await p.evaluate(() => (document.querySelector('main')?.innerText ?? '').trim().length);
|
|
if (main < 20) problems.push(`${hash} blank main region`);
|
|
const n = await p.evaluate(() => [...document.querySelectorAll('button, a[href^="#"]')].filter((e) => e.offsetParent && !e.disabled).length);
|
|
for (let i = 0; i < Math.min(n, 60); i++) {
|
|
await open(p, hash, signedOut); errs = [];
|
|
const res = await p.evaluate(async (i) => {
|
|
const els = [...document.querySelectorAll('button, a[href^="#"]')].filter((e) => e.offsetParent && !e.disabled);
|
|
const el = els[i]; if (!el) return null;
|
|
const label = (el.getAttribute('aria-label') || el.innerText || '').trim().slice(0, 40);
|
|
if (/feedback|አስተያየት/i.test(label) || el.closest('.s-tabs')) return { label, skip: true };
|
|
const before = document.body.innerHTML.length + location.hash + document.body.innerText;
|
|
el.click(); await new Promise((r) => setTimeout(r, 350));
|
|
const after = document.body.innerHTML.length + location.hash + document.body.innerText;
|
|
return { label, changed: before !== after };
|
|
}, i);
|
|
clicks++;
|
|
if (!res || res.skip) continue;
|
|
if (errs.length) problems.push(`${hash} [${res.label}] ERROR ${errs[0]}`);
|
|
else if (!res.changed) problems.push(`${hash} [${res.label}] no visible change`);
|
|
}
|
|
}
|
|
await p.close();
|
|
}
|
|
const chunks = [[], [], [], []]; routes.forEach((r, i) => chunks[i % 4].push(r));
|
|
await Promise.all(chunks.map(worker));
|
|
await b.close();
|
|
console.log(`clicked ${clicks} controls on ${routes.length} routes`); console.log(problems.length ? problems.join('\n') : 'no problems');
|