RezinaLMS-CustomerEnd/tools/artifact-check.mjs
kirukib 92cc6a8ddf feat: mobile-first landing pass, lesson bar, dark default, simulated courses
Inspo MCP references: Hyper Effekt / Ferrari (photo hero), Coursera / Babbel (phone rails).
- Hero: headline set on a full-bleed, slowly scrolling reel of portraits
- How it works + payment panels replaced by three photo step cards; pay marks inside step 2
- Phones: category and step cards swipe as rails, stats in one row, header fits 360-390px
- Lesson bar (Previous / n of N / Next lesson) replaces the app tabs inside a course below 1024px;
  app tabs show only when signed in
- Header logo crossfades from wordmark to monogram on scroll
- Language picker is one dropdown (header and footer)
- Dark theme by default; saved choice still wins
- Demo banner removed
- Footer: "Powered by Yaltopia Tech" with a shine sweep
- Seed: three more simulated courses (soft glam, traditional Habesha, building your clientele)
- artifact-check: data: URIs (the favicon) aren't network requests

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-20 12:00:24 +03:00

34 lines
2.1 KiB
JavaScript

// CI check: loads the inlined demo in jsdom with ALL network blocked and fails if the page
// tries to fetch or load any script (e.g. a lazy chunk or an RSC .txt payload), or throws.
// Usage: node tools/artifact-check.mjs dist/demo.html
import { JSDOM, VirtualConsole } from 'jsdom'; import fs from 'fs';
const file = process.argv[2] || 'dist/demo.html';
const errors = [], network = [];
const vc = new VirtualConsole();
vc.on('jsdomError', (e) => errors.push(String(e.message)));
const dom = new JSDOM(fs.readFileSync(file, 'utf8'), {
runScripts: 'dangerously', url: 'https://artifact.local/', virtualConsole: vc, pretendToBeVisual: true,
beforeParse(w) {
Object.assign(w, { TextEncoder, TextDecoder, MessageChannel, ReadableStream, structuredClone });
w.fetch = (u) => { network.push(`fetch ${u}`); return Promise.reject(new Error('blocked')); };
const create = w.document.createElement.bind(w.document);
w.document.createElement = (tag, ...rest) => {
const el = create(tag, ...rest);
if (tag === 'script') {
const d = Object.getOwnPropertyDescriptor(w.HTMLScriptElement.prototype, 'src');
Object.defineProperty(el, 'src', { set(v) { network.push(`script ${v}`); d.set.call(el, v); }, get() { return d.get.call(el); } });
}
return el;
};
},
});
const w = dom.window;
await new Promise((r) => setTimeout(r, 2000));
for (const route of ['#/am', '#/am/courses', '#/en/help']) { w.location.hash = route; await new Promise((r) => setTimeout(r, 300)); }
// React can re-insert hoisted <link>/<script> tags at hydration; jsdom doesn't fetch them, so scan the DOM too.
for (const el of w.document.querySelectorAll('link[href],script[src]')) network.push(`${el.tagName.toLowerCase()} ${el.getAttribute('href') ?? el.getAttribute('src')}`);
const allowed = (u) => /^(link|script) data:/.test(u) || /^link https:\/\/fonts\.(googleapis|gstatic)\.com/.test(u) || /cdnjs\.cloudflare\.com|cdn\.jsdelivr\.net\/npm|fonts\.googleapis\.com|fonts\.gstatic\.com/.test(u);
const bad = network.filter((n) => !allowed(n));
console.log({ networkAttempts: bad, errors });
process.exit(bad.length || errors.length ? 1 : 0);