mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 16:22:20 +00:00
fix(cockpit): a place pack that will not load ends the loading batch failed; flags keep their neighbours out from under the border and out of a scaled flag's edge; a new ride asks again for a sheet that failed
This commit is contained in:
1 parent
5a6cf22be1
commit
e954734379
16 files changed
+198
-55
No files matched your search
@@ -0,0 +1,59 @@
|
||||
// src/ui/placePacksLoading.test.mjs — the loading status names the place
|
||||
// packs while they load, and a failed pack ends the batch as failed.
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import {
|
||||
aggregateLayerLoading,
|
||||
createLoadingFeedbackState,
|
||||
reduceLoadingFeedback,
|
||||
} from '../loadingFeedback.js';
|
||||
import { withPlacePacks } from './placePacksLoading.js';
|
||||
|
||||
const SATELLITES = Object.freeze({
|
||||
id: 'satellites',
|
||||
name: 'Satellites',
|
||||
enabled: true,
|
||||
stats: { count: 9000, lastUpdate: 1 },
|
||||
});
|
||||
|
||||
function batch(states) {
|
||||
let state = createLoadingFeedbackState();
|
||||
let now = 0;
|
||||
for (const status of states) {
|
||||
now += 1000;
|
||||
state = reduceLoadingFeedback(
|
||||
state,
|
||||
aggregateLayerLoading(withPlacePacks([SATELLITES], status)),
|
||||
now,
|
||||
);
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
||||
test('nothing extra while the packs are idle', () => {
|
||||
const layers = [SATELLITES];
|
||||
assert.equal(
|
||||
withPlacePacks(layers, { loading: false, failed: false }),
|
||||
layers,
|
||||
);
|
||||
});
|
||||
|
||||
test('the packs are named while they load', () => {
|
||||
const summary = aggregateLayerLoading(
|
||||
withPlacePacks([SATELLITES], { loading: true, failed: false }),
|
||||
);
|
||||
assert.deepEqual(summary.activeIds, ['place-names']);
|
||||
assert.equal(summary.active[0].label, 'Place names');
|
||||
});
|
||||
|
||||
test('a load that lands ends complete; one that fails ends failed', () => {
|
||||
const loading = { loading: true, failed: false };
|
||||
assert.equal(
|
||||
batch([loading, { loading: false, failed: false }]).terminal,
|
||||
'complete',
|
||||
);
|
||||
assert.equal(
|
||||
batch([loading, { loading: false, failed: true }]).terminal,
|
||||
'error',
|
||||
);
|
||||
});
|
||||
Reference in new issue
Block a user