Public Access
feat(registration): add email confirmation UI
New ConfirmEmailPage for users to verify their email and set password. Resend form on registration and error pages. Registration form no longer asks for a password. Confirmation requires a button click. The admin list marks unconfirmed requests and offers only delete for them.
This commit is contained in:
1 parent
249973dd69
commit
6dda186bdf
15 files changed
+416
-50
No files matched your search
@@ -0,0 +1,37 @@
|
||||
// @vitest-environment jsdom
|
||||
import {afterEach, describe, expect, it, vi} from 'vitest';
|
||||
import {cleanup, fireEvent, render, screen} from '@testing-library/react';
|
||||
import ResendConfirmation from './ResendConfirmation.jsx';
|
||||
import {fetchRoutes, json} from '../test/fetchRoutes.js';
|
||||
|
||||
vi.mock('react-i18next', () => ({
|
||||
useTranslation: () => ({
|
||||
t: (key, options) => (options?.minutes === undefined ? key : `${key}:${options.minutes}`),
|
||||
i18n: {language: 'de'},
|
||||
}),
|
||||
}));
|
||||
|
||||
describe('ResendConfirmation', () => {
|
||||
afterEach(cleanup);
|
||||
|
||||
it('sends the prefilled address and shows the same answer for any address', async () => {
|
||||
const mock = fetchRoutes({'POST /api/registration/resend': json(204, null)});
|
||||
render(<ResendConfirmation defaultEmail="a@b.de"/>);
|
||||
|
||||
fireEvent.click(screen.getByRole('button', {name: 'REGISTRATION.RESEND'}));
|
||||
|
||||
expect(await screen.findByText('REGISTRATION.RESEND_SENT')).toBeTruthy();
|
||||
expect(JSON.parse(mock.mock.calls[0][1].body)).toEqual({email: 'a@b.de'});
|
||||
});
|
||||
|
||||
it('shows the wait time when the IP is blocked', async () => {
|
||||
fetchRoutes({
|
||||
'POST /api/registration/resend': {...json(429, {}), headers: new Headers({'Retry-After': '900'})},
|
||||
});
|
||||
render(<ResendConfirmation/>);
|
||||
|
||||
fireEvent.click(screen.getByRole('button', {name: 'REGISTRATION.RESEND'}));
|
||||
|
||||
expect(await screen.findByText('REGISTRATION.ERROR_TOO_MANY_ATTEMPTS:15')).toBeTruthy();
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user