mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-20 10:12:18 +00:00
Vue kit: the entity card's buttons are UiButtons and its glyphs UiIcons
The four preview buttons (Photos, Route, 3D, Cockpit view) are pressed toggles with the active class, and Follow is one with its own on class, in place of hand-written aria-pressed. The cockpit entry, Fly to, Ask GEV, the camera preview's bigger-view and More info buttons and the nearby lists' rows are ghost UiButtons. Every Material glyph on the card, in the camera preview and in the nearby lists is a UiIcon sized by the card's own rules. Ask GEV's chat bubble stays inline SVG, since no Material symbol the page loads draws it. A guard test pins it, and the migration notes say so. Co-authored-by: Manjunath Paparaju <[email protected]>
This commit is contained in:
1 parent
05976ecd06
commit
bd944ecd04
6 files changed
+146
-45
No files matched your search
@@ -0,0 +1,84 @@
|
||||
// The entity card's buttons and Material glyphs are the kit's: neither its
|
||||
// template nor the camera preview and nearby lists it renders hand-writes a
|
||||
// <button> or a Material Symbols span. The Ask GEV button's chat bubble is
|
||||
// not a Material symbol the page loads, so it stays drawn as inline SVG; the
|
||||
// hero views (model, route globe, cockpit view, ground view, graphs) draw
|
||||
// their own pictures and have no controls.
|
||||
import { test } from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { readFileSync } from 'node:fs';
|
||||
|
||||
/** A view's template block: everything outside script and style. */
|
||||
function template(file) {
|
||||
const source = readFileSync(
|
||||
new URL(`../views/panels/${file}`, import.meta.url),
|
||||
'utf8',
|
||||
);
|
||||
return source.replace(/<(script|style)\b[\s\S]*?<\/\1\s*>/g, '');
|
||||
}
|
||||
const card = template('EntityCard.vue');
|
||||
const camera = template('CctvPreview.vue');
|
||||
const nearby = template('SpotConditions.vue');
|
||||
const heroViews = [
|
||||
'AircraftModelHero.vue',
|
||||
'RouteGlobe.vue',
|
||||
'FlightCockpitView.vue',
|
||||
'SatelliteGroundView.vue',
|
||||
'PreviewHud.vue',
|
||||
'AltitudeGraph.vue',
|
||||
].map(template);
|
||||
|
||||
test('the entity card hand-writes no button; each is a UiButton', () => {
|
||||
for (const markup of [card, camera, nearby, ...heroViews])
|
||||
assert.deepEqual(markup.match(/<button\b/gi) ?? [], []);
|
||||
// Photos, Route, 3D, Cockpit view, the cockpit entry, Fly to, Follow and
|
||||
// Ask GEV.
|
||||
assert.equal(card.match(/<UiButton\b/g)?.length, 8);
|
||||
assert.equal(card.match(/<UiCloseButton\b/g)?.length, 1);
|
||||
// A camera's bigger view and More info; its popup closes with a UiCloseButton.
|
||||
assert.equal(camera.match(/<UiButton\b/g)?.length, 2);
|
||||
assert.equal(camera.match(/<UiCloseButton\b/g)?.length, 1);
|
||||
// The traffic, hazard, alert and other nearby rows.
|
||||
assert.equal(nearby.match(/<UiButton\b/g)?.length, 4);
|
||||
});
|
||||
|
||||
test('the preview switch and Follow are pressed toggles with their classes', () => {
|
||||
const previews = card.match(/<UiButton v-if="\w+" :pressed[^>]*>/g) ?? [];
|
||||
assert.equal(previews.length, 4);
|
||||
for (const button of previews) {
|
||||
assert.match(button, /pressed-class="active"/);
|
||||
assert.doesNotMatch(button, /aria-pressed|:class=/);
|
||||
}
|
||||
assert.match(
|
||||
card,
|
||||
/<UiButton v-if="store\.canFollow\(\)" class="entity-card__action" :pressed="Boolean\(store\.isFollowing\(\)\)" pressed-class="entity-card__action--on"/,
|
||||
);
|
||||
});
|
||||
|
||||
test('the entity card hand-writes no Material glyph; each is a UiIcon', () => {
|
||||
for (const markup of [card, camera, nearby, ...heroViews])
|
||||
assert.deepEqual(markup.match(/material-symbols-outlined/g) ?? [], []);
|
||||
const counts = [
|
||||
// The preview switch's three, the hero glyph, the header icon, the
|
||||
// warning, the route's plane, the route note and the three actions.
|
||||
[card, 11],
|
||||
// Bigger view, the popup's camera and More info.
|
||||
[camera, 3],
|
||||
// The two weather glyphs, five headings and three row glyphs.
|
||||
[nearby, 10],
|
||||
];
|
||||
for (const [markup, count] of counts) {
|
||||
const icons = markup.match(/<UiIcon\b[^>]*>/g) ?? [];
|
||||
assert.equal(icons.length, count);
|
||||
// Without it the kit writes an 18px size that beats the card's own rules.
|
||||
for (const icon of icons) assert.match(icon, /:size="null"/);
|
||||
}
|
||||
});
|
||||
|
||||
test('the only inline SVG glyph is the Ask GEV chat bubble', () => {
|
||||
const svgs = [...card.matchAll(/<svg\b[\s\S]*?<\/svg\s*>/g)].map((m) => m[0]);
|
||||
assert.equal(svgs.length, 1);
|
||||
assert.match(svgs[0], /<path d="M4 5h16v11H9l-5 4z" \/>/);
|
||||
for (const markup of [camera, nearby])
|
||||
assert.deepEqual(markup.match(/<svg\b/gi) ?? [], []);
|
||||
});
|
||||
Reference in new issue
Block a user