mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-17 16:52:20 +00:00
test(street-level): harden KartaView tests (mutation score 51% → 95%)
A mutation review (91, then 130 mutants) found tests that could not fail
(quick presses with synchronous fakes, a no-flight check with a provider
that never posed), and untested paths. New and rewritten tests kill 123 of
130 mutants; the 7 survivors are equivalent or harmless redraws.
- viewer: held-back loads for quick presses, stale sharp/flat loads,
close mid-load, ends checks for an older photo, WebGL retried per mount,
focus handed back, look direction kept on ›.
- provider: id-ordered pages with out-of-order indexes, page and probe
failures retried, overtaken lookups, cones re-centred on ‹ ›, leftover
imagery filters hide no line or cone, coverage hints, tile cache.
- source: 429 backoff and Retry-After under mock timers, hang timeouts,
the nearest query's parameters. policy: storage-host injection, FOV 360,
longitudes past ±180. panorama: a stub WebGL context (angles, lost
context, re-measuring). lineCoverage.test.mjs: tooHigh hint, passes().
- core: openImage({frame:false}) and openNearest leave the camera
(with a posing provider and a default-open control), KartaView's legend
and wording end to end; viewerHost supportsRenderModes.
- Fixed tick-count waits replaced by an until() poll.
- Browser gate fixture: odd photos archived (409 at storage2, served by
the proxy), the first lookup rate-limited (429, Retry-After: 0); the
line-click step asserts the camera stays and › skips the archived photo.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
bd0bbf5134
commit
3d4c6de21a
14 files changed
+1374
-81
No files matched your search
@@ -72,13 +72,17 @@ test('photo files come from the storage host the record names, not the one its U
|
||||
for (const fileurlLTh of [
|
||||
'https://tracker.example/x.jpg',
|
||||
'http://storage1.openstreetcam.org/a.jpg',
|
||||
'https://storage1.openstreetcam.org.evil.example/a.jpg',
|
||||
'javascript:alert(1)',
|
||||
]) {
|
||||
const hostile = normalizePhoto(
|
||||
record({ storage: '', filepathLTh: '', fileurlLTh, fileurl: fileurlLTh }),
|
||||
);
|
||||
assert.notEqual(hostile.urls.view, fileurlLTh);
|
||||
assert.doesNotMatch(String(hostile.urls.view), /tracker|javascript|^http:/);
|
||||
assert.doesNotMatch(
|
||||
String(hostile.urls.view),
|
||||
/tracker|javascript|evil|^http:/,
|
||||
);
|
||||
}
|
||||
// An unexpected storage value falls back to the URLs as given.
|
||||
const odd = normalizePhoto(record({ storage: 'https://evil.example' }));
|
||||
@@ -171,3 +175,65 @@ test('resized images go through the proxy with a base64url address', () => {
|
||||
);
|
||||
assert.equal(resizedImageUrl(null, [1, 1]), null);
|
||||
});
|
||||
|
||||
test('a storage value that only contains a storage host name builds no address from it', () => {
|
||||
for (const storage of ['evil.example/#storage1', 'storage1.evil.example']) {
|
||||
const photo = normalizePhoto(record({ storage }));
|
||||
// Not a storage host: the API's own storage URLs serve.
|
||||
assert.equal(
|
||||
photo.urls.view,
|
||||
'https://storage1.openstreetcam.org/files/photo/2016/8/24/lth/14010_ba53c_57bd1d23d50b7.jpg',
|
||||
storage,
|
||||
);
|
||||
assert.equal(
|
||||
photo.urls.full,
|
||||
'https://storage1.openstreetcam.org/files/photo/2016/8/24/proc/14010_ba53c_57bd1d23d50b7.jpg',
|
||||
storage,
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
test('a 360° field of view makes a panorama whatever the projection says', () => {
|
||||
assert.equal(
|
||||
normalizePhoto(record({ projection: 'PLANE', fieldOfView: '360' })).isPano,
|
||||
true,
|
||||
);
|
||||
assert.equal(
|
||||
normalizePhoto(record({ projection: 'PLANE', fieldOfView: '359' })).isPano,
|
||||
false,
|
||||
);
|
||||
});
|
||||
|
||||
test('a longitude past ±180 is not a position', () => {
|
||||
assert.equal(normalizePhoto(record({ lng: '181', matchLng: '181' })), null);
|
||||
assert.equal(normalizePhoto(record({ lng: '-181', matchLng: '-181' })), null);
|
||||
assert.equal(
|
||||
normalizePhoto(record({ lng: '180', matchLng: '180' })).lon,
|
||||
180,
|
||||
);
|
||||
});
|
||||
|
||||
test('with no processed-photo path the size prefix gives the full photo', () => {
|
||||
const photo = normalizePhoto(
|
||||
record({ filepathProc: '', fileurlProc: '', storage: 'storage3' }),
|
||||
);
|
||||
assert.equal(
|
||||
photo.urls.full,
|
||||
'https://storage3.openstreetcam.org/files/photo/2016/8/24/proc/14010_ba53c_57bd1d23d50b7.jpg',
|
||||
);
|
||||
// Only the large thumbnail, no path at all: the thumbnail still shows.
|
||||
const thumbOnly = normalizePhoto(
|
||||
record({
|
||||
filepathProc: '',
|
||||
fileurlProc: '',
|
||||
filepath: '',
|
||||
fileurl: '',
|
||||
storage: 'storage3',
|
||||
}),
|
||||
);
|
||||
assert.equal(thumbOnly.urls.full, null);
|
||||
assert.match(
|
||||
thumbOnly.urls.view,
|
||||
/^https:\/\/storage3\.openstreetcam\.org\/.*\/lth\//,
|
||||
);
|
||||
});
|
||||
Reference in new issue
Block a user