mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-19 17:52:21 +00:00
Tidy the Rail and Transit ride fixes after review
- A train first seen standing takes its direction from the operator's course, not from a course drawn out of GPS jitter. - Moving a hold to another vehicle releases the first one the same way as ending the hold. - repaint always goes through placeSample, which hides the held vehicle and puts it on its current segment, so setShown is no longer exported. - Tests cover the icon right after a hold, a segment with one known floor, a known floor at 0 m and selection by click after the layer comes back; shared helpers replace repeated setup. - Comments, CURRENT-STATE and the release note say what the code does without internal figures.
This commit is contained in:
1 parent
ee5a6ab317
commit
df4d76384c
8 files changed
+209
-90
No files matched your search
@@ -151,6 +151,39 @@ test('a train drawn on an unknown floor reports no rail height', async (t) => {
|
||||
);
|
||||
});
|
||||
|
||||
test('a train on a known floor at sea level reports a rail height of 0 m', async (t) => {
|
||||
const app = await onTheLine(t, {
|
||||
ground: { ...WARM_GROUND, cachedGroundFloor: () => 0 },
|
||||
});
|
||||
app.parts().selection.selectTrain(T1);
|
||||
const { position } = app.layer.getSelectedTrain();
|
||||
assert.ok(position.heightQuality > 0, 'the floor is known');
|
||||
assert.equal(position.railHeightM, 0, 'a height, not none');
|
||||
});
|
||||
|
||||
test('a train first seen standing takes no direction from its GPS jitter', async (t) => {
|
||||
// Neither reports 13 m apart nor the course drawn between them say which way
|
||||
// it runs; an operator's bearing does.
|
||||
const app = harness(t, { paths: { 'mbta-rail': PACK }, at: BOSTON });
|
||||
let jitterM = 0;
|
||||
app.feeds.set('mbta-rail', () => [
|
||||
train('T1', LAT, LON0 + (1000 + jitterM) / KX),
|
||||
train('T2', LAT, LON0 + (3000 + jitterM) / KX, { bearing: 270 }),
|
||||
]);
|
||||
await app.enable();
|
||||
const seen = [];
|
||||
for (const next of [13, 0, 13, 0, 13, 0]) {
|
||||
jitterM = next;
|
||||
app.run(RAIL_POLL_MS);
|
||||
await app.poll();
|
||||
app.parts().selection.selectTrain(T1);
|
||||
const standing = app.layer.getSelectedTrain().path.direction;
|
||||
app.parts().selection.selectTrain(T2);
|
||||
seen.push([standing, app.layer.getSelectedTrain().path.direction]);
|
||||
}
|
||||
assert.deepEqual(seen, Array(6).fill([0, -1]));
|
||||
});
|
||||
|
||||
test('a snapshot read again while nothing changed is the one read before', async (t) => {
|
||||
let list = stopList('Alpha', 'Bravo', 'Charlie');
|
||||
const app = await onTheLine(t, {
|
||||
|
||||
Reference in new issue
Block a user