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:
Said TurkseverandClaude Opus 5.5 committed 2026-10-13 19:32:18 +01:00
1 parent 310984ff0b
commit 454e261256
16 files changed
+683 -179

No files matched your search

@@ -24,11 +24,19 @@ function photoRecord(id, { metres = 0, seq = '14010', index = 0 } = {}) {
};
}
/** A source over `sequences` (id → indexes present), recording calls. */
function fakeSource({ nearest = [], sequences = {} } = {}) {
const calls = { nearest: 0, photo: [], pages: [] };
/**
* A source over `sequences` (id → indexes present, in page order: KartaView
* pages follow photo ids, which only roughly follow the index), recording
* calls. Photos whose id is in `archived` answer 409.
*/
function fakeSource({ nearest = [], sequences = {}, archived = [] } = {}) {
const calls = { nearest: 0, photo: [], pages: [], probes: [] };
return {
calls,
probeImage: async (url) => {
calls.probes.push(url);
return !archived.some((id) => url.includes(`/${id}.jpg`));
},
getTile: async () => ({ lines: [] }),
nearestPhotos: async () => {
calls.nearest++;
@@ -59,7 +67,7 @@ function fakeSource({ nearest = [], sequences = {} } = {}) {
}
function fakeContext() {
const actions = { opened: [], nearest: [] };
const actions = { opened: [], nearest: [], instance: null };
return {
actions,
context: {
@@ -71,7 +79,12 @@ function fakeContext() {
getSurface: () => 'draped',
notify() {},
actions: {
openImage: (id) => actions.opened.push(id),
// As the core does: the provider's own viewer opens it.
openImage: async (id, options) => {
actions.opened.push({ id, options });
await actions.instance?.viewer.open(id);
return true;
},
openNearest: (point) => actions.nearest.push(point),
reportError() {},
},
@@ -96,6 +109,7 @@ function setup(sourceOptions) {
});
const { context, actions } = fakeContext();
const instance = definition.create(context);
actions.instance = instance;
return { definition, instance, source, actions, loads };
}
@@ -159,8 +173,9 @@ test('the nearest photo is the closest within 50 m, and opening it asks nothing
test('a cone opens its photo; a line opens the photo nearest the click', () => {
const { instance, actions } = setup();
actions.instance = null;
assert.equal(instance.handlePick('kv:img:123'), true);
assert.deepEqual(actions.opened, ['123']);
assert.deepEqual(actions.opened, [{ id: '123', options: undefined }]);
const point = { lon: -83.0458, lat: 42.3314 };
assert.equal(
instance.handlePick('kv:line:14/1/2/3', { groundPoint: () => point }),
@@ -185,47 +200,124 @@ test('coverage stats report KartaView as configured and key-free', async () => {
assert.equal(stats.count, 0);
});
test('› walks across sequence pages; ‹ walks back; the ends stop', async () => {
const press = async (button) => {
button.fire('click');
for (let i = 0; i < 12; i++) await settle();
};
async function mounted(sourceOptions) {
const env = setup(sourceOptions);
const host = fakeHost();
await env.instance.viewer.mount(host);
const poses = [];
env.instance.viewer.onPose((pose) => poses.push(pose.imageId));
const [, , prev, next] = host.children[0].children;
return { ...env, poses, prev, next };
}
test('› walks across sequence pages without moving the camera; ‹ walks back; the ends stop', async () => {
const size = SEQUENCE_PAGE_SIZE;
const indexes = Array.from({ length: size + 5 }, (_, i) => i);
const { instance, source } = setup({ sequences: { s: indexes } });
const host = fakeHost();
await instance.viewer.mount(host);
const poses = [];
instance.viewer.onPose((pose) => poses.push(pose.imageId));
const [, , prev, next] = host.children[0].children;
const press = async (button) => {
button.fire('click');
for (let i = 0; i < 6; i++) await settle();
};
const { instance, actions, source, poses, prev, next } = await mounted({
sequences: { s: indexes },
});
await instance.viewer.open(`s-${size - 1}`);
await press(next);
assert.equal(poses.at(-1), `s-${size}`, 'onto the second page');
assert.deepEqual(source.calls.pages, ['s:1', 's:2']);
assert.deepEqual(actions.opened.at(-1), {
id: `s-${size}`,
options: { frame: false },
});
assert.ok(source.calls.pages.includes('s:2'));
await press(prev);
assert.equal(poses.at(-1), `s-${size - 1}`);
await instance.viewer.open('s-0');
for (let i = 0; i < 6; i++) await settle();
assert.equal(prev.disabled, true, 'nothing before the first photo');
await press(prev);
assert.equal(poses.at(-1), 's-0', 'nothing before the first photo');
assert.equal(prev.disabled, true);
assert.equal(poses.at(-1), 's-0');
});
test('a page with missing photos is found by stepping back a page', async () => {
test('pages that overlap in index (id order) step one photo at a time across the edge', async () => {
const size = SEQUENCE_PAGE_SIZE;
// Index `size + 100` sits on page 1 when 200 earlier photos are gone.
const indexes = Array.from({ length: size + 300 }, (_, i) => i).filter(
(i) => i < 100 || i >= 300,
// As KartaView pages by id: page 1 holds 0…size+2 less two, page 2 starts
// with those two (size-2, size) before the rest.
const first = Array.from({ length: size + 3 }, (_, i) => i).filter(
(i) => i !== size - 2 && i !== size,
);
const second = [
size - 2,
size,
...Array.from({ length: 50 }, (_, i) => size + 3 + i),
];
const { instance, poses, next } = await mounted({
sequences: { s: [...first, ...second] },
});
await instance.viewer.open(`s-${size - 5}`);
for (let k = 1; k <= 8; k++) await press(next);
assert.deepEqual(
poses.slice(-9).map((id) => Number(id.slice(2))),
Array.from({ length: 9 }, (_, i) => size - 5 + i),
'no photo skipped at the page edge',
);
});
test('a photo whose index outruns the page count is found, and its neighbours are real', async () => {
// 1,000 photos with 500–1499 deleted: index 1500 is on page 2, not 4.
const indexes = [
...Array.from({ length: 500 }, (_, i) => i),
...Array.from({ length: 500 }, (_, i) => 1500 + i),
];
const { instance, poses, prev, next } = await mounted({
sequences: { s: indexes },
});
await instance.viewer.open('s-1500');
await press(next);
assert.equal(poses.at(-1), 's-1501');
await press(prev);
await press(prev);
assert.equal(poses.at(-1), 's-499', 'back across the gap');
await instance.viewer.open('s-1999');
for (let i = 0; i < 8; i++) await settle();
assert.equal(next.disabled, true, 'the last photo');
});
test('archived photos are skipped: by the nearest lookup, and by › and ‹', async () => {
const { instance, poses, next } = await mounted({
nearest: [
photoRecord('gone', { metres: 3 }),
photoRecord('kept', { metres: 9 }),
],
archived: ['gone', 's-2', 's-3'],
sequences: { s: [0, 1, 2, 3, 4] },
});
assert.equal(
await instance.nearestImage({ lat: 42.3314, lon: -83.0458 }),
'kept',
);
await instance.viewer.open('s-1');
await press(next);
assert.equal(poses.at(-1), 's-4', 'two archived photos stepped over');
const allGone = setup({
nearest: [photoRecord('gone', { metres: 3 })],
archived: ['gone'],
});
await assert.rejects(
allGone.instance.nearestImage({ lat: 42.3314, lon: -83.0458 }),
/archived and cannot be shown/,
);
const noFiles = setup({
nearest: [
{
...photoRecord('bare', { metres: 2 }),
filepathLTh: '',
filepathProc: '',
},
],
});
assert.equal(
await noFiles.instance.nearestImage({ lat: 42.3314, lon: -83.0458 }),
null,
'a record with no file is not a photo',
);
const { instance, source } = setup({ sequences: { s: indexes } });
const host = fakeHost();
await instance.viewer.mount(host);
const poses = [];
instance.viewer.onPose((pose) => poses.push(pose.imageId));
const target = size + 100;
await instance.viewer.open(`s-${target}`);
const [, , , next] = host.children[0].children;
next.fire('click');
for (let i = 0; i < 8; i++) await settle();
assert.equal(poses.at(-1), `s-${target + 1}`);
assert.deepEqual(source.calls.pages.slice(0, 2), ['s:2', 's:1']);
});