Muttersprache koppeln und russischen A1-Kurs ergänzen

GUI und neue Erklärungen verwenden gemeinsam native_language. Deutsch und
Russisch sind die beiden Muttersprachen; Englisch bleibt die Lernsprache.
Kompatibilitätsfelder werden atomar gekoppelt, widersprüchliche Eingaben
abgewiesen und bestehende Profile sowie eingefrorene Inhalte erhalten.

Ergänzt vollständige russische GUI-Kataloge und 840 geprüfte Aufgabenansichten
in sieben Modulen einschließlich A1-Test, mit getrennten Sprachrollen für
Ausgangs- und Lernmaterial. Äquivalente Ansichten teilen ihre Nachweisidentität.
Stabile API-Fehlercodes, neue deterministische Hilfen und Trainingsbegründungen
berücksichtigen die Muttersprache. Dokumentiert das Sprachmodell in AGENTS.md.

Validierung: Go-Race-Suite mit eigener lokaler PostgreSQL-Testdatenbank, go vet,
Web-Build, Offline-Bank-/Variantenaudit, Diff-Prüfung sowie lokale Browser-Smokes
für Sprachen, Kurs, Administration, Aussprache und Aufnahme. Keine Live-Anbieter,
Produktionsprofile, Deployment-Schritte oder historischen Neubewertungen.
This commit is contained in:
Eugenius Naumenko
2026-11-07 17:02:17 +00:00
parent f3d42ee2b6
commit 16cceae28a
77 changed files with 46646 additions and 1969 deletions
+43 -137
View File
@@ -1,141 +1,47 @@
const { chromium } = require(process.env.PLAYWRIGHT_MODULE || 'playwright');
const assert = require('node:assert/strict');
const fs = require('node:fs');
(async () => {
const api = process.env.AI_E2E_API, token = process.env.AI_E2E_TOKEN, url = process.env.AI_E2E_URL;
assert(api && token && url);
const german = JSON.parse(fs.readFileSync('src/i18n/de-DE.json', 'utf8'));
const english = JSON.parse(fs.readFileSync('src/i18n/en-US.json', 'utf8'));
assert.deepEqual(Object.keys(german).sort(), Object.keys(english).sort());
for (const key of Object.keys(german)) {
assert(german[key] && english[key], `Empty translation: ${key}`);
assert.deepEqual(german[key].match(/\{\w+\}/g)?.sort() ?? [], english[key].match(/\{\w+\}/g)?.sort() ?? [], key);
}
const browser = await chromium.launch({ headless: true, args: ['--no-sandbox'] });
try {
const page = await browser.newPage();
page.setDefaultTimeout(15000);
const errors = [];
page.on('pageerror', (error) => errors.push(error.message));
const headers = { Authorization: `Bearer ${token}` };
const me = async () => {
const response = await page.request.get(api + '/me', { headers });
assert.equal(response.status(), 200);
return response.json();
};
const patch = async (data) => {
const response = await page.request.patch(api + '/me/preferences', { headers, data });
assert.equal(response.status(), 200, await response.text());
return response.json();
};
await page.goto(url);
await page.getByRole('heading', { name: 'Einloggen', exact: true }).waitFor();
await page.getByRole('combobox', { name: 'Oberflächensprache' }).selectOption('en-US');
await page.getByRole('heading', { name: 'Log in', exact: true }).waitFor();
assert.equal(await page.locator('html').getAttribute('lang'), 'en-US');
await page.reload();
await page.getByRole('heading', { name: 'Log in', exact: true }).waitFor();
await page.getByRole('button', { name: 'Create account', exact: true }).click();
await page.getByText('The English course currently uses German task instructions and explanations.').waitFor();
await page.setViewportSize({ width: 360, height: 780 });
assert(await page.evaluate(() => document.documentElement.scrollWidth <= window.innerWidth), 'Registration overflows on a narrow screen');
await page.setViewportSize({ width: 1280, height: 800 });
const email = `languages-${Date.now()}@example.test`, password = 'local-language-test-password';
await page.getByRole('textbox', { name: 'Email', exact: true }).fill(email);
await page.getByLabel('Password', { exact: true }).fill(password);
const registration = page.waitForResponse((r) => r.url().endsWith('/auth/register') && r.request().method() === 'POST');
await page.getByRole('button', { name: 'Register', exact: true }).click();
const registered = await (await registration).json();
assert.equal(registered.user.ui_language, 'en-US');
assert.equal(registered.user.instruction_language, 'de-DE');
await page.getByRole('button', { name: 'Today', exact: true }).waitFor();
await page.getByText('Preferred explanation language: German.', { exact: true }).waitFor();
await page.getByRole('heading', { name: 'A1 pronunciation practice', exact: true }).waitFor();
await page.getByRole('button', { name: 'Log out', exact: true }).click();
await page.getByRole('combobox', { name: 'Interface language' }).selectOption('de-DE');
await page.getByRole('textbox', { name: 'E-Mail', exact: true }).fill(email);
await page.getByLabel('Passwort', { exact: true }).fill(password);
await page.getByRole('button', { name: 'Einloggen', exact: true }).click();
await page.getByRole('button', { name: 'Today', exact: true }).waitFor();
await page.getByRole('button', { name: 'Progress', exact: true }).click();
await page.getByRole('heading', { name: 'Progress', exact: true }).waitFor();
await page.getByRole('heading', { name: 'Your pronunciation profile · en-US', exact: true }).waitFor();
await page.getByText('Your new pronunciation profile needs confirmed measurements.', { exact: false }).waitFor();
await page.getByRole('button', { name: 'Log out', exact: true }).click();
const original = await me();
await page.evaluate((value) => localStorage.setItem('speech_token', value), token);
await page.reload();
await page.getByRole('combobox', { name: 'Oberflächensprache' }).selectOption('en-US');
await page.getByRole('button', { name: 'Pronunciation', exact: true }).click();
await page.getByRole('button', { name: 'Record', exact: true }).waitFor();
const sentence = await page.locator('.target-text').innerText();
await page.getByRole('combobox', { name: 'Interface language' }).selectOption('de-DE');
await page.getByRole('button', { name: 'Aufnehmen', exact: true }).waitFor();
assert.equal(await page.locator('.target-text').innerText(), sentence);
await page.getByRole('combobox', { name: 'Oberflächensprache' }).selectOption('en-US');
await page.getByRole('button', { name: 'Conversation', exact: true }).click();
await page.getByRole('button', { name: 'Start', exact: true }).click();
const reply = page.getByRole('textbox', { name: 'Your conversation reply', exact: true });
await reply.fill('My name is Mira.');
await page.getByRole('combobox', { name: 'Interface language' }).selectOption('de-DE');
assert.equal(await page.getByRole('textbox', { name: 'Deine Dialogantwort', exact: true }).inputValue(), 'My name is Mira.');
await page.getByRole('combobox', { name: 'Oberflächensprache' }).selectOption('en-US');
const turnResponse = page.waitForResponse(r => /\/conversation\/[^/]+\/turn$/.test(r.url()));
await page.getByRole('button', { name: 'Send', exact: true }).click();
assert.equal((await turnResponse).request().postDataJSON().text, 'My name is Mira.');
await page.locator('.bubble.learner').getByText('My name is Mira.', { exact: true }).waitFor();
await page.getByRole('button', { name: 'Administration', exact: true }).click();
await page.getByRole('heading', { name: 'AI settings and usage', exact: true }).waitFor();
const action = page.getByLabel('Action').first();
await action.selectOption('next_exercise');
await page.getByRole('option', { name: 'Pronunciation generation', exact: true }).first().waitFor({ state: 'attached' });
await page.getByLabel('Monthly limit in USD', { exact: true }).fill('0.12');
await page.getByRole('combobox', { name: 'Interface language' }).selectOption('de-DE');
assert.equal(await page.getByLabel('Monatslimit in USD', { exact: true }).inputValue(), '0.12');
await page.getByRole('combobox', { name: 'Oberflächensprache' }).selectOption('en-US');
assert.equal(await page.getByLabel('Monthly limit in USD', { exact: true }).inputValue(), '0.12');
const settings = await (await page.request.get(api + '/admin/ai/settings', { headers })).json();
assert.equal(settings.budget.monthly_limit_microusd, 0, 'Changing UI language must not save budget edits');
await page.getByLabel('Monthly limit in USD', { exact: true }).fill('0');
await page.getByRole('button', { name: 'Save budget', exact: true }).click();
await page.getByRole('status').filter({ hasText: 'Budget saved.' }).waitFor();
await page.getByRole('combobox', { name: 'Interface language' }).selectOption('de-DE');
await page.getByRole('status').filter({ hasText: 'Budget gespeichert.' }).waitFor();
await page.getByRole('combobox', { name: 'Oberflächensprache' }).selectOption('en-US');
await page.getByRole('status').filter({ hasText: 'Budget saved.' }).waitFor();
await page.getByRole('button', { name: 'A1 course', exact: true }).click();
await page.getByRole('button', { name: 'Open the original fixed course', exact: true }).click();
await page.getByText('Guided A1 course', { exact: true }).waitFor();
await page.getByRole('region', { name: 'Module progress', exact: true }).waitFor();
await patch({ ui_language: original.user.ui_language });
const learningProfile = await patch({ target_language: 'es-ES', cefr_level: 'A2', daily_goal_minutes: 23 });
await page.evaluate((value) => localStorage.setItem('speech_token', value), token);
await page.reload();
const picker = page.getByRole('combobox', { name: 'Oberflächensprache' });
await picker.waitFor();
await picker.selectOption('en-US');
await page.getByRole('button', { name: 'Today', exact: true }).waitFor();
let account = await me();
assert.equal(account.user.ui_language, 'en-US');
assert.equal(account.user.instruction_language, original.user.instruction_language);
assert.deepEqual(account.profile, learningProfile);
await page.reload();
await page.getByRole('combobox', { name: 'Interface language' }).waitFor();
assert.equal(await page.locator('html').getAttribute('lang'), 'en-US');
await page.route('**/me/preferences', (route) => route.fulfill({ status: 503, contentType: 'application/json', body: '{"error":"fixture unavailable"}' }));
await page.getByRole('combobox', { name: 'Interface language' }).selectOption('de-DE');
await page.getByRole('alert').filter({ hasText: 'Unable to save the language.' }).waitFor();
assert.equal(await page.getByRole('combobox', { name: 'Interface language' }).inputValue(), 'en-US');
account = await me();
assert.equal(account.user.ui_language, 'en-US');
assert.deepEqual(account.profile, learningProfile);
await page.unroute('**/me/preferences');
const rejected = await page.request.patch(api + '/me/preferences', { headers, data: { ui_language: 'xx-XX' } });
assert.equal(rejected.status(), 400);
await patch({ ui_language: original.user.ui_language, target_language: original.profile.target_language, cefr_level: original.profile.cefr_level, daily_goal_minutes: original.profile.daily_goal_minutes });
assert.deepEqual(errors, []);
console.log('PASS: catalog parity; language before login; registration/login; account persistence; independent instructions; pronunciation, conversation, admin and legacy controls; unsaved input survives language switches; partial PATCH preserves course/level/goal; rejected saves; no browser errors.');
} finally { await browser.close(); }
})().catch((error) => { console.error(error); process.exitCode = 1; });
const api=process.env.AI_E2E_API,token=process.env.AI_E2E_TOKEN,url=process.env.AI_E2E_URL;
const de=JSON.parse(fs.readFileSync('src/i18n/de-DE.json')),ru=JSON.parse(fs.readFileSync('src/i18n/ru-RU.json'));
assert.deepEqual(Object.keys(de).sort(),Object.keys(ru).sort());
for(const key of Object.keys(de)) {assert(ru[key]);assert.deepEqual(de[key].match(/\{\w+\}/g)?.sort()??[],ru[key].match(/\{\w+\}/g)?.sort()??[],key)}
const browser=await chromium.launch({headless:true,args:['--no-sandbox']});
try {
const page=await browser.newPage();page.setDefaultTimeout(15000);const errors=[];page.on('pageerror',e=>errors.push(e.message));
const headers={Authorization:`Bearer ${token}`};
const get=async()=>{const r=await page.request.get(api+'/me',{headers});assert.equal(r.status(),200);return r.json()};
const patch=async data=>{const r=await page.request.patch(api+'/me/preferences',{headers,data});assert.equal(r.status(),200,await r.text());return r.json()};
const coupled=(user,language)=>{assert.equal(user.native_language,language);assert.equal(user.ui_language,language);assert.equal(user.instruction_language,language)};
await page.goto(url);await page.getByRole('heading',{name:'Einloggen',exact:true}).waitFor();
const picker=()=>page.locator('.language-picker select');assert.deepEqual(await picker().locator('option').evaluateAll(items=>items.map(x=>x.value)),['de-DE','ru-RU']);
await picker().selectOption('ru-RU');await page.getByRole('heading',{name:ru['auth.login'],exact:true}).waitFor();await page.reload();assert.equal(await picker().inputValue(),'ru-RU');
await page.getByRole('button',{name:ru['auth.register'],exact:true}).click();
await page.setViewportSize({width:360,height:780});assert(await page.evaluate(()=>document.documentElement.scrollWidth<=innerWidth));await page.setViewportSize({width:1280,height:800});
const email=`native-${Date.now()}@example.test`,password='local-language-test-password';
await page.getByRole('textbox',{name:ru['auth.email'],exact:true}).fill(email);await page.getByLabel(ru['auth.password'],{exact:true}).fill(password);
const registration=page.waitForResponse(r=>r.url().endsWith('/auth/register')&&r.request().method()==='POST');await page.getByRole('button',{name:ru['auth.register.submit'],exact:true}).click();
const registered=await(await registration).json();coupled(registered.user,'ru-RU');assert.equal(registered.profile.target_language,'en-US');
await page.getByRole('button',{name:ru['nav.today'],exact:true}).waitFor();
await page.getByRole('button',{name:ru['auth.logout'],exact:true}).click();await picker().selectOption('de-DE');
await page.getByRole('textbox',{name:de['auth.email'],exact:true}).fill(email);await page.getByLabel(de['auth.password'],{exact:true}).fill(password);await page.getByRole('button',{name:de['auth.login'],exact:true}).click();await page.getByRole('button',{name:ru['nav.today'],exact:true}).waitFor();
await page.getByRole('button',{name:ru['auth.logout'],exact:true}).click();
const original=await get();const learning=await patch({native_language:'de-DE',target_language:'es-ES',cefr_level:'A2',daily_goal_minutes:23});
await page.evaluate(t=>localStorage.setItem('speech_token',t),token);await page.reload();await page.getByRole('button',{name:de['nav.today'],exact:true}).waitFor();
await picker().selectOption('ru-RU');await page.getByRole('button',{name:ru['nav.today'],exact:true}).waitFor();let account=await get();coupled(account.user,'ru-RU');assert.deepEqual(account.profile,learning);
await page.reload();await page.getByRole('button',{name:ru['nav.today'],exact:true}).waitFor();assert.equal(await page.locator('html').getAttribute('lang'),'ru-RU');
await page.route('**/me/preferences',route=>route.fulfill({status:503,contentType:'application/json',body:'{"error":"fixture unavailable","code":"service_unavailable"}'}));await picker().selectOption('de-DE');await page.getByRole('alert').filter({hasText:ru['language.saveError']}).waitFor();assert.equal(await picker().inputValue(),'ru-RU');account=await get();coupled(account.user,'ru-RU');assert.deepEqual(account.profile,learning);await page.unroute('**/me/preferences');
for(const data of [{native_language:'en-US'},{native_language:'de-DE',instruction_language:'ru-RU'}]){const r=await page.request.patch(api+'/me/preferences',{headers,data});assert.equal(r.status(),400);assert.match((await r.json()).code,/native_language_(unsupported|conflict)/)}
await patch({native_language:original.user.native_language,target_language:original.profile.target_language,cefr_level:original.profile.cefr_level,daily_goal_minutes:original.profile.daily_goal_minutes});
await page.reload();await page.getByRole('button',{name:de['nav.today'],exact:true}).waitFor();await picker().selectOption('ru-RU');
await page.getByRole('button',{name:ru['nav.practice'],exact:true}).click();await page.getByRole('button',{name:ru['ui.record'],exact:true}).waitFor();const sentence=await page.locator('.target-text').innerText();
await picker().selectOption('de-DE');await page.getByRole('button',{name:de['ui.record'],exact:true}).waitFor();assert.equal(await page.locator('.target-text').innerText(),sentence);await picker().selectOption('ru-RU');
await page.getByRole('button',{name:ru['nav.conversation'],exact:true}).click();await page.getByRole('button',{name:ru['ui.start'],exact:true}).click();const reply=page.getByRole('textbox',{name:ru['conversation.answer'],exact:true});await reply.fill('My name is Mira.');
await picker().selectOption('de-DE');assert.equal(await page.getByRole('textbox',{name:de['conversation.answer'],exact:true}).inputValue(),'My name is Mira.');await picker().selectOption('ru-RU');
await page.getByRole('button',{name:ru['nav.admin'],exact:true}).click();const budget=page.getByLabel(ru['ui.monthly_limit_in_usd'],{exact:true});await budget.fill('0.12');await picker().selectOption('de-DE');assert.equal(await page.getByLabel(de['ui.monthly_limit_in_usd'],{exact:true}).inputValue(),'0.12');await picker().selectOption('ru-RU');assert.equal(await budget.inputValue(),'0.12');const settings=await(await page.request.get(api+'/admin/ai/settings',{headers})).json();assert.equal(settings.budget.monthly_limit_microusd,0);
await patch({native_language:original.user.native_language});
// Server codes, rather than server diagnostics, appear in the selected native language.
await page.getByRole('button',{name:ru['auth.logout'],exact:true}).click();await page.getByRole('textbox',{name:ru['auth.email'],exact:true}).fill(email);await page.getByLabel(ru['auth.password'],{exact:true}).fill('wrong-password');await page.getByRole('button',{name:ru['auth.login'],exact:true}).click();await page.locator('.form-error').filter({hasText:'Неверная почта или пароль.'}).waitFor();await picker().selectOption('de-DE');await page.locator('.form-error').filter({hasText:'E-Mail oder Passwort ist falsch.'}).waitFor();
assert.deepEqual(errors,[]);console.log('PASS: German/Russian catalogs and placeholders; registration/login/persistence; exactly two native options; coupled aliases; profile preservation; rejected conflicts and saves; localized errors; pronunciation target, dialog answer and unsaved budget survive native switches.');
} finally {await browser.close()}
})().catch(e=>{console.error(e);process.exitCode=1});