fix(street-level): review follow-ups — shares judged against the last draw; refused pictures stay refused

From the maintainer review of #1134 (approve with follow-ups):
- lineCoverage: a share is judged against the cap the tile was last drawn
  with, not against later shares that redrew nothing, so small increases
  add up (a retained tile stayed at 100 points after its share grew to
  116). A rebuild's measuring pass no longer counts as a draw.
- photoViewer: a picture refused for its size (bytes, streamed bytes or
  decoded side) is marked `tooLarge`, and the viewer never loads that file
  again by any path; the flat fallback had retried an oversized SD file
  through an <img>, which has no size limit.
- Regressions for both: cumulative share growth below the threshold, and a
  refused SD panorama that is not fetched again as a flat photo.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
Said TurkseverandClaude Opus 5.5 committed 2026-10-15 16:08:18 +01:00
1 parent de83e1c17f
commit e3bc431f9a
5 files changed
+129 -16

No files matched your search

@@ -295,3 +295,39 @@ test('a photo with no author to name is captioned with the instance holding it',
const named = { ...photo, creator: 'Robot8A' };
assert.equal(PANORAMAX_SOURCES.describe(named).title, null);
});
test('an SD panorama refused for its size is not fetched again as a flat photo', async () => {
const loads = [];
const viewer = createPanoramaxViewer({
getPhoto: async () => PHOTOS.pano,
step: async () => null,
onStep() {},
load: async (url, options = {}) => {
loads.push({ url, crossOrigin: options.crossOrigin });
// The picture host's SD file is past the viewer's size limits.
if (url === PHOTOS.pano.urls.sd)
throw Object.assign(new Error('too big'), { tooLarge: true });
return { src: url };
},
createRenderer: () => ({
setImage() {},
setView() {},
getView: () => ({ yaw: 0, pitch: 0, fov: 80 }),
resize() {},
clear() {},
destroy() {},
}),
});
const host = fakeHost();
await viewer.mount(host);
await viewer.open('pano');
const sdLoads = loads.filter((l) => l.url === PHOTOS.pano.urls.sd);
assert.equal(sdLoads.length, 1, 'tried once, as a bitmap, and refused');
assert.equal(sdLoads[0].crossOrigin, true);
const { picture } = parts(host);
assert.equal(picture.hidden, false, 'the flat fallback shows');
assert.notEqual(picture.src, PHOTOS.pano.urls.sd);
// Opened again later: the refused file is still not asked for.
await viewer.open('pano');
assert.equal(loads.filter((l) => l.url === PHOTOS.pano.urls.sd).length, 1);
});