simplify application and remove window references
Sonarqube Scanner / Build and analyze (push) Failing after 1m27s

This commit is contained in:
Florian Zumpe
2026-06-17 16:08:01 +02:00
parent 6a4d84ac6a
commit 32f161483d
20 changed files with 560 additions and 282 deletions
+17 -7
View File
@@ -68,15 +68,23 @@ test('mobile navigation footer contains a rotating SVG arrow and exact metre out
test('client bearing calculation points north and east correctly', async () => {
const source = await read('public/js/distance.js');
const context = { window: { Wegwichtel: {} } };
const context = { Wegwichtel: {} };
vm.runInNewContext(source, context);
const distance = context.window.Wegwichtel.Distance;
const distance = context.Wegwichtel.Distance;
assert.ok(Math.abs(distance.bearing({ lat: 0, lon: 0 }, { lat: 1, lon: 0 })) < 0.001);
assert.ok(Math.abs(distance.bearing({ lat: 0, lon: 0 }, { lat: 0, lon: 1 }) - 90) < 0.001);
});
test('authored browser modules use the portable global object', async () => {
const scripts = (await clientSources()).join('\n');
assert.match(scripts, /globalThis\.Wegwichtel/);
assert.doesNotMatch(scripts, /\bwindow\./);
});
test('route controls use accessible icon buttons with start, pause and stop states', async () => {
const html = await read('public/index.html');
const app = await read('public/js/app.js');
@@ -88,13 +96,15 @@ test('route controls use accessible icon buttons with start, pause and stop stat
assert.match(html, /aria-label="Route starten"/);
assert.match(html, /aria-label="Route pausieren"/);
assert.match(html, /aria-label="Route beenden"/);
assert.match(html, /<fieldset>[\s\S]*<legend>Routensteuerung<\/legend>/);
assert.doesNotMatch(html, /role="group"/);
assert.doesNotMatch(html, /aria-type=/);
assert.match(app, /routeState:\s*'idle'/);
assert.match(app, /state\.routeState = 'paused'/);
assert.match(app, /state\.routeState = 'running'/);
assert.match(app, /function endRoute/);
assert.match(geo, /navigator\.geolocation\.watchPosition/);
assert.match(geo, /navigator\.geolocation\.clearWatch/);
assert.match(geo, /watchPosition/);
assert.match(geo, /clearWatch/);
});
test('route control SVG files are present', async () => {
@@ -171,9 +181,9 @@ test('POI page uses icon-based back and slideshow controls in a single responsiv
assert.match(html, /class="back-button"[\s\S]*images\/icons\/back\.svg/);
assert.match(html, /id="slide-prev"[\s\S]*images\/icons\/chevron-left\.svg/);
assert.match(html, /id="slide-next"[\s\S]*images\/icons\/chevron-right\.svg/);
assert.match(html, /class="slide-meta"/);
assert.match(css, /#slide-controls[\s\S]*grid-template-columns:\s*var\(--icon-button-size\) minmax\(0, 1fr\) var\(--icon-button-size\)/);
assert.match(css, /\.slide-meta[\s\S]*justify-content:\s*center/);
assert.match(html, /<fieldset>[\s\S]*<legend>Bildnavigation<\/legend>/);
assert.match(css, /#slideshow > fieldset[\s\S]*grid-template-columns:\s*var\(--icon-button-size\) minmax\(0, 1fr\) var\(--icon-button-size\)/);
assert.match(css, /#slideshow > fieldset > div[\s\S]*justify-content:\s*center/);
assert.match(css, /#slide-caption[\s\S]*overflow-wrap:\s*anywhere/);
assert.doesNotMatch(loader, /controlgroup/);
});