mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-22 03:02:20 +00:00
fix(street-level): KartaView QA round — archived photos, connection budget, paging, ‹ ›
From two agentic QA passes (UX and failure modes): - A line click opens the nearest photo that can be shown: archived photos (409; a HEAD says 200) and records without files are skipped, a few at most, else 'KartaView's photos here are archived'. ‹ › skip them too. - api.kartaview.org is HTTP/1.1 (six connections): tiles take three, lookups two, sequence pages one, so a lookup never times out behind tiles; a timed-out lookup is asked once more; waits are capped at 10 s. - Sequence pages follow photo ids, not the index: a photo's page is found by search, a neighbour page joins near an edge, so ‹ › neither skip at page edges nor loop past gaps. Pages are 500 photos (~1.2 MB). - ‹ › open through the core without framing: loading, errors and cones behave as for any open; presses step on from the photo on its way; the ends disable up front. - Cones ignore the hidden IMAGERY / SINCE filters; no 'Selected' swatch for a source whose lines never highlight; 'no KartaView photos in view'; an unreadable tile is not cached as empty; a 0,0 fix is no photo; a failed lookup's error goes when another source is lit; the link goes through the image proxy; a stalled panorama shows its front view after 15 s instead of 60. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
310984ff0b
commit
454e261256
16 files changed
+683
-179
No files matched your search
@@ -5,7 +5,11 @@ import {
|
||||
createKartaViewSource,
|
||||
createLimiter,
|
||||
} from './source.js';
|
||||
import { PHOTO_API_CONCURRENCY, PHOTO_API_RETRIES } from './policy.js';
|
||||
import {
|
||||
PHOTO_API_CONCURRENCY,
|
||||
PHOTO_API_RETRIES,
|
||||
TILE_CONCURRENCY,
|
||||
} from './policy.js';
|
||||
|
||||
const ok = (body) => ({
|
||||
ok: true,
|
||||
@@ -87,12 +91,13 @@ test('rate-limiting that outlasts the retries is reported with a wait', async ()
|
||||
assert.ok(error instanceof KartaViewSourceError);
|
||||
assert.equal(error.status, 429);
|
||||
assert.ok(error.retryAfterSec > 0);
|
||||
assert.match(error.message, /try again in a moment/);
|
||||
return true;
|
||||
});
|
||||
assert.equal(calls, PHOTO_API_RETRIES + 1);
|
||||
});
|
||||
|
||||
test('an API refusal inside a 200 is an error with KartaView’s message; 601 is just empty', async () => {
|
||||
test('an API refusal inside a 200 is a readable error with its code; 601 is just empty', async () => {
|
||||
const refusing = createKartaViewSource({
|
||||
fetchImpl: async () =>
|
||||
ok({
|
||||
@@ -100,7 +105,10 @@ test('an API refusal inside a 200 is an error with KartaView’s message; 601 is
|
||||
result: {},
|
||||
}),
|
||||
});
|
||||
await assert.rejects(refusing.getPhoto('1'), /out of range/);
|
||||
await assert.rejects(
|
||||
refusing.getPhoto('1'),
|
||||
/KartaView refused the request \(code 612\)/,
|
||||
);
|
||||
const empty = createKartaViewSource({
|
||||
fetchImpl: async () =>
|
||||
ok({ status: { apiCode: 601 }, result: { data: [] } }),
|
||||
@@ -190,3 +198,92 @@ test('the limiter runs tasks in order and keeps going after a failure', async ()
|
||||
await new Promise((resolve) => setTimeout(resolve, 0));
|
||||
assert.equal(limiter.pending, 0);
|
||||
});
|
||||
|
||||
test('tiles, lookups and sequence pages queue separately, so a lookup never waits behind them', async () => {
|
||||
const running = { tile: 0, photo: 0, page: 0 };
|
||||
const peak = { tile: 0, photo: 0, page: 0 };
|
||||
const release = [];
|
||||
const kind = (url) =>
|
||||
url.includes('/tiles/')
|
||||
? 'tile'
|
||||
: url.includes('/photos')
|
||||
? 'page'
|
||||
: 'photo';
|
||||
const source = createKartaViewSource({
|
||||
fetchImpl: async (url) => {
|
||||
const k = kind(url);
|
||||
running[k]++;
|
||||
peak[k] = Math.max(peak[k], running[k]);
|
||||
if (k !== 'photo') await new Promise((resolve) => release.push(resolve));
|
||||
running[k]--;
|
||||
return k === 'tile' ? ok({ lines: [] }) : ok(photoPayload([]));
|
||||
},
|
||||
});
|
||||
const tiles = Array.from({ length: 9 }, (_, i) =>
|
||||
source.getTile({ x: i, y: 0, z: 14 }),
|
||||
);
|
||||
const pages = [1, 2].map((page) =>
|
||||
source.getSequencePhotos('1', { page, itemsPerPage: 500 }),
|
||||
);
|
||||
// Every slow tile and page is in flight or queued; a lookup still answers.
|
||||
assert.deepEqual(await source.nearestPhotos({ lat: 1, lon: 1 }), []);
|
||||
assert.equal(peak.tile, TILE_CONCURRENCY);
|
||||
assert.equal(peak.page, 1);
|
||||
while (release.length) {
|
||||
release.shift()();
|
||||
await new Promise((resolve) => setTimeout(resolve, 0));
|
||||
}
|
||||
await Promise.all([...tiles, ...pages]);
|
||||
assert.equal(peak.tile, TILE_CONCURRENCY);
|
||||
assert.equal(peak.page, 1);
|
||||
});
|
||||
|
||||
test('a lookup that times out is asked once more; a second timeout says to try again', async () => {
|
||||
let calls = 0;
|
||||
const source = createKartaViewSource({
|
||||
fetchImpl: async () => {
|
||||
calls++;
|
||||
throw new TypeError('Failed to fetch');
|
||||
},
|
||||
});
|
||||
await assert.rejects(
|
||||
source.getPhoto('1'),
|
||||
/did not answer in time — try again/,
|
||||
);
|
||||
assert.equal(calls, 2);
|
||||
});
|
||||
|
||||
test('an image probe reads only the status: an archived photo (409) is not showable', async () => {
|
||||
const seen = [];
|
||||
const source = createKartaViewSource({
|
||||
fetchImpl: async (url, { signal }) => {
|
||||
seen.push(signal);
|
||||
return {
|
||||
ok: !url.includes('archived'),
|
||||
status: url.includes('archived') ? 409 : 200,
|
||||
};
|
||||
},
|
||||
});
|
||||
assert.equal(
|
||||
await source.probeImage('https://storage13.openstreetcam.org/ok.jpg'),
|
||||
true,
|
||||
);
|
||||
assert.equal(
|
||||
await source.probeImage('https://storage13.openstreetcam.org/archived.jpg'),
|
||||
false,
|
||||
);
|
||||
assert.equal(await source.probeImage(null), false);
|
||||
assert.ok(
|
||||
seen.every((signal) => signal.aborted),
|
||||
'the body is dropped',
|
||||
);
|
||||
const offline = createKartaViewSource({
|
||||
fetchImpl: async () => {
|
||||
throw new TypeError('Failed to fetch');
|
||||
},
|
||||
});
|
||||
assert.equal(
|
||||
await offline.probeImage('https://x.openstreetcam.org/a.jpg'),
|
||||
false,
|
||||
);
|
||||
});
|
||||
Reference in new issue
Block a user