Internationalization
Sonarqube Scanner / Prepare environment (push) Successful in 20s
Sonarqube Scanner / Build and test (push) Failing after 36s
Sonarqube Scanner / SonarQube analysis (push) Skipped
Sonarqube Scanner / Deploy to Server (push) Successful in 9s

This commit is contained in:
Florian Zumpe
2026-10-01 09:41:01 +02:00
parent 607e5450e1
commit aff88eba1b
41 changed files with 1368 additions and 636 deletions
+24 -19
View File
@@ -1,3 +1,4 @@
import { loadI18n } from '../test-support/i18n.js';
import assert from 'node:assert/strict';
import fs from 'node:fs/promises';
import path from 'node:path';
@@ -299,6 +300,10 @@ async function loadApp() {
context.addEventListener = (name, handler) => harness.globalListeners.set(name, handler);
context.globalThis = context;
await loadI18n(context);
vm.runInNewContext(await fs.readFile(path.join(root, 'public/js/user-messages.js'), 'utf8'), context, { filename: path.join(root, 'public/js/user-messages.js') });
await loadI18n(context);
vm.runInNewContext(source, context, { filename: sourcePath });
return {
@@ -322,9 +327,9 @@ test('route control runtime loads server/local routes and supports switching wit
assert.deepEqual(apiCalls.slice(0, 2), ['health', 'routes']);
assert.deepEqual(setup.steps, [['server', 'done'], ['routes', 'done'], ['location', 'done']]);
assert.match(harness.node('#location-hint').textValue, /Standort nicht verfügbar/);
assert.match(harness.node('#route-control-server-title').textValue, /Aktive Strecken \(1\)/);
assert.match(harness.node('#route-control-local-title').textValue, /Lokale Strecken \(1\)/);
assert.match(harness.node('#location-hint').textValue, /Standort konnte nicht gefunden werden/);
assert.match(harness.node('#route-control-server-title').textValue, /Strecken für alle \(1\)/);
assert.match(harness.node('#route-control-local-title').textValue, /Meine Entwürfe \(1\)/);
assert.ok(harness.node('#all-route-list').appended.join('').includes('Serverweg'));
assert.ok(harness.node('#local-route-list').appended.join('').includes('Lokaler Weg'));
@@ -344,7 +349,7 @@ test('route control runtime loads server/local routes and supports switching wit
await harness.activate('[data-route-select]', localButton);
assert.equal(harness.node('#route-control-title').textValue, 'Lokaler Weg');
assert.match(harness.node('#route-control-next').textValue, /Nächster Streckenpunkt: Lokaler Weg Start/);
assert.match(harness.node('#route-control-next').textValue, /Nächste Station: Lokaler Weg Start/);
assert.equal(harness.node('#route-page').attributes.has('hidden'), false);
const serverButton = new FakeNode('server-select');
@@ -354,7 +359,7 @@ test('route control runtime loads server/local routes and supports switching wit
assert.ok(apiCalls.includes('route:server-1'));
assert.equal(harness.node('#route-control-title').textValue, 'Serverweg');
assert.match(harness.node('#route-control-next').textValue, /Nächster Streckenpunkt: Serverweg Start/);
assert.match(harness.node('#route-control-next').textValue, /Nächste Station: Serverweg Start/);
});
test('local-route change refreshes an active draft and handles its later removal', async () => {
@@ -383,7 +388,7 @@ test('local-route change refreshes an active draft and handles its later removal
harness.document.dispatchEvent(removeEvent);
await tick();
assert.equal(harness.node('#route-control-title').textValue, 'Route wählen');
assert.equal(harness.node('#route-control-title').textValue, 'Strecke wählen');
assert.equal(harness.node('#routes-page').attributes.has('hidden'), false);
assert.equal(editor.refreshed, 2);
});
@@ -400,7 +405,7 @@ test('route control closes on escape and reports local storage failures', async
context.Wegwichtel.LocalRoutes.listAppRoutes = () => { throw new Error('LocalStorage nicht lesbar'); };
harness.globalListeners.get('pageshow')?.({});
assert.ok(harness.node('#route-control-local-list').appended.join('').includes('LocalStorage nicht lesbar'));
assert.ok(harness.node('#route-control-local-list').appended.join('').includes('Deine Entwürfe konnten nicht geöffnet werden'));
});
async function selectServer(setup) {
@@ -442,18 +447,18 @@ test('tracking triggers each POI once, records media progress and pauses/resumes
calls.heading(10);
assert.match(harness.node('#navigation-arrow').styles.get('transform'), /rotate\(50\.0deg\)/);
calls.error(new Error('Signal verloren'));
assert.equal(harness.node('#tracking-status').textValue, 'GPS-Fehler: Signal verloren');
assert.equal(harness.node('#tracking-status').textValue, 'Dein Standort konnte nicht gefunden werden. Prüfe die Standort-Erlaubnis auf deinem Gerät.');
await harness.activate('#pause-route', new FakeNode('pause'));
assert.match(harness.node('#tracking-status').textValue, /pausiert/);
assert.match(harness.node('#tracking-status').textValue, /Du machst eine Pause/);
assert.equal(savedStates.at(-1)[1], 'paused');
await harness.activate('#start-route', new FakeNode('resume'));
calls.position({ lat: 50.001, lon: 10.001, accuracy: 5 });
assert.equal(calls.vibrations, 2);
assert.equal(harness.node('#route-control-next').textValue, 'Alle Streckenpunkte erreicht');
assert.equal(harness.node('#route-control-next').textValue, 'Alle Stationen erreicht');
assert.equal(harness.node('#navigation-distance').textValue, '0 m');
await harness.activate('#stop-route', new FakeNode('stop'));
assert.equal(savedStates.at(-1)[1], 'idle');
assert.equal(harness.node('#route-control-title').textValue, 'Route wählen');
assert.equal(harness.node('#route-control-title').textValue, 'Strecke wählen');
assert.equal(harness.node('#navigation-footer').properties.get('hidden'), true);
assert.ok(calls.stopped >= 4);
});
@@ -468,8 +473,8 @@ test('saved route resumes paused, manual POI viewing and lifecycle events persis
const calls = observeSensors(setup);
await context.Wegwichtel.App.initialize({ markStep() {} });
await selectServer(setup);
assert.match(harness.node('#tracking-status').textValue, /Gespeicherter/);
assert.equal(harness.node('#start-route').attributes.get('title'), 'Route fortsetzen');
assert.match(harness.node('#tracking-status').textValue, /weitermachen/);
assert.equal(harness.node('#start-route').attributes.get('title'), 'Strecke fortsetzen');
const poi = new FakeNode('poi');
poi.dataValues.set('poi-id', 2);
await harness.key('[data-poi-select]', poi, ' ');
@@ -501,16 +506,16 @@ test('tracking handles an empty route and orientation permission resolving after
context.Wegwichtel.Orientation.start = () => new Promise(resolve => { grant = resolve; });
await context.Wegwichtel.App.initialize({ markStep() {} });
await selectServer(setup);
assert.match(harness.node('#poi-list').appended.join(''), /keine Streckenpunkte/);
assert.match(harness.node('#poi-list').appended.join(''), /keine Stationen/);
await harness.activate('#start-route', new FakeNode('start'));
calls.position({ lat: 50, lon: 10, accuracy: 10 });
assert.equal(harness.node('#navigation-mode').textValue, 'Keine Navigationspunkte vorhanden');
assert.equal(harness.node('#navigation-mode').textValue, 'Der Weg dieser Strecke fehlt.');
await harness.activate('#pause-route', new FakeNode('pause'));
const stopped = calls.stopped;
grant(true);
await tick();
assert.equal(calls.stopped, stopped + 1);
assert.equal(harness.node('#navigation-mode').textValue, 'Route pausiert');
assert.equal(harness.node('#navigation-mode').textValue, 'Strecke pausiert');
await harness.activate('#stop-route', new FakeNode('stop'));
});
@@ -522,7 +527,7 @@ test('route recommendations and accent-insensitive search use location without c
far.start = { lat: 51, lon: 10 };
context.Wegwichtel.Api.routes = async () => ({ routes: [far, setup.serverRoute, null, {}] });
await context.Wegwichtel.App.initialize({ markStep() {} });
assert.match(harness.node('#location-hint').textValue, /Standort ermittelt/);
assert.match(harness.node('#location-hint').textValue, /Standort wurde/);
assert.match(harness.node('#nearby-route-list').appended.join(''), /Serverweg/);
assert.doesNotMatch(harness.node('#nearby-route-list').appended.join(''), /Äpfelweg/);
const position = context.Wegwichtel.App.currentPosition();
@@ -537,7 +542,7 @@ test('route recommendations and accent-insensitive search use location without c
autocomplete.select({}, { item: { value: 'Serverweg' } });
assert.match(harness.node('#all-route-list').appended.join(''), /Serverweg/);
harness.$('#route-search').val('unbekannt').trigger('input');
assert.match(harness.node('#all-route-list').appended.join(''), /Keine Route entspricht/);
assert.match(harness.node('#all-route-list').appended.join(''), /Keine passende Strecke gefunden/);
await harness.activate('#clear-route-search', new FakeNode('clear'));
assert.equal(harness.node('#route-search').value, '');
});
@@ -546,7 +551,7 @@ test('invalid API responses reject initialization and route selection errors res
const setup = await loadApp();
const { context, harness } = setup;
context.Wegwichtel.Api.routes = async () => ({ routes: null });
await assert.rejects(context.Wegwichtel.App.initialize({ markStep() {} }), /gültige Routenliste/);
await assert.rejects(context.Wegwichtel.App.initialize({ markStep() {} }), /Strecken konnten nicht geladen werden/);
const errors = [];
context.alert = message => errors.push(message);
context.Wegwichtel.Api.route = async () => { throw { responseJSON: { message: 'Strecke entfernt' } }; };