Public Access
feat(registration): send the browser language
This commit is contained in:
1 parent
43968b3b7a
commit
b8f70e7578
3 files changed
+16
-1
No files matched your search
@@ -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',
|
||||
}),
|
||||
});
|
||||
|
||||
|
||||
@@ -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');
|
||||
|
||||
|
||||
Reference in new issue
Block a user