mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-05 19:04:02 +00:00
test: add deterministic imagery option to tracking regression
This commit is contained in:
1 parent
694e062ad4
commit
9c01f24fdf
1 file changed
+31
@@ -88,6 +88,7 @@
|
|||||||
* --source-base <path> Browser module prefix (default /src)
|
* --source-base <path> Browser module prefix (default /src)
|
||||||
* --url <url> App URL (default http://localhost:4173)
|
* --url <url> App URL (default http://localhost:4173)
|
||||||
* --headful Show the browser (debugging)
|
* --headful Show the browser (debugging)
|
||||||
|
* --offline-imagery Use bundled texture for known Esri/OSM tile images only
|
||||||
* --keep-open Leave the browser open after the run (debugging)
|
* --keep-open Leave the browser open after the run (debugging)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -110,6 +111,7 @@ const SOURCE_BASE = getOpt('--source-base', '/src').replace(/\/$/, '');
|
|||||||
const APP_URL = getOpt('--url', 'http://localhost:4173');
|
const APP_URL = getOpt('--url', 'http://localhost:4173');
|
||||||
const APP_ORIGIN = new URL(APP_URL).origin;
|
const APP_ORIGIN = new URL(APP_URL).origin;
|
||||||
const HEADFUL = getFlag('--headful');
|
const HEADFUL = getFlag('--headful');
|
||||||
|
const OFFLINE_IMAGERY = getFlag('--offline-imagery');
|
||||||
const KEEP_OPEN = getFlag('--keep-open');
|
const KEEP_OPEN = getFlag('--keep-open');
|
||||||
|
|
||||||
const CHROME_EXECUTABLE_CANDIDATES = [
|
const CHROME_EXECUTABLE_CANDIDATES = [
|
||||||
@@ -201,6 +203,15 @@ async function main() {
|
|||||||
console.log(` App URL : ${APP_URL}`);
|
console.log(` App URL : ${APP_URL}`);
|
||||||
console.log(` Mode : ${HEADFUL ? 'headful' : 'headless'}\n`);
|
console.log(` Mode : ${HEADFUL ? 'headful' : 'headless'}\n`);
|
||||||
|
|
||||||
|
// Tracking does not assert imagery geography. This optional fixture leaves
|
||||||
|
// provider metadata, terrain, models and every tracking assertion untouched.
|
||||||
|
// Read before launching so a missing bundled asset fails explicitly.
|
||||||
|
const offlineImageryTile = OFFLINE_IMAGERY
|
||||||
|
? fs.readFileSync(new URL('../node_modules/cesium/Build/Cesium/Assets/Textures/NaturalEarthII/0/0/0.jpg', import.meta.url))
|
||||||
|
: null;
|
||||||
|
let offlineImageryRequests = 0;
|
||||||
|
if (OFFLINE_IMAGERY) console.log(' Imagery : bundled NaturalEarthII fixture (tile images only)');
|
||||||
|
|
||||||
// Verify the dev server is up before launching a browser.
|
// Verify the dev server is up before launching a browser.
|
||||||
try {
|
try {
|
||||||
const res = await fetch(APP_URL, { method: 'GET' });
|
const res = await fetch(APP_URL, { method: 'GET' });
|
||||||
@@ -256,6 +267,25 @@ async function main() {
|
|||||||
await page.setRequestInterception(true);
|
await page.setRequestInterception(true);
|
||||||
page.on('request', (request) => {
|
page.on('request', (request) => {
|
||||||
const url = new URL(request.url());
|
const url = new URL(request.url());
|
||||||
|
// Reuse the one existing interceptor; do not install competing handlers.
|
||||||
|
// Exact HTTPS origins and image paths only: metadata, feature queries,
|
||||||
|
// other providers, terrain and local/model resources continue normally.
|
||||||
|
const knownImageryTile = request.method() === 'GET' && (
|
||||||
|
(url.origin === 'https://services.arcgisonline.com'
|
||||||
|
&& /^\/ArcGIS\/rest\/services\/World_Imagery\/MapServer\/tile\/\d+\/\d+\/\d+$/.test(url.pathname))
|
||||||
|
|| (url.origin === 'https://tile.openstreetmap.org'
|
||||||
|
&& /^\/\d+\/\d+\/\d+\.png$/.test(url.pathname))
|
||||||
|
);
|
||||||
|
if (OFFLINE_IMAGERY && knownImageryTile) {
|
||||||
|
offlineImageryRequests++;
|
||||||
|
request.respond({
|
||||||
|
status: 200,
|
||||||
|
contentType: 'image/jpeg',
|
||||||
|
headers: { 'Access-Control-Allow-Origin': '*' },
|
||||||
|
body: offlineImageryTile,
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (url.origin === APP_ORIGIN && url.pathname === '/api/openai/hud-summary') {
|
if (url.origin === APP_ORIGIN && url.pathname === '/api/openai/hud-summary') {
|
||||||
request.respond({
|
request.respond({
|
||||||
status: 200,
|
status: 200,
|
||||||
@@ -4095,6 +4125,7 @@ async function main() {
|
|||||||
|
|
||||||
finishAndExit();
|
finishAndExit();
|
||||||
} finally {
|
} finally {
|
||||||
|
if (OFFLINE_IMAGERY) console.log(` Bundled imagery tiles served: ${offlineImageryRequests}`);
|
||||||
if (!KEEP_OPEN) {
|
if (!KEEP_OPEN) {
|
||||||
await browser.close();
|
await browser.close();
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in new issue
Block a user