feat/Update_Controllers_to_Allow_for_Premium_Membership
This commit is contained in:
@@ -90,6 +90,24 @@ describe('LoginPage', () => {
|
||||
expect(window.localStorage.getItem('authTokenPersistence')).toBe('session');
|
||||
});
|
||||
|
||||
it('does not complete login when registration requires email verification', async () => {
|
||||
mockedApi.get.mockClear();
|
||||
mockedApi.get.mockResolvedValueOnce({
|
||||
data: { requireAuth: true, googleEnabled: false, microsoftEnabled: false, localEnabled: true, allowRegistration: true, requireEmailVerification: true },
|
||||
} as any);
|
||||
mockedApi.post.mockResolvedValueOnce({ data: { verificationRequired: true } } as any);
|
||||
|
||||
renderLoginPage('register');
|
||||
await userEvent.type(await screen.findByLabelText('Email'), 'pending@example.com');
|
||||
await userEvent.type(screen.getByLabelText('Current password'), 'password1');
|
||||
await userEvent.type(screen.getByLabelText('Confirm password'), 'password1');
|
||||
await click(screen.getByRole('button', { name: 'Create account' }));
|
||||
|
||||
expect(await screen.findByText('Please verify your email address before signing in.')).toBeInTheDocument();
|
||||
expect(mockedApi.get).not.toHaveBeenCalledWith('/auth/me');
|
||||
expect(mockNavigate).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('rejects an unsafe post-login redirect path', async () => {
|
||||
mockedApi.post.mockResolvedValueOnce({ data: { authenticated: true, provider: 'local' } } as any);
|
||||
mockedApi.get.mockResolvedValueOnce({ data: { roles: [], email: 'person@example.com', userName: 'person' } } as any);
|
||||
|
||||
Reference in New Issue
Block a user