Files
gods-eye-view/src/rightRailPolicy.test.mjs
T
Manjunath PaparajuandSameh Khamis 0a6fd5f43f Make Space Missions an ordinary layer with its own panel
Space Missions no longer runs as a Context mode. The launches layer owns
its Satellites dependency, including the rule that a Satellites off
asked for after Space Missions was switched on ends it (request order
decides), and a small controller connects the layer to its own panel and
store. Context no longer isolates, snapshots or restores Space Missions
or Satellites, so Contacts and Space Missions run together in either
order, and scene playback no longer exits an isolating mode. Settled by
the owner: Contacts leaves Satellites as it is, and only a person's or
voice Satellites off ends Space Missions; a scene, story, preset or
other programmatic off does not.

Turning the layer on by hand or by voice, choosing it at first run, or
picking a mission on the globe opens the Space Missions panel, and on a
phone its Missions sheet. Asking voice to open the panel while the layer
is off is refused with a reason, and voice never opens it while the
Cockpit owns the screen. With no Context mode on, a voice Context off
switches Space Missions off. A failed Satellites restore no longer cuts
the layer's teardown short. Mission labels on the globe select their
mission. The layer names a failed first index load itself, so the
Context toast no longer imports Space Missions code.

Also carries the satellites request ordering and
DataLayerManager.waitForLayerIdle, the share token for the panel, voice
panel ids, Cockpit folding the panel away and the phone tab ellipsis.
The panel shares the rail gutters and hover border of the other side
panels.

On top of the Omnibar: "open space missions panel" reaches the new
panel, and Open Context no longer answers to "missions".

Co-authored-by: Sameh Khamis <[email protected]>
2026-11-18 16:03:51 -08:00

75 lines
2.9 KiB
JavaScript

import { readStylesheet } from './testSupport/readStylesheet.mjs';
import assert from 'node:assert/strict';
import { readFileSync } from 'node:fs';
import test from 'node:test';
import { shouldExpandGlobalContextPanel } from './rightRailPolicy.js';
test('desktop side rails hide collapsed panels in every HUD layout, never on phones or beside Cockpit', () => {
const right = readFileSync(new URL('./ui/rightPanelRail.js', import.meta.url), 'utf8');
const left = readFileSync(new URL('./ui/leftPanelRail.js', import.meta.url), 'utf8');
const css = readStylesheet(new URL('../style.css', import.meta.url));
for (const ui of [right, left]) {
assert.match(ui, /const isMobile = windowRef\.matchMedia\('\(max-width: 720px\)'\)\.matches/);
assert.match(ui, /if \(exclusive && panel\.classList\.contains\('collapsed'\)\)\s*panel\.setAttribute\('aria-hidden', 'true'\)/);
assert.doesNotMatch(ui, /hud\.variant === 'cyber'/);
}
assert.match(right, /const exclusive = !isMobile;/);
// Cockpit keeps its collapsed Data Layers strip, which its layout aligns to.
assert.match(
left,
/const exclusive =\s*!isMobile && !documentRef\?\.body\?\.classList\?\.contains\('cockpit-mode'\);/,
);
assert.match(css, /#right-context-rail\.layout-exclusive > \[data-panel-id\]\.collapsed \{/);
assert.match(css, /#left-panel-stack\.layout-exclusive > \[data-panel-id\]\.collapsed \{/);
});
test('explicit Contacts and Cockpit actions expand Global Context after success', () => {
for (const action of ['contacts', 'cockpit']) {
assert.equal(shouldExpandGlobalContextPanel({
action,
explicitUserAction: true,
succeeded: true,
}), true, `${action} should reveal its supporting context`);
}
});
test('Cockpit expansion is independent of whether a track was already selected', () => {
for (const selectedTrack of [null, 'UAL649']) {
assert.equal(shouldExpandGlobalContextPanel({
action: 'cockpit',
explicitUserAction: true,
succeeded: true,
selectedTrack,
}), true);
}
});
test('restoration and programmatic replay preserve the saved Global Context collapse state', () => {
assert.equal(shouldExpandGlobalContextPanel({
action: 'contacts',
explicitUserAction: false,
succeeded: true,
}), false);
assert.equal(shouldExpandGlobalContextPanel({
action: 'contacts',
explicitUserAction: true,
succeeded: true,
restoring: true,
}), false);
});
test('failed or unrelated actions never expand Global Context', () => {
assert.equal(shouldExpandGlobalContextPanel({
action: 'contacts',
explicitUserAction: true,
succeeded: false,
}), false, 'a failed transition must preserve the prior panel state for rollback');
for (const action of ['search-nearby', 'space-missions']) {
assert.equal(shouldExpandGlobalContextPanel({
action,
explicitUserAction: true,
succeeded: true,
}), false);
}
});