mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-06 19:34:01 +00:00
Assert that the traffic population after a globe round trip stays near the population before it
Both are read after the same settle delay; the population is checked again once the vehicle comparison is taken.
This commit is contained in:
1 parent
eed8acc3f7
commit
5564156c09
1 file changed
+78
-64
@@ -113,59 +113,8 @@ try {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
await waitTraffic();
|
await waitTraffic();
|
||||||
await new Promise((resolve) => setTimeout(resolve, 2000));
|
// The view compared before and after the switches: a central window free of
|
||||||
const ids = await p.evaluate(() =>
|
// panels and status toasts.
|
||||||
window.qaTraffic.getDetectableObjects().map((p) => p.id),
|
|
||||||
);
|
|
||||||
const first = await p.evaluate(
|
|
||||||
() => window.qaTraffic.getStats().motion.rebuilds,
|
|
||||||
);
|
|
||||||
const population = await p.evaluate(() => window.qaTraffic.getStats().count);
|
|
||||||
for (const kind of ['navara', 'cesium', 'navara']) {
|
|
||||||
if ((await p.evaluate(() => window.__godsEyeView.engine.kind)) !== kind) {
|
|
||||||
await p.select('#globe-engine', kind);
|
|
||||||
await ready(kind);
|
|
||||||
}
|
|
||||||
await waitTraffic();
|
|
||||||
const check = await p.evaluate(() => {
|
|
||||||
const { dataManager } = window.__godsEyeView;
|
|
||||||
const mod = dataManager.layers.get('traffic').module;
|
|
||||||
return {
|
|
||||||
same: mod === window.qaTraffic,
|
|
||||||
...mod.getStats(),
|
|
||||||
params: mod.getParams(),
|
|
||||||
ids: mod.getDetectableObjects().map((p) => p.id),
|
|
||||||
};
|
|
||||||
});
|
|
||||||
console.log(
|
|
||||||
kind,
|
|
||||||
check.mode,
|
|
||||||
check.count,
|
|
||||||
check.flowBuckets,
|
|
||||||
check.heatLines,
|
|
||||||
check.motion,
|
|
||||||
);
|
|
||||||
assert.equal(check.same, true);
|
|
||||||
assert.equal(check.params.jamViz, 'both');
|
|
||||||
assert.equal(check.error, null);
|
|
||||||
assert.equal(
|
|
||||||
check.motion.rebuilds,
|
|
||||||
first,
|
|
||||||
'traffic population was cleared',
|
|
||||||
);
|
|
||||||
assert.ok(
|
|
||||||
check.ids.some((id) => ids.includes(id)),
|
|
||||||
'original moving vehicles survived',
|
|
||||||
);
|
|
||||||
if (!keyless)
|
|
||||||
assert.ok(check.heatLines > 0, 'congestion corridors are published');
|
|
||||||
if (keyless) assert.equal(check.flowBuckets.sim, check.count);
|
|
||||||
else assert.ok(check.flowBuckets.slow + check.flowBuckets.jam > 0);
|
|
||||||
}
|
|
||||||
if (keyless)
|
|
||||||
assert.ok(![...reads.keys()].some((u) => u.includes('/tomtom/flow/')));
|
|
||||||
// Compare the same view with the layer shown and hidden, vehicle by
|
|
||||||
// vehicle. Only a central window free of panels and status toasts counts.
|
|
||||||
const region = { left: 310, top: 160, right: 810, bottom: 660 };
|
const region = { left: 310, top: 160, right: 810, bottom: 660 };
|
||||||
// Each vehicle in the window with its window position and its height above
|
// Each vehicle in the window with its window position and its height above
|
||||||
// the terrain Navara draws there. A vehicle below that terrain is hidden by
|
// the terrain Navara draws there. A vehicle below that terrain is hidden by
|
||||||
@@ -221,21 +170,81 @@ try {
|
|||||||
await new Promise((resolve) => setTimeout(resolve, 500));
|
await new Promise((resolve) => setTimeout(resolve, 500));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
// The population once roads, heights and dots have settled. Source counts
|
||||||
|
// can be ready before the renderer has drawn terrain, so the camera and the
|
||||||
|
// attached road heights get the same delay before and after the switches.
|
||||||
|
const settledPopulation = async () => {
|
||||||
|
await new Promise((resolve) => setTimeout(resolve, 2200));
|
||||||
|
await settled();
|
||||||
|
return p.evaluate(() => window.qaTraffic.getStats().count);
|
||||||
|
};
|
||||||
|
const population = await settledPopulation();
|
||||||
|
const buriedBefore = (await vehiclesInView()).filter(
|
||||||
|
(v) => v.clearance != null && v.clearance <= -1,
|
||||||
|
).length;
|
||||||
|
const ids = await p.evaluate(() =>
|
||||||
|
window.qaTraffic.getDetectableObjects().map((p) => p.id),
|
||||||
|
);
|
||||||
|
const first = await p.evaluate(
|
||||||
|
() => window.qaTraffic.getStats().motion.rebuilds,
|
||||||
|
);
|
||||||
|
for (const kind of ['navara', 'cesium', 'navara']) {
|
||||||
|
if ((await p.evaluate(() => window.__godsEyeView.engine.kind)) !== kind) {
|
||||||
|
await p.select('#globe-engine', kind);
|
||||||
|
await ready(kind);
|
||||||
|
}
|
||||||
|
await waitTraffic();
|
||||||
|
const check = await p.evaluate(() => {
|
||||||
|
const { dataManager } = window.__godsEyeView;
|
||||||
|
const mod = dataManager.layers.get('traffic').module;
|
||||||
|
return {
|
||||||
|
same: mod === window.qaTraffic,
|
||||||
|
...mod.getStats(),
|
||||||
|
params: mod.getParams(),
|
||||||
|
ids: mod.getDetectableObjects().map((p) => p.id),
|
||||||
|
};
|
||||||
|
});
|
||||||
|
console.log(
|
||||||
|
kind,
|
||||||
|
check.mode,
|
||||||
|
check.count,
|
||||||
|
check.flowBuckets,
|
||||||
|
check.heatLines,
|
||||||
|
check.motion,
|
||||||
|
);
|
||||||
|
assert.equal(check.same, true);
|
||||||
|
assert.equal(check.params.jamViz, 'both');
|
||||||
|
assert.equal(check.error, null);
|
||||||
|
assert.equal(
|
||||||
|
check.motion.rebuilds,
|
||||||
|
first,
|
||||||
|
'traffic population was cleared',
|
||||||
|
);
|
||||||
|
assert.ok(
|
||||||
|
check.ids.some((id) => ids.includes(id)),
|
||||||
|
'original moving vehicles survived',
|
||||||
|
);
|
||||||
|
if (!keyless)
|
||||||
|
assert.ok(check.heatLines > 0, 'congestion corridors are published');
|
||||||
|
if (keyless) assert.equal(check.flowBuckets.sim, check.count);
|
||||||
|
else assert.ok(check.flowBuckets.slow + check.flowBuckets.jam > 0);
|
||||||
|
}
|
||||||
|
if (keyless)
|
||||||
|
assert.ok(![...reads.keys()].some((u) => u.includes('/tomtom/flow/')));
|
||||||
|
// Compare the same view with the layer shown and hidden, vehicle by
|
||||||
|
// vehicle.
|
||||||
const raw = async () =>
|
const raw = async () =>
|
||||||
sharp(await p.screenshot())
|
sharp(await p.screenshot())
|
||||||
.removeAlpha()
|
.removeAlpha()
|
||||||
.raw()
|
.raw()
|
||||||
.toBuffer({ resolveWithObject: true });
|
.toBuffer({ resolveWithObject: true });
|
||||||
// Source counts can be ready before the incoming renderer has drawn terrain.
|
const settledCount = await settledPopulation();
|
||||||
// Let the camera and the newly attached road heights settle before comparison.
|
|
||||||
await new Promise((resolve) => setTimeout(resolve, 2200));
|
|
||||||
await settled();
|
|
||||||
const settledCount = await p.evaluate(
|
|
||||||
() => window.qaTraffic.getStats().count,
|
|
||||||
);
|
|
||||||
const before = await vehiclesInView();
|
const before = await vehiclesInView();
|
||||||
const shown = await raw();
|
const shown = await raw();
|
||||||
const after = new Map((await vehiclesInView()).map((v) => [v.id, v]));
|
const after = new Map((await vehiclesInView()).map((v) => [v.id, v]));
|
||||||
|
// Read again once the comparison is taken: the population used to fall
|
||||||
|
// seconds after the return, once the incoming globe republished the roads.
|
||||||
|
const finalCount = await p.evaluate(() => window.qaTraffic.getStats().count);
|
||||||
await p.evaluate(() =>
|
await p.evaluate(() =>
|
||||||
window.__godsEyeView.dataManager.setEnabled('traffic', false, {
|
window.__godsEyeView.dataManager.setEnabled('traffic', false, {
|
||||||
origin: 'user',
|
origin: 'user',
|
||||||
@@ -307,16 +316,21 @@ try {
|
|||||||
buried,
|
buried,
|
||||||
);
|
);
|
||||||
// The checks after each switch run before the incoming globe republishes
|
// The checks after each switch run before the incoming globe republishes
|
||||||
// the roads. Report what the population settles to; it is not asserted yet.
|
// the roads; these compare what the population settles to.
|
||||||
console.log(
|
console.log(
|
||||||
'population before the switches',
|
'population before the switches',
|
||||||
population,
|
population,
|
||||||
'settled after the round trip',
|
'settled after the round trip',
|
||||||
settledCount,
|
settledCount,
|
||||||
|
'after the comparison',
|
||||||
|
finalCount,
|
||||||
|
'below the drawn terrain before the switches',
|
||||||
|
buriedBefore,
|
||||||
);
|
);
|
||||||
if (settledCount < 0.8 * population)
|
for (const count of [settledCount, finalCount])
|
||||||
console.log(
|
assert.ok(
|
||||||
'known defect: the traffic population shrinks after returning to Navara',
|
count >= 0.8 * population && count <= 1.25 * population,
|
||||||
|
`the population after the round trip (${count}) stays within 80-125% of the ${population} before it`,
|
||||||
);
|
);
|
||||||
assert.ok(aboveGround >= 12, 'at least 12 vehicles above ground in view');
|
assert.ok(aboveGround >= 12, 'at least 12 vehicles above ground in view');
|
||||||
assert.ok(
|
assert.ok(
|
||||||
|
|||||||
Reference in new issue
Block a user