mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-17 08:42:21 +00:00
Fix the camera picker and oblique traffic waits in two QA scripts
The CCTV camera check lost camera B from the picker when the flight to camera A changed the cameras in view; the picker now keeps focus while A is held. The oblique traffic wait compared exact seven-decimal view keys that a settled camera never reproduced; it compares the coverage with the current view within small tolerances and prints both keys on timeout.
This commit is contained in:
1 parent
97e192ebce
commit
6b0d3f4675
4 files changed
+271
-31
No files matched your search
+106
-7
@@ -1,7 +1,12 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
import { createFakeEngine } from '../../src/globe/testing/fakeEngine.js';
|
||||
import { moveTrafficCamera, whenTrafficSettled } from './traffic.mjs';
|
||||
import { createReticleFootprint } from '../../src/layers/traffic/footprint.js';
|
||||
import {
|
||||
moveTrafficCamera,
|
||||
trafficReadiness,
|
||||
whenTrafficSettled,
|
||||
} from './traffic.mjs';
|
||||
|
||||
function fixture(t) {
|
||||
const engine = createFakeEngine({ kind: 'cesium' });
|
||||
@@ -69,7 +74,9 @@ test('traffic readiness rejects old coverage, pending debounce and partial popul
|
||||
let disposed = 0;
|
||||
await whenTrafficSettled({
|
||||
evaluate: async () => {},
|
||||
async waitForFunction(predicate) {
|
||||
async waitForFunction(expression) {
|
||||
const predicate = () =>
|
||||
typeof expression === 'function' ? expression() : eval(expression);
|
||||
if (++calls < 3) assert.equal(predicate(), true);
|
||||
else {
|
||||
assert.equal(
|
||||
@@ -100,17 +107,109 @@ test('traffic readiness rejects old coverage, pending debounce and partial popul
|
||||
assert.equal(disposed, 3);
|
||||
});
|
||||
|
||||
test('traffic loading timeouts fail the scenario', async (t) => {
|
||||
fixture(t);
|
||||
test('traffic readiness accepts the layer footprint after rounding and tiny pose drift', (t) => {
|
||||
const app = fixture(t);
|
||||
app.engine.fake.setPose({
|
||||
latitude: (30.2672 * Math.PI) / 180,
|
||||
longitude: (-97.7431 * Math.PI) / 180,
|
||||
height: 300,
|
||||
heading: 2 * Math.PI - 1e-8,
|
||||
pitch: -Math.PI / 12,
|
||||
});
|
||||
const stats = {
|
||||
count: 100,
|
||||
loading: false,
|
||||
surfacePending: 0,
|
||||
roadBounds: createReticleFootprint()(app.engine, 300),
|
||||
};
|
||||
app.dataManager = {
|
||||
layers: new Map([['traffic', { module: { getStats: () => stats } }]]),
|
||||
};
|
||||
assert.equal(trafficReadiness().settled, true);
|
||||
app.engine.fake.setPose({
|
||||
latitude: (30.2672 * Math.PI) / 180 + 2e-8,
|
||||
longitude: (-97.7431 * Math.PI) / 180 - 2e-8,
|
||||
height: 300.1,
|
||||
heading: 1e-8,
|
||||
pitch: -Math.PI / 12 + 2e-8,
|
||||
});
|
||||
const observed = trafficReadiness();
|
||||
assert.notEqual(observed.viewKey, observed.coverageViewKey);
|
||||
assert.equal(observed.settled, true);
|
||||
});
|
||||
|
||||
test('traffic readiness rejects changed views and malformed coverage keys', (t) => {
|
||||
const app = fixture(t);
|
||||
const stats = {
|
||||
count: 100,
|
||||
loading: false,
|
||||
surfacePending: 0,
|
||||
roadBounds: { coverage: {} },
|
||||
};
|
||||
app.dataManager = {
|
||||
layers: new Map([['traffic', { module: { getStats: () => stats } }]]),
|
||||
};
|
||||
for (const key of [
|
||||
null,
|
||||
'old view',
|
||||
'0,0,0.1,0',
|
||||
'0,0,0.1,0,NaN',
|
||||
'0,0,Infinity,0,-0.2617994',
|
||||
'0.01,0,0.1,0,-0.2617994',
|
||||
'0,0.01,0.1,0,-0.2617994',
|
||||
'0,0,0.3,0,-0.2617994',
|
||||
'0,0,0.1,0.01,-0.2617994',
|
||||
'0,0,0.1,0,-0.7853982',
|
||||
]) {
|
||||
stats.roadBounds.coverage.viewKey = key;
|
||||
assert.equal(trafficReadiness().settled, false, String(key));
|
||||
}
|
||||
});
|
||||
|
||||
test('traffic loading timeouts include both keys and pending work', async (t) => {
|
||||
const app = fixture(t);
|
||||
const coverageViewKey = '0.01,0,0.1,0,-0.2617994';
|
||||
app.dataManager = {
|
||||
layers: new Map([
|
||||
[
|
||||
'traffic',
|
||||
{
|
||||
module: {
|
||||
getStats: () => ({
|
||||
count: 12,
|
||||
loading: true,
|
||||
surfacePending: 2,
|
||||
roadBounds: { coverage: { viewKey: coverageViewKey } },
|
||||
}),
|
||||
},
|
||||
},
|
||||
],
|
||||
]),
|
||||
};
|
||||
const timeout = new Error('traffic loading timeout');
|
||||
timeout.name = 'TimeoutError';
|
||||
let calls = 0;
|
||||
await assert.rejects(
|
||||
whenTrafficSettled({
|
||||
evaluate: async () => {},
|
||||
evaluate: async (fn) => (typeof fn === 'function' ? fn() : undefined),
|
||||
async waitForFunction() {
|
||||
if (++calls === 3) throw new Error('traffic loading timeout');
|
||||
if (++calls === 3) throw timeout;
|
||||
return { dispose: async () => {} };
|
||||
},
|
||||
}),
|
||||
/traffic loading timeout/,
|
||||
(error) => {
|
||||
assert.equal(error.cause, timeout);
|
||||
assert.match(error.message, /Readiness timeout: traffic/);
|
||||
assert.ok(
|
||||
error.message.includes(`"coverageViewKey":"${coverageViewKey}"`),
|
||||
);
|
||||
assert.ok(
|
||||
error.message.includes(
|
||||
'"viewKey":"0.0000000,0.0000000,0.1000000,0.0000000,-0.2617994"',
|
||||
),
|
||||
);
|
||||
assert.match(error.message, /"loading":true,"surfacePending":2/);
|
||||
return true;
|
||||
},
|
||||
);
|
||||
});
|
||||
Reference in new issue
Block a user