From 812105a51d46db9b66ce67db48fd0fca976a2475 Mon Sep 17 00:00:00 2001 From: glo85315 <159006137+glo85315@users.noreply.github.com> Date: Mon, 1 Apr 2024 16:57:51 +0530 Subject: [PATCH] =?UTF-8?q?PWA-3233=20:=20Unable=20to=20sign-In=20using=20?= =?UTF-8?q?TAB/=20Mouse=20Click=20button=20from=20Sign=20=E2=80=A6=20(#423?= =?UTF-8?q?1)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * PWA-3233 : Unable to sign-In using TAB/ Mouse Click button from Sign in Page * PWA-3233 :fixed the preetier issues * PWA-3233 : fixed test case coverage * PWA-3233 : fixed test case coverage * Update useSignIn.js * replacing handleTrigger with handleTriggerClick --------- Co-authored-by: rudraswamy.c Co-authored-by: Aanchal Pawar <97873570+glo82145@users.noreply.github.com> Co-authored-by: glo11372 --- .../talons/SignIn/__tests__/useSignIn.spec.js | 14 ++++++++++++ .../peregrine/lib/talons/SignIn/useSignIn.js | 22 +++++++++++-------- 2 files changed, 27 insertions(+), 9 deletions(-) diff --git a/packages/peregrine/lib/talons/SignIn/__tests__/useSignIn.spec.js b/packages/peregrine/lib/talons/SignIn/__tests__/useSignIn.spec.js index 2ebbc99315..63e35adb8b 100644 --- a/packages/peregrine/lib/talons/SignIn/__tests__/useSignIn.spec.js +++ b/packages/peregrine/lib/talons/SignIn/__tests__/useSignIn.spec.js @@ -227,3 +227,17 @@ test('mutation error is returned by talon', async () => { `[Error: Uh oh! There was an error signing in :(]` ); }); + +it('should call handleForgotPassword when Enter key is pressed', () => { + const { result } = renderHookWithProviders(); + const { forgotPasswordHandleEnterKeyPress } = result.current; + const enterKeyEvent = { key: 'Enter' }; + renderHook(() => forgotPasswordHandleEnterKeyPress(enterKeyEvent)); +}); + +it('should call handleEnterKeyPress when Enter key is pressed', () => { + const { result } = renderHookWithProviders(); + const { handleEnterKeyPress } = result.current; + const enterKeyEvent = { key: 'Enter' }; + renderHook(() => handleEnterKeyPress(enterKeyEvent)); +}); diff --git a/packages/peregrine/lib/talons/SignIn/useSignIn.js b/packages/peregrine/lib/talons/SignIn/useSignIn.js index d4db2026e3..0bf326e531 100644 --- a/packages/peregrine/lib/talons/SignIn/useSignIn.js +++ b/packages/peregrine/lib/talons/SignIn/useSignIn.js @@ -68,6 +68,7 @@ export const useSignIn = props => { async ({ email, password }) => { setIsSigningIn(true); handleTriggerClick(); + try { // Get source cart id (guest cart id). const sourceCartId = cartId; @@ -159,13 +160,14 @@ export const useSignIn = props => { showForgotPassword(); }, [setDefaultUsername, showForgotPassword]); - const forgotPasswordHandleEnterKeyPress = useCallback(() => { + const forgotPasswordHandleEnterKeyPress = useCallback( event => { if (event.key === 'Enter') { handleForgotPassword(); } - }; - }, [handleForgotPassword]); + }, + [handleForgotPassword] + ); const handleCreateAccount = useCallback(() => { const { current: formApi } = formApiRef; @@ -177,21 +179,23 @@ export const useSignIn = props => { showCreateAccount(); }, [setDefaultUsername, showCreateAccount]); - const handleEnterKeyPress = useCallback(() => { + const handleEnterKeyPress = useCallback( event => { if (event.key === 'Enter') { handleCreateAccount(); } - }; - }, [handleCreateAccount]); + }, + [handleCreateAccount] + ); - const signinHandleEnterKeyPress = useCallback(() => { + const signinHandleEnterKeyPress = useCallback( event => { if (event.key === 'Enter') { handleSubmit(); } - }; - }, [handleSubmit]); + }, + [handleSubmit] + ); const errors = useMemo( () =>