mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-05 10:53:59 +00:00
feat(ui): render application templates as Vue views mounted before wiring
Templates listed in build/applicationViews.js expand to mount hosts, and mountApplicationViews() renders them before translation and wiring. Markup tests read the page through a server-side render helper, the i18n scanner reads view templates, and Vue preserves whitespace so views keep the exact DOM. No template is converted yet.
This commit is contained in:
1 parent
b7e7058a5c
commit
9d24945143
32 files changed
+243
-63
No files matched your search
@@ -1,11 +1,17 @@
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { readFileSync } from 'node:fs';
|
||||
import { expandApplicationHtml, APPLICATION_TEMPLATES } from '../../build/application-html.js';
|
||||
import {
|
||||
expandApplicationHtml,
|
||||
APPLICATION_TEMPLATES,
|
||||
} from '../../build/application-html.js';
|
||||
import { APPLICATION_VIEW_NAMES } from '../../build/applicationViews.js';
|
||||
import { APPLICATION_VIEWS } from '../ui/views/index.js';
|
||||
import { readApplicationHtml } from '../testSupport/applicationHtml.mjs';
|
||||
|
||||
test('the standalone document expands every component once and preserves unique element ids', () => {
|
||||
test('the standalone document expands every component once and preserves unique element ids', async () => {
|
||||
const source = readFileSync(new URL('../../index.html', import.meta.url), 'utf8');
|
||||
const html = expandApplicationHtml(source);
|
||||
const html = await readApplicationHtml();
|
||||
assert.equal([...source.matchAll(/gev:template /g)].length, APPLICATION_TEMPLATES.length);
|
||||
assert.doesNotMatch(html, /gev:template/);
|
||||
const ids = [...html.matchAll(/\sid="([^"]+)"/g)].map(match => match[1]);
|
||||
@@ -15,8 +21,21 @@ test('the standalone document expands every component once and preserves unique
|
||||
});
|
||||
|
||||
test('component selection includes only requested markup and refuses filesystem traversal', () => {
|
||||
const html = expandApplicationHtml('<!-- gev:template welcome -->\n');
|
||||
assert.match(html, /id="first-run-launcher"/);
|
||||
const html = expandApplicationHtml('<!-- gev:template hud-loading -->\n');
|
||||
assert.match(html, /id="loading-screen"/);
|
||||
assert.doesNotMatch(html, /id="cesiumContainer"/);
|
||||
assert.throws(() => expandApplicationHtml('<!-- gev:template ../../.env -->'), /Unknown application template/);
|
||||
});
|
||||
|
||||
test('views expand to mount hosts, the loading screen stays static, and every view is registered', () => {
|
||||
assert.deepEqual(Object.keys(APPLICATION_VIEWS).sort(), [...APPLICATION_VIEW_NAMES].sort());
|
||||
for (const name of APPLICATION_VIEW_NAMES) {
|
||||
assert.ok(APPLICATION_TEMPLATES.includes(name), name);
|
||||
assert.equal(
|
||||
expandApplicationHtml(`<!-- gev:template ${name} -->\n`),
|
||||
`<div class="gev-view" data-gev-view="${name}"></div>\n`,
|
||||
);
|
||||
}
|
||||
// It paints before any script runs.
|
||||
assert.ok(!APPLICATION_VIEW_NAMES.includes('hud-loading'));
|
||||
});
|
||||
Reference in new issue
Block a user