From 1f7496bfe9bca57992f8c7c6810ca0ea8d0afe15 Mon Sep 17 00:00:00 2001 From: ssurendrannair Date: Mon, 6 Jul 2026 18:21:31 +0000 Subject: [PATCH 1/5] fix: clear form errors on valid email submission in forgot password --- src/forgot-password/ForgotPasswordPage.jsx | 3 +++ .../tests/ForgotPasswordPage.test.jsx | 23 +++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/src/forgot-password/ForgotPasswordPage.jsx b/src/forgot-password/ForgotPasswordPage.jsx index fad3130045..d4fc33e471 100644 --- a/src/forgot-password/ForgotPasswordPage.jsx +++ b/src/forgot-password/ForgotPasswordPage.jsx @@ -86,6 +86,9 @@ const ForgotPasswordPage = (props) => { props.setForgotPasswordFormData({ email, emailValidationError: error }); windowScrollTo({ left: 0, top: 0, behavior: 'smooth' }); } else { + setFormErrors(''); + setValidationError(''); + props.setForgotPasswordFormData({ email, emailValidationError: '' }); props.forgotPassword(email); } }; diff --git a/src/forgot-password/tests/ForgotPasswordPage.test.jsx b/src/forgot-password/tests/ForgotPasswordPage.test.jsx index c3b97c030d..cc8501bd21 100644 --- a/src/forgot-password/tests/ForgotPasswordPage.test.jsx +++ b/src/forgot-password/tests/ForgotPasswordPage.test.jsx @@ -241,6 +241,29 @@ describe('ForgotPasswordPage', () => { expect(successElement.textContent).toEqual(successMessage); }); + it('should clear validation errors before submitting a valid email', () => { + store.dispatch = jest.fn(store.dispatch); + props = { + ...props, + emailValidationError: 'Enter your email', + email: '', + }; + + const { container } = render(reduxWrapper()); + const emailInput = screen.getByLabelText('Email'); + + fireEvent.change(emailInput, { target: { value: 'registered@example.com' } }); + fireEvent.click(screen.getByText('Submit')); + + expect(props.forgotPassword).toHaveBeenCalledWith('registered@example.com'); + expect(store.dispatch).toHaveBeenCalledWith(setForgotPasswordFormData({ + email: 'registered@example.com', + emailValidationError: '', + })); + expect(container.querySelector('.pgn__form-text-invalid')).toBeNull(); + expect(container.querySelector('.alert-danger')).toBeNull(); + }); + it('should display invalid password reset link error', () => { store = mockStore({ ...initialState, From 8d5878411b4e4d7c8423989b26ba054f731d4657 Mon Sep 17 00:00:00 2001 From: ssurendrannair Date: Tue, 7 Jul 2026 06:55:17 +0000 Subject: [PATCH 2/5] test: assert forgot password submission via redux dispatch --- src/forgot-password/tests/ForgotPasswordPage.test.jsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/forgot-password/tests/ForgotPasswordPage.test.jsx b/src/forgot-password/tests/ForgotPasswordPage.test.jsx index cc8501bd21..c88d356cf7 100644 --- a/src/forgot-password/tests/ForgotPasswordPage.test.jsx +++ b/src/forgot-password/tests/ForgotPasswordPage.test.jsx @@ -10,7 +10,7 @@ import configureStore from 'redux-mock-store'; import { INTERNAL_SERVER_ERROR, LOGIN_PAGE } from '../../data/constants'; import { PASSWORD_RESET } from '../../reset-password/data/constants'; -import { setForgotPasswordFormData } from '../data/actions'; +import { forgotPassword, setForgotPasswordFormData } from '../data/actions'; import ForgotPasswordPage from '../ForgotPasswordPage'; const mockedNavigator = jest.fn(); @@ -255,7 +255,7 @@ describe('ForgotPasswordPage', () => { fireEvent.change(emailInput, { target: { value: 'registered@example.com' } }); fireEvent.click(screen.getByText('Submit')); - expect(props.forgotPassword).toHaveBeenCalledWith('registered@example.com'); + expect(store.dispatch).toHaveBeenCalledWith(forgotPassword('registered@example.com')); expect(store.dispatch).toHaveBeenCalledWith(setForgotPasswordFormData({ email: 'registered@example.com', emailValidationError: '', From d06aed336f68b856ab1530e501d23942379d98a1 Mon Sep 17 00:00:00 2001 From: ssurendrannair Date: Tue, 7 Jul 2026 12:51:17 +0530 Subject: [PATCH 3/5] Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- .../tests/ForgotPasswordPage.test.jsx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/forgot-password/tests/ForgotPasswordPage.test.jsx b/src/forgot-password/tests/ForgotPasswordPage.test.jsx index c88d356cf7..d611d8099e 100644 --- a/src/forgot-password/tests/ForgotPasswordPage.test.jsx +++ b/src/forgot-password/tests/ForgotPasswordPage.test.jsx @@ -243,15 +243,15 @@ describe('ForgotPasswordPage', () => { it('should clear validation errors before submitting a valid email', () => { store.dispatch = jest.fn(store.dispatch); - props = { - ...props, - emailValidationError: 'Enter your email', - email: '', - }; const { container } = render(reduxWrapper()); - const emailInput = screen.getByLabelText('Email'); + // First submit an invalid/blank email to trigger the alert banner via local `formErrors`. + fireEvent.click(screen.getByText('Submit')); + expect(container.querySelector('.alert-danger')).not.toBeNull(); + + // Then resubmit with a valid email and verify the banner + validation error are cleared. + const emailInput = screen.getByLabelText('Email'); fireEvent.change(emailInput, { target: { value: 'registered@example.com' } }); fireEvent.click(screen.getByText('Submit')); From b4c909788b96f558e4ff7ac97fd9d14b5c3b4eec Mon Sep 17 00:00:00 2001 From: ssurendrannair Date: Tue, 7 Jul 2026 06:55:17 +0000 Subject: [PATCH 4/5] fix: address pull request finding --- src/forgot-password/tests/ForgotPasswordPage.test.jsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/forgot-password/tests/ForgotPasswordPage.test.jsx b/src/forgot-password/tests/ForgotPasswordPage.test.jsx index cc8501bd21..c88d356cf7 100644 --- a/src/forgot-password/tests/ForgotPasswordPage.test.jsx +++ b/src/forgot-password/tests/ForgotPasswordPage.test.jsx @@ -10,7 +10,7 @@ import configureStore from 'redux-mock-store'; import { INTERNAL_SERVER_ERROR, LOGIN_PAGE } from '../../data/constants'; import { PASSWORD_RESET } from '../../reset-password/data/constants'; -import { setForgotPasswordFormData } from '../data/actions'; +import { forgotPassword, setForgotPasswordFormData } from '../data/actions'; import ForgotPasswordPage from '../ForgotPasswordPage'; const mockedNavigator = jest.fn(); @@ -255,7 +255,7 @@ describe('ForgotPasswordPage', () => { fireEvent.change(emailInput, { target: { value: 'registered@example.com' } }); fireEvent.click(screen.getByText('Submit')); - expect(props.forgotPassword).toHaveBeenCalledWith('registered@example.com'); + expect(store.dispatch).toHaveBeenCalledWith(forgotPassword('registered@example.com')); expect(store.dispatch).toHaveBeenCalledWith(setForgotPasswordFormData({ email: 'registered@example.com', emailValidationError: '', From 4c85f09496f55c40ef24bca2f2a4399c45e0445b Mon Sep 17 00:00:00 2001 From: ssurendrannair Date: Tue, 7 Jul 2026 07:42:46 +0000 Subject: [PATCH 5/5] fix: clear stale error state on valid email resubmission in forgot password --- src/forgot-password/tests/ForgotPasswordPage.test.jsx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/forgot-password/tests/ForgotPasswordPage.test.jsx b/src/forgot-password/tests/ForgotPasswordPage.test.jsx index d611d8099e..1b7848e44a 100644 --- a/src/forgot-password/tests/ForgotPasswordPage.test.jsx +++ b/src/forgot-password/tests/ForgotPasswordPage.test.jsx @@ -111,7 +111,7 @@ describe('ForgotPasswordPage', () => { forgotPassword: { status: INTERNAL_SERVER_ERROR }, }); const expectedMessage = 'We were unable to contact you.' - + 'An error has occurred. Try refreshing the page, or check your internet connection.'; + + 'An error has occurred. Try refreshing the page, or check your internet connection.'; const { container } = render(reduxWrapper()); @@ -231,8 +231,8 @@ describe('ForgotPasswordPage', () => { }); const successMessage = 'Check your emailWe sent an email to with instructions to reset your password. If you do not ' - + 'receive a password reset message after 1 minute, verify that you entered the correct email address,' - + ' or check your spam folder. If you need further assistance, contact technical support.'; + + 'receive a password reset message after 1 minute, verify that you entered the correct email address,' + + ' or check your spam folder. If you need further assistance, contact technical support.'; const { container } = render(reduxWrapper()); const successElement = findByTextContent(container, successMessage); @@ -272,8 +272,8 @@ describe('ForgotPasswordPage', () => { }, }); const successMessage = 'Invalid password reset link' - + 'This password reset link is invalid. It may have been used already. ' - + 'Enter your email below to receive a new link.'; + + 'This password reset link is invalid. It may have been used already. ' + + 'Enter your email below to receive a new link.'; const { container } = render(reduxWrapper()); const successElement = findByTextContent(container, successMessage);