47 lines
1.5 KiB
JavaScript
47 lines
1.5 KiB
JavaScript
// Runtime smoke test for the embedded Quant-UX engine with a minimal DOM stub.
|
|
const fs = require('fs');
|
|
|
|
const html = fs.readFileSync(process.argv[2], 'utf-8');
|
|
const m = html.match(/<script>\s*(window\.QUX_MODEL.*?)<\/script>/s);
|
|
if (!m) { console.error('no engine script found'); process.exit(1); }
|
|
|
|
function makeEl() {
|
|
const el = {
|
|
style: {}, dataset: {}, children: [],
|
|
classList: { add() {}, remove() {} },
|
|
appendChild(c) { el.children.push(c); return c; },
|
|
addEventListener() {},
|
|
set textContent(v) { el._text = v; }, get textContent() { return el._text || ''; },
|
|
set innerHTML(v) { el._html = v; }, get innerHTML() { return el._html || ''; },
|
|
};
|
|
return el;
|
|
}
|
|
|
|
const stage = makeEl();
|
|
global.window = {
|
|
innerWidth: 1920, innerHeight: 1080,
|
|
addEventListener() {},
|
|
};
|
|
global.document = {
|
|
getElementById(id) {
|
|
if (id === 'stage') return stage;
|
|
return makeEl();
|
|
},
|
|
createElement() { return makeEl(); },
|
|
};
|
|
|
|
const errors = [];
|
|
try {
|
|
eval(m[1]); // runs the IIFE -> renders start screen
|
|
const rendered = stage.children.length;
|
|
const screenEl = stage.children[0];
|
|
console.log('runtime OK, stage children:', rendered);
|
|
if (screenEl) console.log('screen holder styles:', JSON.stringify({
|
|
width: screenEl.style.width, height: screenEl.style.height, zIndex: screenEl.style.zIndex,
|
|
}));
|
|
console.log('widgets rendered on start screen:', screenEl ? screenEl.children.length : 0);
|
|
} catch (e) {
|
|
errors.push(e);
|
|
}
|
|
if (errors.length) { console.error('RUNTIME ERRORS:', errors); process.exit(1); }
|