feat/Update_Controllers_to_Allow_for_Premium_Membership
This commit is contained in:
@@ -12,12 +12,13 @@ const mockedApi = api as jest.Mocked<typeof api>;
|
||||
// jest.fn() in setupTests.ts before every test -- re-arm it here so error-derived text is testable.
|
||||
const mockedGetApiErrorMessage = getApiErrorMessage as jest.Mock;
|
||||
|
||||
function renderVerifyEmailPage(search: string) {
|
||||
window.history.pushState({}, '', `/verify-email${search}`);
|
||||
function renderVerifyEmailPage(search: string, emailChange = false) {
|
||||
const path = emailChange ? '/confirm-email-change' : '/verify-email';
|
||||
window.history.pushState({}, '', `${path}${search}`);
|
||||
return render(
|
||||
<MemoryRouter initialEntries={[`/verify-email${search}`]} future={{ v7_startTransition: true, v7_relativeSplatPath: true }}>
|
||||
<MemoryRouter initialEntries={[`${path}${search}`]} future={{ v7_startTransition: true, v7_relativeSplatPath: true }}>
|
||||
<I18nProvider>
|
||||
<VerifyEmailPage />
|
||||
<VerifyEmailPage emailChange={emailChange} />
|
||||
</I18nProvider>
|
||||
</MemoryRouter>,
|
||||
);
|
||||
@@ -55,4 +56,13 @@ describe('VerifyEmailPage', () => {
|
||||
expect(await screen.findByText('Missing user/token in link.')).toBeInTheDocument();
|
||||
expect(mockedApi.post).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('confirms a pending email change and requires a fresh sign-in', async () => {
|
||||
mockedApi.post.mockResolvedValueOnce({ data: {} } as any);
|
||||
|
||||
renderVerifyEmailPage('?userId=user-1&email=new%40example.com&token=change-token', true);
|
||||
|
||||
expect(await screen.findByText('Your email has changed. Sign in again with the new address.')).toBeInTheDocument();
|
||||
expect(mockedApi.post).toHaveBeenCalledWith('/auth/email-change/confirm', { userId: 'user-1', email: 'new@example.com', token: 'change-token' });
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user