Multiple improvements
Sonarqube Scanner / Prepare environment (push) Successful in 10s
Sonarqube Scanner / Build and test (push) Successful in 28s
Sonarqube Scanner / SonarQube analysis (push) Successful in 1m8s
Sonarqube Scanner / Deploy to Server (push) Successful in 8s

This commit is contained in:
2026-10-05 01:18:14 +02:00
parent 2b07e9bc47
commit 49a9de0355
27 changed files with 797 additions and 80 deletions
+32
View File
@@ -730,3 +730,35 @@ test('creator identity never falls back to insecure randomness or replaces corru
assert.throws(() => api.creatorId(), /Gerätekennung/);
assert.equal(localStorage.getItem('wegwichtel.creator-id.v1'), 'broken');
});
test('route selection reads metadata only and station media is loaded and released separately', async () => {
const { api, context } = await loadLocalRoutes();
const reads = [0, 0];
const revoked = [];
let urlNumber = 0;
context.URL.createObjectURL = () => `blob:lazy-${++urlNumber}`;
context.URL.revokeObjectURL = url => revoked.push(url);
const files = [];
for (let id = 0; id < 2; id++) {
const file = Object.assign(new Blob(['image']), { name: `${id}.jpg` });
const handle = { async getFile() { reads[id]++; return file; } };
files.push(await api.storeMediaFile('lazy', id, 'image', id, file, handle));
}
api.save({ id: 'lazy', route: { name: 'Lazy' }, pois: files.map((image, id) => ({ id, images: [image] })) });
await api.getAppRoute('lazy');
api.get('lazy');
assert.deepEqual(reads, [0, 0]);
const first = await api.getPoiWithMedia('lazy', 0, { requestPermission: true });
assert.deepEqual(reads, [1, 0]);
assert.equal(first.images[0].url, 'blob:lazy-1');
const second = await api.getAppPoi('lazy', 1);
assert.deepEqual(reads, [1, 1]);
assert.equal(second.images[0].url, 'blob:lazy-2');
api.releasePoiMedia(first); api.releasePoiMedia(first); api.releasePoiMedia(second);
api.releasePoiMedia({ images: [{ url: 'https://example.org/image.jpg' }] });
assert.deepEqual(revoked, ['blob:lazy-1', 'blob:lazy-2']);
assert.equal(await api.getPoiWithMedia('lazy', 9), null);
assert.equal(await api.getAppPoi('missing', 0), null);
assert.equal(api.get('lazy').pois[0].images[0].url, undefined);
});