simplify application and remove window references
Sonarqube Scanner / Build and analyze (push) Failing after 1m27s
Sonarqube Scanner / Build and analyze (push) Failing after 1m27s
This commit is contained in:
@@ -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/);
|
||||
});
|
||||
|
||||
@@ -14,11 +14,11 @@ test('legacy vibration patterns are exposed as immutable constants', async () =>
|
||||
const calls = [];
|
||||
const context = {
|
||||
navigator: { vibrate: pattern => { calls.push(pattern); return true; } },
|
||||
window: { Wegwichtel: {} }
|
||||
Wegwichtel: {}
|
||||
};
|
||||
|
||||
vm.runInNewContext(await source(), context);
|
||||
const vibration = context.window.Wegwichtel.Vibration;
|
||||
const vibration = context.Wegwichtel.Vibration;
|
||||
|
||||
assert.equal(vibration.Patterns.MICRO, 50);
|
||||
assert.equal(vibration.Patterns.MINI, 100);
|
||||
@@ -34,26 +34,28 @@ test('vibration wrapper starts named patterns and can cancel them', async () =>
|
||||
const calls = [];
|
||||
const context = {
|
||||
navigator: { vibrate: pattern => { calls.push(pattern); return true; } },
|
||||
window: { Wegwichtel: {} }
|
||||
Wegwichtel: {}
|
||||
};
|
||||
|
||||
vm.runInNewContext(await source(), context);
|
||||
const vibration = context.window.Wegwichtel.Vibration;
|
||||
const vibration = context.Wegwichtel.Vibration;
|
||||
|
||||
assert.equal(vibration.start(vibration.Patterns.ACTIVE_POI), true);
|
||||
assert.equal(vibration.start(vibration.Patterns.SHORT), true);
|
||||
assert.equal(vibration.stop(), true);
|
||||
assert.deepEqual(Array.from(calls[0]), [500, 300, 500]);
|
||||
assert.equal(calls[1], 0);
|
||||
assert.deepEqual(Array.from(calls[1]), [200]);
|
||||
assert.equal(calls[2], 0);
|
||||
});
|
||||
|
||||
test('vibration wrapper fails harmlessly when the browser API is unavailable', async () => {
|
||||
const context = {
|
||||
navigator: {},
|
||||
window: { Wegwichtel: {} }
|
||||
Wegwichtel: {}
|
||||
};
|
||||
|
||||
vm.runInNewContext(await source(), context);
|
||||
const vibration = context.window.Wegwichtel.Vibration;
|
||||
const vibration = context.Wegwichtel.Vibration;
|
||||
|
||||
assert.equal(vibration.isSupported(), false);
|
||||
assert.equal(vibration.start(vibration.Patterns.SHORT), false);
|
||||
|
||||
Reference in New Issue
Block a user