test(ui): pin the midpoint band's exact minimum, and correct a test comment

Co-authored-by: Manjunath Paparaju <[email protected]>
This commit is contained in:
Sameh KhamisandManjunath Paparaju committed 2026-11-18 23:26:10 -08:00
1 parent 10dbd2f937
commit fd64a78aca
1 file changed
+12 -1
+12 -1
View File
@@ -31,6 +31,7 @@ import {
speedRulerStep,
speedRulerTicks,
} from './cockpitMath.js';
import { bandBesideMidpointObstacles } from './ui/panelRailGeometry.js';
test('cockpit presentation updates are throttled independently of camera frames', () => {
assert.equal(cockpitUiUpdateDue(1000, 0, 100), true);
@@ -390,12 +391,22 @@ test('HUD rail layout counts obstacles beside those across the midpoint', () =>
// Neighbours exactly two gaps away leave no room between: one block, 100
// to 400, and a tie (50px a side) goes above.
assert.deepEqual(band([[100, 180], [200, 300], [320, 400]]), [40, 90]);
// A neighbour exactly two gaps below joins it too: 150 to 300, 110px
// A neighbour exactly two gaps below joins it too: 150 to 300, 100px
// above against 150 below.
assert.deepEqual(band([[150, 250], [270, 300]]), [310, 460]);
// A side under 8% of the window (38.4px) is no room: 30px above, none
// below, so the band stays as it is.
assert.deepEqual(band([[80, 455]]), [40, 460]);
// Exactly the minimum is enough.
const exact = bandBesideMidpointObstacles({
midpoint: 240,
top: 40,
bottom: 460,
obstacles: [{ top: 90, bottom: 465 }],
gap: 10,
minimum: 40,
});
assert.deepEqual([exact?.top, exact?.bottom], [40, 80]);
});
test('HUD rail layout keeps a band beside a midpoint obstacle inside its own edges', () => {