mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-17 16:52:20 +00:00
Fold duplicate coverage tests into their neighbours
This commit is contained in:
1 parent
5c4918affb
commit
ea76fc4bc0
9 files changed
+94
-328
No files matched your search
@@ -1,64 +0,0 @@
|
||||
// The Transit prompt names the altitude the gate opens at: at 2,900 km over
|
||||
// Boston (under 3,000 km, above the 2,850 km enter threshold) nothing loads.
|
||||
import { test } from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { createState } from './state.js';
|
||||
import { createViewport } from './viewport.js';
|
||||
import { createQueries } from './queries.js';
|
||||
import { ACTIVATION_ENTER_ALTITUDE_M } from './policy.js';
|
||||
|
||||
const BOSTON = { lat: 42.3601, lon: -71.0589 };
|
||||
|
||||
function makeLayer() {
|
||||
const services = {
|
||||
overlays: {
|
||||
setOverlayEntries() {},
|
||||
setOverlaySourceVisible() {},
|
||||
clearOverlaySource() {},
|
||||
},
|
||||
render: { governorRequestRender() {} },
|
||||
};
|
||||
const state = createState({ services });
|
||||
const polled = [];
|
||||
const parts = {
|
||||
ingestion: {
|
||||
feedStatus: () => ({ count: 0 }),
|
||||
pollFeed: (feed) => polled.push(feed.id),
|
||||
removeFeedVehicles() {},
|
||||
sweepAgedVehicles() {},
|
||||
},
|
||||
rendering: { requestVisibility() {}, syncRenderHold() {} },
|
||||
};
|
||||
parts.viewport = createViewport({ state, services, parts });
|
||||
const queries = createQueries({ state, parts }).methods;
|
||||
state._enabled = true;
|
||||
const rad = Math.PI / 180;
|
||||
state._viewer = {
|
||||
camera: {
|
||||
positionCartographic: {
|
||||
height: 0,
|
||||
latitude: BOSTON.lat * rad,
|
||||
longitude: BOSTON.lon * rad,
|
||||
},
|
||||
computeViewRectangle: () => undefined,
|
||||
},
|
||||
scene: { globe: {} },
|
||||
};
|
||||
return { state, queries, viewport: parts.viewport, polled };
|
||||
}
|
||||
|
||||
test('below the prompted altitude but above the gate, the prompt names the gate', () => {
|
||||
const { state, queries, viewport, polled } = makeLayer();
|
||||
state._viewer.camera.positionCartographic.height = 2_900_000;
|
||||
viewport.runProximityCheck();
|
||||
|
||||
// Nothing loads at 2,900 km: the gate opens at the enter threshold.
|
||||
assert.equal(state._altitudeGateOpen, false);
|
||||
assert.deepEqual(polled, []);
|
||||
|
||||
const km = Math.round(ACTIVATION_ENTER_ALTITUDE_M / 1000).toLocaleString(
|
||||
'en-US',
|
||||
);
|
||||
const { statusMessage } = queries.getStats();
|
||||
assert.equal(statusMessage, `Fly below ${km} km to a covered region`);
|
||||
});
|
||||
@@ -4021,3 +4021,15 @@ test('a view with no feed reads its coverage prompt, not an undated feed', async
|
||||
'Fly below 2,850 km to a covered region',
|
||||
);
|
||||
});
|
||||
|
||||
test('the prompt names the altitude the gate opens at, not 3,000 km', async (t) => {
|
||||
// 2,900 km is under ACTIVATION_ALTITUDE_M but above the enter threshold.
|
||||
const app = harness(t, { altitude: 2_900_000 });
|
||||
app.layer.enable(app.viewer);
|
||||
await app.layer.update();
|
||||
assert.deepEqual(app.requested, [], 'nothing loads over Boston');
|
||||
assert.equal(
|
||||
app.layer.getStats().statusMessage,
|
||||
'Fly below 2,850 km to a covered region',
|
||||
);
|
||||
});
|
||||
@@ -91,8 +91,10 @@ test('leaving a feed whose tick failed repaints its error away', async () => {
|
||||
await lifecycle.refreshLayer('transit');
|
||||
assert.match(row(), /feed unavailable/, 'the tick recorded the failure');
|
||||
|
||||
const before = painted.length;
|
||||
state._viewer = viewer(LONDON, 4_000);
|
||||
parts.viewport.runProximityCheck();
|
||||
assert.equal(queries.getStats().status, 'zoom-in');
|
||||
assert.ok(painted.length > before, 'leaving Boston repainted the row');
|
||||
assert.doesNotMatch(painted.at(-1), /feed unavailable/);
|
||||
});
|
||||
Reference in new issue
Block a user