Test scope opacity, the Visual reset and the panel's presets

The share codec carries field 30 and still encodes a link made before it
to the same code; the long form writes sco only below full opacity; the
mask fades without repainting; the panel shows and sets the opacity, and
the reset and the presets call their actions.

Co-authored-by: Manjunath Paparaju <[email protected]>
This commit is contained in:
Sameh KhamisandManjunath Paparaju committed 2026-11-14 15:31:33 -08:00
1 parent 471151910d
commit 6c1744e55b
6 files changed
+294 -1

No files matched your search

+50
View File
@@ -119,6 +119,7 @@ function randomState(random) {
detectionFadePct: maybe(0.5, int(0, 40)),
detectionOutsideOpacityPct: maybe(0.5, int(0, 100)),
scopeFeatherPct: maybe(0.5, int(0, 200)),
scopeOpacityPct: maybe(0.5, int(0, 100)),
scopeTerminusPct: maybe(
0.3,
int(SCOPE_TERMINUS_MIN_PCT, SCOPE_TERMINUS_MAX_PCT),
@@ -210,6 +211,7 @@ test('each setting costs bytes only when it differs from its default', () => {
detectionFadePct: 8,
detectionOutsideOpacityPct: 2,
scopeFeatherPct: 99,
scopeOpacityPct: 40,
scopeTerminusPct: 95,
};
const defaults = createDefaultShareViewState();
@@ -355,6 +357,7 @@ test('every registered field round-trips at once', () => {
celestialRing: true,
scopeEnabled: false,
scopeFeatherPct: 35,
scopeOpacityPct: 60,
scopeTerminusPct: 97,
mapStack: 'esri-imagery',
layerState,
@@ -1587,3 +1590,50 @@ test('Data Library tokens round-trip and malformed ones are skipped', () => {
assert.equal(normalizeLibraryTokens(null), null);
assert.deepEqual(normalizeLibraryTokens('x'.repeat(500)), []);
});
test('scope opacity is field 30; a link made before it opens at full opacity', () => {
// Made before field 30 existed: thermal, Cyber, Scope off at 35% feather
// and a pinned terminus.
const before = 'ARD-7j4YuxMguBcoUEgQcAOAAQPIASPQAWGa';
const old = decodeOk(before).state;
assert.equal(old.scopeOpacityPct, 100);
assert.equal(old.scopeFeatherPct, 35);
assert.equal(encodeShareView(old), before, 'it still encodes to itself');
const state = {
lat: 51.5007,
lon: -0.1246,
alt: 1500,
heading: 40,
style: 'thermal',
scopeEnabled: false,
scopeFeatherPct: 35,
scopeTerminusPct: 97,
hudVariant: 'cyber',
};
assert.equal(encodeShareView(state), before);
assert.equal(encodeShareView({ ...state, scopeOpacityPct: 100 }), before);
const faded = assertRoundTrip({ ...state, scopeOpacityPct: 45 });
assert.notEqual(faded, before);
assert.equal(decodeOk(faded).state.scopeOpacityPct, 45);
assert.equal(
decodeOk(assertRoundTrip({ scopeOpacityPct: 0 })).state.scopeOpacityPct,
0,
);
// Out of range is clamped; anything not a number is the default.
assert.equal(
normalizeShareViewState({ scopeOpacityPct: 150 }).scopeOpacityPct,
100,
);
assert.equal(
normalizeShareViewState({ scopeOpacityPct: -5 }).scopeOpacityPct,
0,
);
assert.equal(
normalizeShareViewState({ scopeOpacityPct: 33.6 }).scopeOpacityPct,
34,
);
assert.equal(
normalizeShareViewState({ scopeOpacityPct: 'x' }).scopeOpacityPct,
100,
);
});