mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 08:12:24 +00:00
fix(cockpit): an application subject's wait for the floor is bounded, a late asynchronous hold is released, and a hold never counts as the user's selection
- A subject with no height at all waits at most COCKPIT_GROUND_WAIT_TIMEOUT_MS for the floor, its HUD updating and reading ACQUIRING SURFACE; then the view ends and the provider gets its subject back (there is no height of its own to fall back to). - A hold that returns a promise is refused as before and released again once it settles, unless that subject is being ridden by then; release must tolerate a second call. - Rail and Transit stamp selectedAtMs only for a user's selection (a click, focusTrain or focusVehicle); a deselection clears it, and a train or vehicle selected only by a hold reads null.
This commit is contained in:
1 parent
1e4060f6ba
commit
4c33552105
13 files changed
+239
-28
No files matched your search
@@ -4196,6 +4196,32 @@ test('the selected vehicle reads as a snapshot of its place, motion and source',
|
||||
assert.ok(Number.isFinite(view.position.latitude));
|
||||
});
|
||||
|
||||
test('selectedAtMs is the user’s selection time; a hold and a deselection leave none', async (t) => {
|
||||
const app = harness(t);
|
||||
const key = await busRunningNorth(app);
|
||||
// A vehicle only a hold selected reports none.
|
||||
assert.equal(app.layer.setCockpitSubject(key), true);
|
||||
assert.equal(app.layer.getCockpitSubject().selectedAtMs, null);
|
||||
app.layer.setCockpitSubject(null);
|
||||
assert.equal(app.layer.setCockpitSubject(null), true, 'twice is harmless');
|
||||
assert.equal(app.state()._selectedKey, key);
|
||||
// The user's selection stamps it, again on a re-selection.
|
||||
assert.equal(app.layer.focusVehicle(key), true);
|
||||
const first = app.layer.getSelectedVehicle().selectedAtMs;
|
||||
assert.ok(Number.isFinite(first));
|
||||
app.run(1000);
|
||||
app.layer.focusVehicle(key);
|
||||
assert.ok(app.layer.getSelectedVehicle().selectedAtMs > first);
|
||||
// Deselected, then held: none.
|
||||
globalThis.document.dispatchEvent(
|
||||
Object.assign(new Event('keydown'), { key: 'Escape' }),
|
||||
);
|
||||
assert.equal(app.state()._selectedKey, null);
|
||||
assert.equal(app.state()._selectedAtMs, null);
|
||||
app.layer.setCockpitSubject(key);
|
||||
assert.equal(app.layer.getCockpitSubject().selectedAtMs, null);
|
||||
});
|
||||
|
||||
test('a held vehicle hides, keeps moving out of view, and lets go when it goes', async (t) => {
|
||||
const app = harness(t);
|
||||
const key = await busRunningNorth(app);
|
||||
|
||||
Reference in new issue
Block a user