mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-04 18:34:02 +00:00
The first formal release. - One-click install via Pinokio; keyless boot lands on a live Esri World Imagery satellite globe with keyless terrain, with automatic OSM fallback and graceful degradation when terrain is unavailable. - Provider Settings (the POWER UP panel): add, replace, or remove API keys inside the app; credential files made owner-only before any secret is written; external keys shown read-only; the panel refuses shared or proxied servers. - Keyless capability responses for the optional HUD summary and place search. - Aircraft-identity voice answers cover operator, type, and route, and say so plainly when enrichment is unavailable. - README rewritten keyless-first; concise 0.1.0 changelog section; CI workflow included. Gates: 2,672 unit tests pass / 0 fail, build clean, tracking regression 108/108, map-source tray QA pass, setup doctor ready.
112 lines
3.9 KiB
JavaScript
112 lines
3.9 KiB
JavaScript
import { test } from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
import createViteConfig, {
|
|
adsbLolFallbackAnchor,
|
|
coalesceProxyRequest,
|
|
launchLibraryRequestHeaders,
|
|
keylessGooglePlacesResponse,
|
|
LL2_CACHE_TTL_MS,
|
|
readResponseJsonCapped,
|
|
regionalBriefHasAnySource,
|
|
validMilitaryInstallationBox,
|
|
validRegionalPoint,
|
|
} from '../../vite.config.js';
|
|
|
|
test('missing Google place context is a quiet keyless capability, not a 503', () => {
|
|
assert.deepEqual(keylessGooglePlacesResponse(undefined), {
|
|
statusCode: 200,
|
|
payload: { configured: false, error: null, places: [] },
|
|
});
|
|
assert.deepEqual(keylessGooglePlacesResponse(' '), {
|
|
statusCode: 200,
|
|
payload: { configured: false, error: null, places: [] },
|
|
});
|
|
assert.equal(keylessGooglePlacesResponse('configured-key'), null);
|
|
});
|
|
|
|
test('regional proxy rejects absent and blank coordinates instead of coercing them to zero', () => {
|
|
assert.equal(validRegionalPoint(new URLSearchParams('longitude=12.5')), null);
|
|
assert.equal(validRegionalPoint(new URLSearchParams('latitude=12.5')), null);
|
|
assert.equal(validRegionalPoint(new URLSearchParams('latitude=&longitude=12.5')), null);
|
|
assert.deepEqual(
|
|
validRegionalPoint(new URLSearchParams('latitude=0&longitude=0')),
|
|
{ latitude: 0, longitude: 0 },
|
|
);
|
|
});
|
|
|
|
test('adjacent proxy validators also require every coordinate explicitly', () => {
|
|
assert.equal(
|
|
validMilitaryInstallationBox(new URLSearchParams('west=-1&north=1&east=1')),
|
|
null,
|
|
);
|
|
assert.equal(adsbLolFallbackAnchor({ url: '?lat=12.5' }), null);
|
|
assert.equal(adsbLolFallbackAnchor({ url: '?lon=12.5' }), null);
|
|
});
|
|
|
|
test('new data proxies install the same routes in dev and preview servers', () => {
|
|
const config = createViteConfig({ mode: 'test' });
|
|
const byName = new Map(config.plugins.map((plugin) => [plugin.name, plugin]));
|
|
for (const name of [
|
|
'rocket-launches-proxy',
|
|
'military-installations-proxy',
|
|
'regional-brief-proxy',
|
|
'weather-effects-proxy',
|
|
]) {
|
|
assert.equal(typeof byName.get(name)?.configureServer, 'function', `${name} dev hook`);
|
|
assert.equal(typeof byName.get(name)?.configurePreviewServer, 'function', `${name} preview hook`);
|
|
}
|
|
});
|
|
|
|
test('Launch Library uses a 15-minute cache and optional server-side token header', () => {
|
|
assert.equal(LL2_CACHE_TTL_MS, 15 * 60_000);
|
|
assert.deepEqual(launchLibraryRequestHeaders(''), { Accept: 'application/json' });
|
|
assert.deepEqual(launchLibraryRequestHeaders(' secret '), {
|
|
Accept: 'application/json',
|
|
Authorization: 'Token secret',
|
|
});
|
|
});
|
|
|
|
test('proxy request coalescing shares one per-key refresh and clears it after settlement', async () => {
|
|
const inFlight = new Map();
|
|
let refreshCount = 0;
|
|
let release;
|
|
const gate = new Promise((resolve) => { release = resolve; });
|
|
const first = coalesceProxyRequest(inFlight, 'cell', async () => {
|
|
refreshCount += 1;
|
|
await gate;
|
|
return 'fresh';
|
|
});
|
|
const second = coalesceProxyRequest(inFlight, 'cell', () => {
|
|
refreshCount += 1;
|
|
return 'duplicate';
|
|
});
|
|
assert.equal(first.shared, false);
|
|
assert.equal(second.shared, true);
|
|
assert.equal(first.promise, second.promise);
|
|
release();
|
|
assert.equal(await second.promise, 'fresh');
|
|
assert.equal(refreshCount, 1);
|
|
assert.equal(inFlight.size, 0);
|
|
});
|
|
|
|
test('bounded JSON reader rejects oversized upstream bodies', async () => {
|
|
assert.deepEqual(await readResponseJsonCapped(new Response('{"ok":true}'), 32), { ok: true });
|
|
await assert.rejects(
|
|
readResponseJsonCapped(new Response(JSON.stringify({ value: 'x'.repeat(64) })), 32),
|
|
(error) => error?.code === 'RESPONSE_TOO_LARGE',
|
|
);
|
|
});
|
|
|
|
test('regional brief treats an all-source outage as total failure', () => {
|
|
assert.equal(regionalBriefHasAnySource({
|
|
place: null,
|
|
weather: null,
|
|
news: { status: 'unavailable' },
|
|
}), false);
|
|
assert.equal(regionalBriefHasAnySource({
|
|
place: { country: 'United States' },
|
|
weather: null,
|
|
news: { status: 'unavailable' },
|
|
}), true);
|
|
});
|