Public Access
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.
38 lines
1.5 KiB
React
38 lines
1.5 KiB
React
// @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();
|
|
});
|
|
});
|