feat(i18n): translate the whole interface

Mark every UI string the unmarked-text check reported (534) plus text it
cannot see (helpers, joined labels, runtime-built panels), and translate
the result to Spanish and Russian: 1,679 messages each.

- Kept on purpose, with the reason where the text lives: provider and
  product names, place and camera names, codes and units, dB values, the HUD
  terminal readouts, demo shot titles that saved projects look up by title,
  and text for AI tools and the voice model.
- Modules shared with the server or AI tools stay free of the i18n import
  (local msg); the wind reading and voice session stay English and are
  translated where the page shows them.
- npm test now runs the unmarked-text check.
- Fixes on the way: a duplicated radio privacy paragraph, the contact panel
  toggle saying Expand while open, the CSS filter mistaking & for CSS.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
German KhokhlovandClaude Opus 5.5 committed 2026-10-12 19:24:42 +04:00
1 parent ee72133574
commit 3129e531e6
99 files changed
+4670 -1294

No files matched your search

+483 -144
View File
@@ -52,13 +52,23 @@ test('dismissal is session-scoped; only the checkbox suppresses durably', () =>
rememberFirstRunSessionDismissed(session);
assert.equal(session.read(), 'dismissed');
// Gone for THIS session...
assert.equal(shouldShowFirstRun({ storage, sessionStorageRef: session, location: { search: '' } }), false);
assert.equal(
shouldShowFirstRun({
storage,
sessionStorageRef: session,
location: { search: '' },
}),
false,
);
// ...and back in the next one, because sessionStorage did not survive it.
assert.equal(shouldShowFirstRun({
storage,
sessionStorageRef: memoryStorage(FIRST_RUN_SESSION_KEY),
location: { search: '' },
}), true);
assert.equal(
shouldShowFirstRun({
storage,
sessionStorageRef: memoryStorage(FIRST_RUN_SESSION_KEY),
location: { search: '' },
}),
true,
);
// Session dismissal must never have written the durable key.
assert.equal(storage.read(), null);
});
@@ -67,43 +77,65 @@ test('the checkbox writes and clears durable suppression, and a storage reset un
const storage = memoryStorage(FIRST_RUN_STORAGE_KEY);
setFirstRunSuppressed(true, storage);
assert.equal(storage.read(), 'suppressed');
assert.equal(shouldShowFirstRun({
storage,
sessionStorageRef: memoryStorage(FIRST_RUN_SESSION_KEY),
location: { search: '' },
}), false);
assert.equal(
shouldShowFirstRun({
storage,
sessionStorageRef: memoryStorage(FIRST_RUN_SESSION_KEY),
location: { search: '' },
}),
false,
);
// Unticking before dismissing takes the suppression back.
setFirstRunSuppressed(false, storage);
assert.equal(storage.read(), null);
assert.equal(shouldShowFirstRun({
storage,
sessionStorageRef: memoryStorage(FIRST_RUN_SESSION_KEY),
location: { search: '' },
}), true);
assert.equal(
shouldShowFirstRun({
storage,
sessionStorageRef: memoryStorage(FIRST_RUN_SESSION_KEY),
location: { search: '' },
}),
true,
);
// A cleared/hard-reset profile shows it again — an accepted, documented cost.
setFirstRunSuppressed(true, storage);
assert.equal(shouldShowFirstRun({
storage: memoryStorage(FIRST_RUN_STORAGE_KEY),
sessionStorageRef: memoryStorage(FIRST_RUN_SESSION_KEY),
location: { search: '' },
}), true);
assert.equal(
shouldShowFirstRun({
storage: memoryStorage(FIRST_RUN_STORAGE_KEY),
sessionStorageRef: memoryStorage(FIRST_RUN_SESSION_KEY),
location: { search: '' },
}),
true,
);
});
test('welcome params work in both directions and outrank both suppressions', () => {
const suppressed = memoryStorage(FIRST_RUN_STORAGE_KEY, 'suppressed');
const dismissed = memoryStorage(FIRST_RUN_SESSION_KEY, 'dismissed');
// ?welcome=1 replays past the checkbox AND past a session dismissal.
assert.equal(shouldShowFirstRun({
storage: suppressed, sessionStorageRef: dismissed, location: { search: '?welcome=1' },
}), true);
assert.equal(
shouldShowFirstRun({
storage: suppressed,
sessionStorageRef: dismissed,
location: { search: '?welcome=1' },
}),
true,
);
// ?welcome=0 suppresses a session that would otherwise see it.
assert.equal(shouldShowFirstRun({ ...fresh(), location: { search: '?welcome=0' } }), false);
assert.equal(
shouldShowFirstRun({ ...fresh(), location: { search: '?welcome=0' } }),
false,
);
// A share link outranks everything, including the replay hatch.
assert.equal(shouldShowFirstRun({
hasShareState: true, ...fresh(), location: { search: '?welcome=1' },
}), false);
assert.equal(
shouldShowFirstRun({
hasShareState: true,
...fresh(),
location: { search: '?welcome=1' },
}),
false,
);
});
test('a share link never sees the launcher — its author already chose the view', () => {
@@ -112,11 +144,20 @@ test('a share link never sees the launcher — its author already chose the view
test('privacy-restricted storage fails open and every write stays best-effort', () => {
const blocked = {
getItem: () => { throw new Error('blocked'); },
setItem: () => { throw new Error('blocked'); },
removeItem: () => { throw new Error('blocked'); },
getItem: () => {
throw new Error('blocked');
},
setItem: () => {
throw new Error('blocked');
},
removeItem: () => {
throw new Error('blocked');
},
};
assert.equal(shouldShowFirstRun({ storage: blocked, sessionStorageRef: blocked }), true);
assert.equal(
shouldShowFirstRun({ storage: blocked, sessionStorageRef: blocked }),
true,
);
assert.doesNotThrow(() => setFirstRunSuppressed(true, blocked));
assert.doesNotThrow(() => rememberFirstRunSessionDismissed(blocked));
});
@@ -128,10 +169,15 @@ test('a THROWING storage getter still fails open — Safari private mode', () =>
// before the function body starts, so the SecurityError escapes every
// try/catch in the module and the launcher silently never appears.
const saved = Object.getOwnPropertyDescriptor(globalThis, 'localStorage');
const savedSession = Object.getOwnPropertyDescriptor(globalThis, 'sessionStorage');
const savedSession = Object.getOwnPropertyDescriptor(
globalThis,
'sessionStorage',
);
const hostile = {
configurable: true,
get() { throw new Error('SecurityError: The operation is insecure.'); },
get() {
throw new Error('SecurityError: The operation is insecure.');
},
};
Object.defineProperty(globalThis, 'localStorage', hostile);
Object.defineProperty(globalThis, 'sessionStorage', hostile);
@@ -152,16 +198,22 @@ test('a THROWING storage getter still fails open — Safari private mode', () =>
} finally {
if (saved) Object.defineProperty(globalThis, 'localStorage', saved);
else delete globalThis.localStorage;
if (savedSession) Object.defineProperty(globalThis, 'sessionStorage', savedSession);
if (savedSession)
Object.defineProperty(globalThis, 'sessionStorage', savedSession);
else delete globalThis.sessionStorage;
}
});
test('no storage is touched from a default parameter position', () => {
const module = fs.readFileSync(new URL('./firstRunExperience.js', import.meta.url), 'utf8');
const module = fs.readFileSync(
new URL('./firstRunExperience.js', import.meta.url),
'utf8',
);
// Comments stripped first: the block explaining this very defect quotes the
// bad pattern, and matching prose instead of code would make the pin a liar.
const code = module.replace(/\/\*[\s\S]*?\*\//g, '').replace(/^\s*\/\/.*$/gm, '');
const code = module
.replace(/\/\*[\s\S]*?\*\//g, '')
.replace(/^\s*\/\/.*$/gm, '');
assert.doesNotMatch(
code,
/=\s*globalThis\.(local|session)Storage/,
@@ -169,14 +221,24 @@ test('no storage is touched from a default parameter position', () => {
);
// The only reads of the global areas live inside the guarded resolver.
const globalReads = [...code.matchAll(/globalThis\.(local|session)Storage/g)];
assert.equal(globalReads.length, 2, 'exactly two global storage reads, both in resolveStore');
const resolver = code.slice(code.indexOf('function resolveStore'), code.indexOf('function readStored'));
assert.equal(
globalReads.length,
2,
'exactly two global storage reads, both in resolveStore',
);
const resolver = code.slice(
code.indexOf('function resolveStore'),
code.indexOf('function readStored'),
);
assert.equal(
[...resolver.matchAll(/globalThis\.(local|session)Storage/g)].length,
2,
'both global storage reads must be inside resolveStore, inside its try',
);
assert.match(resolver, /try \{[\s\S]*globalThis\.sessionStorage[\s\S]*\} catch/);
assert.match(
resolver,
/try \{[\s\S]*globalThis\.sessionStorage[\s\S]*\} catch/,
);
assert.match(code, /function readStored\(kind, injected, key\)/);
assert.match(code, /function writeStored\(kind, injected, key, value\)/);
});
@@ -184,33 +246,52 @@ test('no storage is touched from a default parameter position', () => {
// ── ESC arbitration: one surface, one key, never an invisible handler ────────
test('the JS and CSS lists of screen-claiming surfaces stay in step', () => {
const module = fs.readFileSync(new URL('./firstRunExperience.js', import.meta.url), 'utf8');
const module = fs.readFileSync(
new URL('./firstRunExperience.js', import.meta.url),
'utf8',
);
const css = readStylesheet(new URL('../style.css', import.meta.url));
assert.deepEqual(
[...EXCLUSIVE_SURFACE_CLASSES].sort(),
['cockpit-mode', 'recording-mode', 'scene-playback-mode', 'ui-clean-view'],
);
assert.deepEqual([...EXCLUSIVE_SURFACE_CLASSES].sort(), [
'cockpit-mode',
'recording-mode',
'scene-playback-mode',
'ui-clean-view',
]);
// A surface that hides the card in CSS but is missing from the JS list would
// leave an invisible launcher holding the ESC handler — blocker 2 exactly.
const hideRule = css.slice(
css.indexOf('body.ui-clean-view #first-run-launcher'),
css.indexOf('display: none', css.indexOf('body.ui-clean-view #first-run-launcher')),
css.indexOf(
'display: none',
css.indexOf('body.ui-clean-view #first-run-launcher'),
),
);
const inCss = [...hideRule.matchAll(/body\.([a-z-]+) #first-run-launcher/g)].map((m) => m[1]);
const inCss = [
...hideRule.matchAll(/body\.([a-z-]+) #first-run-launcher/g),
].map((m) => m[1]);
assert.deepEqual(
inCss.sort(),
[...EXCLUSIVE_SURFACE_CLASSES].sort(),
'every screen-claiming surface must appear in BOTH lists',
);
assert.match(module, /export const EXCLUSIVE_SURFACE_CLASSES = Object\.freeze\(\[/);
assert.match(
module,
/export const EXCLUSIVE_SURFACE_CLASSES = Object\.freeze\(\[/,
);
});
test('exclusiveSurfaceActive reads the live body classes', () => {
const make = (classes) => ({ body: { classList: { contains: (name) => classes.includes(name) } } });
const make = (classes) => ({
body: { classList: { contains: (name) => classes.includes(name) } },
});
assert.equal(exclusiveSurfaceActive(make([])), false);
for (const name of EXCLUSIVE_SURFACE_CLASSES) {
assert.equal(exclusiveSurfaceActive(make([name])), true, `${name} must count as exclusive`);
assert.equal(
exclusiveSurfaceActive(make([name])),
true,
`${name} must count as exclusive`,
);
}
assert.equal(exclusiveSurfaceActive(make(['some-other-class'])), false);
assert.equal(exclusiveSurfaceActive(undefined), false);
@@ -218,14 +299,25 @@ test('exclusiveSurfaceActive reads the live body classes', () => {
});
test('the key handler refuses to act for a card that is not really on screen', () => {
const module = fs.readFileSync(new URL('./firstRunExperience.js', import.meta.url), 'utf8');
const module = fs.readFileSync(
new URL('./firstRunExperience.js', import.meta.url),
'utf8',
);
assert.match(module, /isActive: \(\) => !closing && isTopmost\(\)/);
// Real visibility, not just the class: the class survives while CSS hides the
// card, which is precisely how a Scene left an invisible ESC handler armed.
assert.match(module, /const isTopmost = \(\) =>\s*root\.isConnected/);
assert.match(module, /&&\s*root\.getClientRects\(\)\.length > 0 &&\s*!coveredByOverlay\(\);/);
const keyboard = fs.readFileSync(new URL('./ui/surfaceKeyboard.js', import.meta.url), 'utf8');
const handler = keyboard.slice(keyboard.indexOf('const onKeyDown = (event) => {'));
assert.match(
module,
/&&\s*root\.getClientRects\(\)\.length > 0 &&\s*!coveredByOverlay\(\);/,
);
const keyboard = fs.readFileSync(
new URL('./ui/surfaceKeyboard.js', import.meta.url),
'utf8',
);
const handler = keyboard.slice(
keyboard.indexOf('const onKeyDown = (event) => {'),
);
assert.match(
handler.slice(0, handler.indexOf("if (event.key === 'Escape')")),
/!isActive\(\)/,
@@ -234,7 +326,10 @@ test('the key handler refuses to act for a card that is not really on screen', (
});
test('an overlay with NO class to watch still disarms the launcher', () => {
const module = fs.readFileSync(new URL('./firstRunExperience.js', import.meta.url), 'utf8');
const module = fs.readFileSync(
new URL('./firstRunExperience.js', import.meta.url),
'utf8',
);
const css = readStylesheet(new URL('../style.css', import.meta.url));
// The repro, pinned as the stacking it actually is: the attribution lightbox
@@ -242,7 +337,10 @@ test('an overlay with NO class to watch still disarms the launcher', () => {
// keeps its box, so getClientRects() alone called it visible, ESC dismissed a
// buried launcher and wrote the session flag while the lightbox stayed open.
const overlay = css.slice(css.indexOf('.cesium-credit-lightbox-overlay {'));
assert.match(overlay.slice(0, overlay.indexOf('}')), /z-index: 200 !important/);
assert.match(
overlay.slice(0, overlay.indexOf('}')),
/z-index: 200 !important/,
);
const launcher = css.slice(css.indexOf('#first-run-launcher {'));
assert.match(launcher.slice(0, launcher.indexOf('}')), /z-index: 175/);
@@ -259,14 +357,26 @@ test('an overlay with NO class to watch still disarms the launcher', () => {
// ...and every inconclusive answer is UNCOVERED, so a guard added to stop the
// launcher acting under an overlay can never become why ESC stopped working.
assert.match(covered, /if \(typeof documentRef\.elementFromPoint !== 'function'\) return false;/);
assert.match(covered, /if \(!\(rect\.width > 0 && rect\.height > 0\)\) return false;/);
assert.match(
covered,
/if \(typeof documentRef\.elementFromPoint !== 'function'\) return false;/,
);
assert.match(
covered,
/if \(!\(rect\.width > 0 && rect\.height > 0\)\) return false;/,
);
assert.match(covered, /\} catch \{\s*\n\s*return false;\s*\n\s*\}/);
});
test('one ESC does one thing — the radio disclosure stops the launcher outright', () => {
const ui = fs.readFileSync(new URL('./ui/radioBindings.js', import.meta.url), 'utf8');
const module = fs.readFileSync(new URL('./firstRunExperience.js', import.meta.url), 'utf8');
const ui = fs.readFileSync(
new URL('./ui/radioBindings.js', import.meta.url),
'utf8',
);
const module = fs.readFileSync(
new URL('./firstRunExperience.js', import.meta.url),
'utf8',
);
// stopPropagation() does NOT stop later listeners on the SAME document, so the
// disclosure's earlier capture handler closed the disclosure and the launcher
@@ -276,30 +386,45 @@ test('one ESC does one thing — the radio disclosure stops the launcher outrigh
const claim = radioEsc.slice(0, radioEsc.indexOf('setRadioDisclosure(false'));
assert.match(claim, /event\.preventDefault\(\);/);
assert.match(claim, /event\.stopImmediatePropagation\(\);/);
assert.doesNotMatch(claim, /event\.stopPropagation\(\);/,
'the plain form leaves the launcher listening and is the defect itself');
assert.doesNotMatch(
claim,
/event\.stopPropagation\(\);/,
'the plain form leaves the launcher listening and is the defect itself',
);
// Belt on the launcher side: a key another surface already marked is not ours,
// whether or not that surface remembered to silence us.
const keyboard = fs.readFileSync(new URL('./ui/surfaceKeyboard.js', import.meta.url), 'utf8');
const handler = keyboard.slice(keyboard.indexOf('const onKeyDown = (event) => {'));
const keyboard = fs.readFileSync(
new URL('./ui/surfaceKeyboard.js', import.meta.url),
'utf8',
);
const handler = keyboard.slice(
keyboard.indexOf('const onKeyDown = (event) => {'),
);
assert.match(
handler.slice(0, handler.indexOf("if (event.key === 'Escape')")),
/event\.defaultPrevented\) return;/,
'a marked key must be somebody else\'s key',
"a marked key must be somebody else's key",
);
});
test('a refused write takes the tick back instead of promising "never again"', () => {
const module = fs.readFileSync(new URL('./firstRunExperience.js', import.meta.url), 'utf8');
const module = fs.readFileSync(
new URL('./firstRunExperience.js', import.meta.url),
'utf8',
);
// The write stays best-effort; the OUTCOME is now reported, because a box left
// ticked after a refused write tells the visitor the launcher is gone for good
// while it is already guaranteed to return next session.
const blocked = {
getItem: () => null,
setItem: () => { throw new Error('blocked'); },
removeItem: () => { throw new Error('blocked'); },
setItem: () => {
throw new Error('blocked');
},
removeItem: () => {
throw new Error('blocked');
},
};
assert.equal(setFirstRunSuppressed(true, blocked), false);
assert.equal(setFirstRunSuppressed(false, blocked), false);
@@ -318,13 +443,26 @@ test('a refused write takes the tick back instead of promising "never again"', (
module.indexOf('const onSuppressChange = (event) => {'),
module.indexOf(' const keyboard = createSurfaceKeyboard({'),
);
assert.match(handler, /if \(setFirstRunSuppressed\(wanted, storage\)\) return;/);
assert.match(handler, /box\.checked = !wanted;/, 'a refused write must revert the tick');
assert.match(
handler,
/if \(setFirstRunSuppressed\(wanted, storage\)\) return;/,
);
assert.match(
handler,
/box\.checked = !wanted;/,
'a refused write must revert the tick',
);
});
test('a surface class that never clears is an ACCEPTED no-show, not a timer', () => {
const module = fs.readFileSync(new URL('./firstRunExperience.js', import.meta.url), 'utf8');
const state = fs.readFileSync(new URL('../docs/CURRENT-STATE.md', import.meta.url), 'utf8');
const module = fs.readFileSync(
new URL('./firstRunExperience.js', import.meta.url),
'utf8',
);
const state = fs.readFileSync(
new URL('../docs/CURRENT-STATE.md', import.meta.url),
'utf8',
);
// A "reveal anyway after N seconds" would trade a benign no-show for the card
// punching through a recording in progress — recordings run long, and none of
@@ -336,33 +474,65 @@ test('a surface class that never clears is an ACCEPTED no-show, not a timer', ()
module.indexOf('ACCEPTED, DELIBERATELY NOT TIMED OUT'),
module.indexOf(' const onViewportResize'),
);
assert.ok(accepted.length > 0, 'the acceptance must be written where the next editor will read it');
assert.match(accepted, /const syncToExclusiveSurfaces = \(\) => \{/,
'the pin must cover the function the note governs, not just the note');
assert.doesNotMatch(accepted, /setTimeout|setInterval/,
'the acceptance is the decision NOT to time this out');
assert.ok(
accepted.length > 0,
'the acceptance must be written where the next editor will read it',
);
assert.match(
accepted,
/const syncToExclusiveSurfaces = \(\) => \{/,
'the pin must cover the function the note governs, not just the note',
);
assert.doesNotMatch(
accepted,
/setTimeout|setInterval/,
'the acceptance is the decision NOT to time this out',
);
assert.match(accepted, /docs\/CURRENT-STATE\.md/);
assert.match(state, /a surface class that never clears means no launcher for that page/i);
assert.match(
state,
/a surface class that never clears means no launcher for that page/i,
);
});
test('the scroll fade only appears when the list really overflows', () => {
const module = fs.readFileSync(new URL('./firstRunExperience.js', import.meta.url), 'utf8');
const module = fs.readFileSync(
new URL('./firstRunExperience.js', import.meta.url),
'utf8',
);
const css = readStylesheet(new URL('../style.css', import.meta.url));
// A fade on a card where all five tiles fit promises a sixth mission that does
// not exist, which is worse than no affordance at all.
assert.match(module, /const overflows = choiceList\.scrollHeight > choiceList\.clientHeight \+ 1;/);
assert.match(module, /choiceList\.dataset\.scrollable = String\(overflows\);/);
assert.match(
module,
/const overflows = choiceList\.scrollHeight > choiceList\.clientHeight \+ 1;/,
);
assert.match(
module,
/choiceList\.dataset\.scrollable = String\(overflows\);/,
);
// ...and the CSS must be gated on that flag, never on the media query alone.
assert.match(css, /\.first-run-choices\[data-scrollable='true'\] \{[\s\S]*?mask-image/);
const bareFade = css.match(/^\s*\.first-run-choices \{[\s\S]*?\n\}/m)?.[0] || '';
assert.doesNotMatch(bareFade, /mask-image/, 'the fade must never apply unconditionally');
assert.match(
css,
/\.first-run-choices\[data-scrollable='true'\] \{[\s\S]*?mask-image/,
);
const bareFade =
css.match(/^\s*\.first-run-choices \{[\s\S]*?\n\}/m)?.[0] || '';
assert.doesNotMatch(
bareFade,
/mask-image/,
'the fade must never apply unconditionally',
);
// Rotating a phone changes which tiles fit, so it re-measures.
assert.match(module, /addEventListener\?\.\('resize', onViewportResize\)/);
assert.match(module, /removeEventListener\?\.\('resize', onViewportResize\)/);
});
test('the launcher yields on engage and waits when a surface is already up', () => {
const module = fs.readFileSync(new URL('./firstRunExperience.js', import.meta.url), 'utf8');
const module = fs.readFileSync(
new URL('./firstRunExperience.js', import.meta.url),
'utf8',
);
// Both directions from one observer: yield if it is up and something takes
// the screen; wait to reveal if something already has it.
assert.match(
@@ -375,19 +545,28 @@ test('the launcher yields on engage and waits when a surface is already up', ()
// not see a new hold because of onboarding chrome.
assert.match(module, /attributes: true,\s*attributeFilter: \['class'\]/);
assert.match(module, /surfaceObserver\?\.disconnect\(\)/);
assert.doesNotMatch(module, /setInterval|requestAnimationFrame\(function poll/);
assert.doesNotMatch(
module,
/setInterval|requestAnimationFrame\(function poll/,
);
});
// ── Per-mission behavior ─────────────────────────────────────────────────────
function missionSpy({ contextOk = true, layerResult = () => true, globe = async () => ({ ok: true }) } = {}) {
function missionSpy({
contextOk = true,
layerResult = () => true,
globe = async () => ({ ok: true }),
} = {}) {
const calls = { contextModes: [], layerIds: [], globeFlights: 0 };
return {
calls,
deps: {
setContextMode: async (mode) => {
calls.contextModes.push(mode);
return contextOk ? { ok: true, mode } : { ok: false, failedLayerIds: ['rocket-launches'] };
return contextOk
? { ok: true, mode }
: { ok: false, failedLayerIds: ['rocket-launches'] };
},
setLayerEnabled: async (layerId) => {
calls.layerIds.push(layerId);
@@ -408,14 +587,23 @@ test('the menu is the four owner-ordered missions', () => {
// went is the one-click globe-scale dump. Restoring the tile needs the
// globe-LOD declutter first.
assert.deepEqual(Object.keys(FIRST_RUN_MISSIONS), [
'contacts', 'space-missions', 'environmental', 'explore',
'contacts',
'space-missions',
'environmental',
'explore',
]);
assert.equal(FIRST_RUN_MISSIONS.infrastructure, undefined,
'the infrastructure mission must be gone, not dormant');
assert.equal(
FIRST_RUN_MISSIONS.infrastructure,
undefined,
'the infrastructure mission must be gone, not dormant',
);
});
test('Live Contacts and Space Missions go through the one setContextMode facade', async () => {
for (const [choice, mode] of [['contacts', 'contacts'], ['space-missions', 'space-missions']]) {
for (const [choice, mode] of [
['contacts', 'contacts'],
['space-missions', 'space-missions'],
]) {
const spy = missionSpy();
const outcome = await runFirstRunChoice(choice, spy.deps);
assert.equal(outcome.ok, true);
@@ -445,8 +633,14 @@ test('the tile is the FULLY CONFIGURED experience: quakes and fires together', (
// that row into LOAD FAILED — a defect in the shared state machine, ledgered
// post-launch, and the note must stay where the next editor will read it
// rather than being re-discovered as a launcher bug.
const module = fs.readFileSync(new URL('./firstRunExperience.js', import.meta.url), 'utf8');
const table = module.slice(module.indexOf(' environmental: Object.freeze({'), module.indexOf(' explore:'));
const module = fs.readFileSync(
new URL('./firstRunExperience.js', import.meta.url),
'utf8',
);
const table = module.slice(
module.indexOf(' environmental: Object.freeze({'),
module.indexOf(' explore:'),
);
assert.match(table, /KEY REQUIRED/);
assert.match(table, /src\/loadingFeedback\.js/);
assert.match(table, /LEDGERED post-launch/);
@@ -461,7 +655,10 @@ test('every visitor gets the same tile — there is no degraded keyless variant'
assert.equal(outcome.ok, true);
assert.deepEqual(outcome.failedLayerIds, []);
assert.deepEqual(spy.calls.layerIds, ['earthquakes', 'local-firms']);
const module = fs.readFileSync(new URL('./firstRunExperience.js', import.meta.url), 'utf8');
const module = fs.readFileSync(
new URL('./firstRunExperience.js', import.meta.url),
'utf8',
);
assert.doesNotMatch(
module.slice(module.indexOf('export async function runFirstRunChoice')),
/FIRMS_MAP_KEY|hasKey|keyless\s*\?/,
@@ -476,16 +673,31 @@ test('a refused layer fails the mission by name, and a stalled flight never does
assert.deepEqual(outcome.failedLayerIds, ['earthquakes']);
// The globe flight is framing. A cancelled or throwing flight is not a failure.
const flightDown = missionSpy({ globe: () => { throw new Error('cancelled'); } });
assert.equal((await runFirstRunChoice('environmental', flightDown.deps)).ok, true);
const flightDown = missionSpy({
globe: () => {
throw new Error('cancelled');
},
});
assert.equal(
(await runFirstRunChoice('environmental', flightDown.deps)).ok,
true,
);
});
test('Explore manually touches nothing at all, and an unknown choice is inert', async () => {
const spy = missionSpy();
assert.equal((await runFirstRunChoice('explore', spy.deps)).ok, true);
assert.deepEqual(spy.calls, { contextModes: [], layerIds: [], globeFlights: 0 });
assert.deepEqual(spy.calls, {
contextModes: [],
layerIds: [],
globeFlights: 0,
});
assert.equal((await runFirstRunChoice('nope', spy.deps)).ok, false);
assert.deepEqual(spy.calls, { contextModes: [], layerIds: [], globeFlights: 0 });
assert.deepEqual(spy.calls, {
contextModes: [],
layerIds: [],
globeFlights: 0,
});
});
test('a failed Context mission reports the layers the facade named', async () => {
@@ -500,14 +712,22 @@ test('the fires/quakes tile name is switchable from one constant', () => {
assert.equal(environmentalLabel('EARTH_WATCH').title, 'EARTH WATCH');
assert.equal(environmentalLabel('ACTIVE_EVENTS').title, 'ACTIVE EVENTS');
assert.equal(environmentalLabel('nonsense').title, 'ENVIRONMENTAL');
assert.equal(environmentalLabel().title, environmentalLabel(ENVIRONMENTAL_LABEL_CHOICE).title);
assert.equal(
environmentalLabel().title,
environmentalLabel(ENVIRONMENTAL_LABEL_CHOICE).title,
);
});
// ── Defaults interplay: what a mission is allowed to persist ─────────────────
test('no mission writes a preference the visitor did not choose by picking it', () => {
const module = fs.readFileSync(new URL('./firstRunExperience.js', import.meta.url), 'utf8');
const code = module.slice(module.indexOf('export function shouldShowFirstRun'));
const module = fs.readFileSync(
new URL('./firstRunExperience.js', import.meta.url),
'utf8',
);
const code = module.slice(
module.indexOf('export function shouldShowFirstRun'),
);
// Layer enables ARE durable in this app and a mission tile IS that choice, so
// they run at the same origin a click on those rows uses.
@@ -528,22 +748,45 @@ test('no mission writes a preference the visitor did not choose by picking it',
'_setModels3dParams',
'setFeather',
]) {
assert.doesNotMatch(code, new RegExp(forbidden), `a mission must never touch ${forbidden}`);
assert.doesNotMatch(
code,
new RegExp(forbidden),
`a mission must never touch ${forbidden}`,
);
}
// The only durable panel write is the Context reveal, and only on the Context
// missions — the globe missions open no panel at all.
const panelWrites = code.match(/setPanelCollapsed/g) || [];
assert.equal(panelWrites.length, 1, 'exactly one panel reveal, on the Context path');
const contextPath = code.slice(code.indexOf('setContextMode: async (mode)'), code.indexOf('setLayerEnabled:'));
assert.match(contextPath, /result\?\.ok[\s\S]*?setPanelCollapsed\?\.\('global-context-panel', false, \{\s*explicit: true,?\s*\}\)/);
assert.equal(
panelWrites.length,
1,
'exactly one panel reveal, on the Context path',
);
const contextPath = code.slice(
code.indexOf('setContextMode: async (mode)'),
code.indexOf('setLayerEnabled:'),
);
assert.match(
contextPath,
/result\?\.ok[\s\S]*?setPanelCollapsed\?\.\('global-context-panel', false, \{\s*explicit: true,?\s*\}\)/,
);
});
test('the decision table is written down where the next editor will read it', () => {
const module = fs.readFileSync(new URL('./firstRunExperience.js', import.meta.url), 'utf8');
assert.match(module, /MISSION → APP STATE, AND WHAT IT IS ALLOWED TO PERSIST/);
const module = fs.readFileSync(
new URL('./firstRunExperience.js', import.meta.url),
'utf8',
);
assert.match(
module,
/MISSION → APP STATE, AND WHAT IT IS ALLOWED TO PERSIST/,
);
for (const row of ['TOUCHED, DURABLE', 'TOUCHED, SESSION', 'NOT TOUCHED']) {
assert.ok(module.includes(row), `decision table is missing its "${row}" rows`);
assert.ok(
module.includes(row),
`decision table is missing its "${row}" rows`,
);
}
assert.match(module, /SHOW POLICY/);
});
@@ -551,56 +794,109 @@ test('the decision table is written down where the next editor will read it', ()
// ── Markup, startup ordering, accessibility ─────────────────────────────────
test('markup, startup ordering and accessibility remain pinned', () => {
const html = expandApplicationHtml(fs.readFileSync(new URL('../index.html', import.meta.url), 'utf8'));
const startup = fs.readFileSync(new URL('./app/startupChrome.js', import.meta.url), 'utf8');
const html = expandApplicationHtml(
fs.readFileSync(new URL('../index.html', import.meta.url), 'utf8'),
);
const startup = fs.readFileSync(
new URL('./app/startupChrome.js', import.meta.url),
'utf8',
);
const css = readStylesheet(new URL('../style.css', import.meta.url));
assert.match(html, /id="first-run-launcher" role="dialog"[^>]*aria-labelledby="first-run-title"[^>]*hidden/);
assert.match(
html,
/id="first-run-launcher" role="dialog"[^>]*aria-labelledby="first-run-title"[^>]*hidden/,
);
assert.equal((html.match(/data-first-run-choice=/g) || []).length, 4);
assert.match(html, /data-first-run-status[^>]*role="status"[^>]*aria-live="polite"/);
assert.match(
html,
/data-first-run-status[^>]*role="status"[^>]*aria-live="polite"/,
);
assert.match(html, /<input type="checkbox" data-first-run-suppress \/>/);
assert.match(html, /<strong data-first-run-environmental-title>/);
// Subcopy must name BOTH feeds the tile turns on — a tile that promised only
// half of what it does is the defect this replaced. Only the VISIBLE <small>
// text counts; the comment beside it naturally says the words too.
const envTile = html.slice(html.indexOf('data-first-run-choice="environmental"'));
const visible = envTile.slice(envTile.indexOf('<small>'), envTile.indexOf('</small>'));
const envTile = html.slice(
html.indexOf('data-first-run-choice="environmental"'),
);
const visible = envTile.slice(
envTile.indexOf('<small>'),
envTile.indexOf('</small>'),
);
assert.match(visible, /earthquakes/i);
assert.match(visible, /fires?/i, 'the tile must promise the fires it enables');
assert.match(
visible,
/fires?/i,
'the tile must promise the fires it enables',
);
// The card's one persuasive line is OWNER-AUTHORED and pinned verbatim,
// unspaced em dash included. This is copy, not prose to be improved in a
// passing edit — changing it needs the owner, not a nicer-sounding rewrite.
assert.ok(
html.includes('<p id="first-run-description">It feels like a forbidden cockpit'
+ '—then you realize the sources are public and the data is real.</p>'),
html.includes(
'<p id="first-run-description" data-i18n-runtime>It feels like a forbidden cockpit' +
'—then you realize the sources are public and the data is real.</p>',
),
'the owner-authored first-run line must ship exactly as written',
);
// Menu order is the owner's, read straight off the markup.
const order = [...html.matchAll(/data-first-run-choice="([a-z-]+)"/g)].map((match) => match[1]);
assert.deepEqual(order, ['contacts', 'space-missions', 'environmental', 'explore']);
assert.doesNotMatch(html, /data-first-run-choice="infrastructure"/,
'the removed tile must leave no markup behind');
const order = [...html.matchAll(/data-first-run-choice="([a-z-]+)"/g)].map(
(match) => match[1],
);
assert.deepEqual(order, [
'contacts',
'space-missions',
'environmental',
'explore',
]);
assert.doesNotMatch(
html,
/data-first-run-choice="infrastructure"/,
'the removed tile must leave no markup behind',
);
assert.match(startup, /styleManager\.initialRestorePromise/);
assert.ok(startup.indexOf("loadingScreen.classList.add('hidden')") < startup.indexOf("loadingScreen.addEventListener('transitionend', revealFirstRun"));
assert.match(startup, /initializeWelcome\?\.\(\{ styleManager, dataManager \}\)/);
assert.ok(
startup.indexOf("loadingScreen.classList.add('hidden')") <
startup.indexOf(
"loadingScreen.addEventListener('transitionend', revealFirstRun",
),
);
assert.match(
startup,
/initializeWelcome\?\.\(\{ styleManager, dataManager \}\)/,
);
assert.match(css, /body\.ui-clean-view #first-run-launcher/);
assert.match(css, /body\.recording-mode #first-run-launcher/);
// Scoped, not a bare search: style.css has other reduced-motion blocks, and
// matching one of THOSE would let the launcher's own opt-out be deleted.
const reducedMotion = [...css.matchAll(/@media \(prefers-reduced-motion: reduce\) \{([\s\S]*?)\n\}/g)]
.map((match) => match[1]);
const reducedMotion = [
...css.matchAll(
/@media \(prefers-reduced-motion: reduce\) \{([\s\S]*?)\n\}/g,
),
].map((match) => match[1]);
assert.ok(
reducedMotion.some((block) => block.includes('#first-run-launcher') && block.includes('.first-run-choices')),
reducedMotion.some(
(block) =>
block.includes('#first-run-launcher') &&
block.includes('.first-run-choices'),
),
'the launcher must keep its OWN prefers-reduced-motion block, covering the card and the scrolling list',
);
// The card must be click-through until revealed and again while it fades out.
const base = css.slice(css.indexOf('#first-run-launcher {'), css.indexOf('#first-run-launcher.visible'));
const base = css.slice(
css.indexOf('#first-run-launcher {'),
css.indexOf('#first-run-launcher.visible'),
);
assert.match(base, /pointer-events: none/);
assert.match(css, /#first-run-launcher\.visible \{[\s\S]*?pointer-events: auto/);
assert.match(
css,
/#first-run-launcher\.visible \{[\s\S]*?pointer-events: auto/,
);
// The card is a flex column so its mission list can scroll on a short
// viewport — and an AUTHOR `display` on this id outranks the UA's
// `[hidden] { display: none }`, which would strand the card in the
@@ -616,13 +912,22 @@ test('markup, startup ordering and accessibility remain pinned', () => {
});
test('the launcher keeps focus, restores it, and never disables the focused button', () => {
const module = fs.readFileSync(new URL('./firstRunExperience.js', import.meta.url), 'utf8');
const module = fs.readFileSync(
new URL('./firstRunExperience.js', import.meta.url),
'utf8',
);
// aria-disabled, never the `disabled` property: disabling a focused button
// drops the keyboard to <body> and strands the visitor outside the launcher.
assert.match(module, /button\.setAttribute\('aria-disabled', String\(next\)\)/);
assert.match(
module,
/button\.setAttribute\('aria-disabled', String\(next\)\)/,
);
assert.doesNotMatch(module, /button\.disabled = /);
// Tab is confined to the launcher, and ESC always releases it.
const keyboard = fs.readFileSync(new URL('./ui/surfaceKeyboard.js', import.meta.url), 'utf8');
const keyboard = fs.readFileSync(
new URL('./ui/surfaceKeyboard.js', import.meta.url),
'utf8',
);
assert.match(module, /keyboard\.activate\(\)/);
assert.match(module, /keyboard\.deactivate\(\{ restoreFocus \}\)/);
assert.match(keyboard, /event\.key !== 'Tab'/);
@@ -633,7 +938,10 @@ test('the launcher keeps focus, restores it, and never disables the focused butt
});
test('the DISPLAY rail starts collapsed on a first run, and a stored choice wins', () => {
const ui = fs.readFileSync(new URL('./ui/panelPositionControls.js', import.meta.url), 'utf8');
const ui = fs.readFileSync(
new URL('./ui/panelPositionControls.js', import.meta.url),
'utf8',
);
// The rail opened by default to advertise HUD / DETECT / 3D. Those default ON
// now, so it was opening to offer controls for things already happening —
// while competing with the mission card for the one first impression there is.
@@ -644,7 +952,11 @@ test('the DISPLAY rail starts collapsed on a first run, and a stored choice wins
);
// The first-run default may only apply when NOTHING is stored: a visitor who
// opened the rail keeps it open, and one who closed it keeps it closed.
const block = ui.slice(ui.indexOf('stored = localStorage.getItem(this._panelCollapseStorageKey(panelId))'));
const block = ui.slice(
ui.indexOf(
'stored = localStorage.getItem(this._panelCollapseStorageKey(panelId))',
),
);
const guard = block.slice(0, block.indexOf('panelEl.classList.toggle'));
assert.match(guard, /if \(stored === '1'\) collapsed = true;/);
assert.match(guard, /if \(stored === '0'\) collapsed = false;/);
@@ -661,9 +973,17 @@ test('the voice TOOL SCHEMA matches the pinned contract — the mission mapping
// Canonical serialization pins every tool name, description, property and
// ordering while allowing source formatting. Derived from the unchanged
// release schema before formatting (the previous source-byte pin passed).
const legacyTools = structuredClone(GEV_REALTIME_TOOLS).filter((tool) => tool.name !== 'set_cyber_sonar');
const hudLayout = legacyTools.find((tool) => tool.name === 'set_hud').parameters.properties.layout;
assert.deepEqual(hudLayout.enum, ['tactical', 'operator', 'minimal', 'cyber']);
const legacyTools = structuredClone(GEV_REALTIME_TOOLS).filter(
(tool) => tool.name !== 'set_cyber_sonar',
);
const hudLayout = legacyTools.find((tool) => tool.name === 'set_hud')
.parameters.properties.layout;
assert.deepEqual(hudLayout.enum, [
'tactical',
'operator',
'minimal',
'cyber',
]);
// Cyber deliberately adds one layout; first-run missions still change no tools.
hudLayout.enum = hudLayout.enum.filter((layout) => layout !== 'cyber');
const block = JSON.stringify(legacyTools);
@@ -680,7 +1000,10 @@ test('the voice TOOL SCHEMA matches the pinned contract — the mission mapping
'b316ca2e67848eb565b6847ac044a19d1465d8ef8252a5dfbd7d947a2a36d5ed',
'the first-run missions must ride EXISTING tools: no schema edit, no cache bust',
);
const instructions = fs.readFileSync(new URL('../server/providers/openai/instructions.js', import.meta.url), 'utf8');
const instructions = fs.readFileSync(
new URL('../server/providers/openai/instructions.js', import.meta.url),
'utf8',
);
// ...and the mapping that makes them reachable by voice is one instruction
// string, whose rollback is deleting that string. Anchored to a LIVE array
@@ -691,23 +1014,39 @@ test('the voice TOOL SCHEMA matches the pinned contract — the mission mapping
/\n\s+'NAMED VIEWS are shorthand/,
'the mission mapping must be an active instruction entry, not commented out',
);
const mapping = instructions.slice(instructions.indexOf('NAMED VIEWS are shorthand'));
const mapping = instructions.slice(
instructions.indexOf('NAMED VIEWS are shorthand'),
);
const paragraph = mapping.slice(0, mapping.indexOf("',\n"));
for (const layerId of [
'local-datacenters', 'local-dams', 'telegeography-submarine-cables', 'local-firms', 'earthquakes',
'local-datacenters',
'local-dams',
'telegeography-submarine-cables',
'local-firms',
'earthquakes',
]) {
assert.ok(paragraph.includes(layerId), `mapping must name the existing ${layerId} enum value`);
assert.ok(
paragraph.includes(layerId),
`mapping must name the existing ${layerId} enum value`,
);
}
assert.ok(paragraph.includes('zoom_to_globe'));
assert.ok(paragraph.includes('set_layer_visibility'));
});
test('every layer a mission drives is already in the shipped set_layer_visibility enum', () => {
const tool = GEV_REALTIME_TOOLS.find(tool => tool.name === 'set_layer_visibility');
const tool = GEV_REALTIME_TOOLS.find(
(tool) => tool.name === 'set_layer_visibility',
);
const allowedLayers = tool.parameters.properties.layerId.enum;
const missionLayerIds = Object.values(FIRST_RUN_MISSIONS).flatMap((mission) => mission.layerIds || []);
const missionLayerIds = Object.values(FIRST_RUN_MISSIONS).flatMap(
(mission) => mission.layerIds || [],
);
assert.ok(missionLayerIds.length > 0);
for (const layerId of missionLayerIds) {
assert.ok(allowedLayers.includes(layerId), `${layerId} must already be an allowed enum value`);
assert.ok(
allowedLayers.includes(layerId),
`${layerId} must already be an allowed enum value`,
);
}
});