feat(registration): send the browser language
Build, Test & Push Frontend / quality-check (push) Successful in 22s
Build, Test & Push Frontend / docker (push) Successful in 25s

This commit is contained in:
lobo committed 2026-10-01 08:30:24 +02:00
1 parent 43968b3b7a
commit b8f70e7578
3 files changed
+16 -1

No files matched your search

+2
View File
@@ -54,6 +54,8 @@ export default function RegistrationPage() {
password: values.password,
inviteCode: values.inviteCode,
displayName: values.displayName,
// Auth's mails use it: a German browser gets German, every other one English.
language: navigator.language?.toLowerCase().startsWith('de') ? 'de' : 'en',
}),
});
+12
View File
@@ -30,6 +30,7 @@ function submitValidForm() {
describe('RegistrationPage', () => {
afterEach(() => {
cleanup();
vi.restoreAllMocks();
});
it('shows the wait time when the IP is blocked', async () => {
@@ -50,6 +51,17 @@ describe('RegistrationPage', () => {
expect(JSON.parse(fetch.mock.calls[0][1].body)).not.toHaveProperty('steamId');
});
it.each([['de-DE', 'de'], ['de', 'de'], ['en-US', 'en'], ['fr-FR', 'en'], [undefined, 'en']])(
'sends the browser language %s as %s, for the mails', async (browser, sent) => {
vi.spyOn(navigator, 'language', 'get').mockReturnValue(browser);
answerRegistration(400, 'INVALID_INVITATION_CODE');
submitValidForm();
await screen.findByText('REGISTRATION.ERROR_INVALID_INVITE_CODE');
expect(JSON.parse(fetch.mock.calls[0][1].body).language).toBe(sent);
});
it('maps a known backend error to its message', async () => {
answerRegistration(400, 'INVALID_INVITATION_CODE');