Files
gods-eye-view/scripts/qa/traffic.mjs
T
German Khokhlov b5cc4feacb Restore the conditions eight converted QA scripts were waiting for
The harness conversion replaced pauses that stood in for real conditions
with camera readiness: the cables and infrastructure idle checks started
measuring while the overlay was still fading in after moveEnd, directions
sampled before its maneuver dots had ground cells, three scripts clicked
before the loading cover was gone, the credits check hit-tested during UI
transitions, and the oblique traffic flight lost its height cap. Each now
waits for its condition; idle checks observe without requesting frames
and record the reasons of the frames they count; readiness waits for the
startup cover and no longer requests frames while polling.
2026-11-10 20:14:50 +04:00

70 lines
2.2 KiB
JavaScript

import { evaluateWithGeo } from './geometry.mjs';
import { whenSettled, whenTilesLoaded } from './ready.mjs';
/** Preserve the oblique fixture's native collision and flight-arc settings. */
export function moveTrafficCamera(page, view, seconds) {
return evaluateWithGeo(
page,
async (geo, view, duration) => {
const { engine, viewer } = window.__godsEyeView;
const native = engine.kind === 'cesium';
const camera = native ? viewer.camera : engine.camera;
// These low-altitude fixture poses must not be lifted by native collision.
if (native)
viewer.scene.screenSpaceCameraController.enableCollisionDetection = false;
camera.cancelFlight();
await new Promise((resolve) =>
camera.flyTo({
destination: geo.cartesian3.fromDegrees(
view.lon,
view.lat,
view.height,
),
orientation: {
heading: ((view.heading ?? 0) * Math.PI) / 180,
pitch: ((view.pitch ?? -45) * Math.PI) / 180,
roll: 0,
},
duration,
// An automatic high arc crosses the traffic layer's activation ceiling.
maximumHeight: Math.max(view.height, engine.camera.height()),
complete: resolve,
cancel: resolve,
}),
);
},
view,
seconds,
);
}
/** A quiet loader can still be waiting for its camera-change debounce. */
export async function whenTrafficSettled(page) {
await whenTilesLoaded(page);
await whenSettled(page);
const handle = await page.waitForFunction(
() => {
const { engine, dataManager } = window.__godsEyeView;
const pose = engine.camera.pose();
const viewKey = [
pose.cartographic.latitude,
pose.cartographic.longitude,
pose.cartographic.height / 10000,
pose.heading,
pose.pitch,
]
.map((value) => Number(value || 0).toFixed(7))
.join(',');
const stats = dataManager.layers.get('traffic').module.getStats();
return (
stats.roadBounds?.coverage?.viewKey === viewKey &&
stats.count > 0 &&
!stats.loading &&
!stats.surfacePending
);
},
{ timeout: 60000, polling: 100 },
);
await handle.dispose();
}