From f0b855d87e9caf06644cef399090652de1711b4e Mon Sep 17 00:00:00 2001 From: Blue Date: Tue, 14 Nov 2023 18:32:39 +0500 Subject: [PATCH] fix: add spinner while loading the optional fields in embadded exp (#1102) Description: Add spinner while loading the optional fields in embadded exp VAN-1658 --- .../ProgressiveProfiling.jsx | 109 ++++++++++-------- .../tests/ProgressiveProfiling.test.jsx | 23 ++++ 2 files changed, 81 insertions(+), 51 deletions(-) diff --git a/src/progressive-profiling/ProgressiveProfiling.jsx b/src/progressive-profiling/ProgressiveProfiling.jsx index 8b5878fe..64af714e 100644 --- a/src/progressive-profiling/ProgressiveProfiling.jsx +++ b/src/progressive-profiling/ProgressiveProfiling.jsx @@ -14,6 +14,7 @@ import { Alert, Form, Hyperlink, + Spinner, StatefulButton, } from '@edx/paragon'; import { Error } from '@edx/paragon/icons'; @@ -217,57 +218,63 @@ const ProgressiveProfiling = (props) => { /> )}
-
-

{formatMessage(messages['progressive.profiling.page.heading'])}

-
-
- {showError ? ( - - {formatMessage(messages['welcome.page.error.heading'])} -

{formatMessage(messages['welcome.page.error.message'])}

-
- ) : null} -
- {formFields} - {(getConfig().AUTHN_PROGRESSIVE_PROFILING_SUPPORT_LINK) && ( - - (sendTrackEvent('edx.bi.welcome.page.support.link.clicked'))} - > - {formatMessage(messages['optional.fields.information.link'])} - - - )} -
- e.preventDefault()} - /> - e.preventDefault()} - /> -
-
+ {registrationEmbedded && welcomePageContextApiStatus === PENDING_STATE ? ( + + ) : ( + <> +
+

{formatMessage(messages['progressive.profiling.page.heading'])}

+

+ {showError ? ( + + {formatMessage(messages['welcome.page.error.heading'])} +

{formatMessage(messages['welcome.page.error.message'])}

+
+ ) : null} +
+ {formFields} + {(getConfig().AUTHN_PROGRESSIVE_PROFILING_SUPPORT_LINK) && ( + + (sendTrackEvent('edx.bi.welcome.page.support.link.clicked'))} + > + {formatMessage(messages['optional.fields.information.link'])} + + + )} +
+ e.preventDefault()} + /> + e.preventDefault()} + /> +
+
+ + )} +
); diff --git a/src/progressive-profiling/tests/ProgressiveProfiling.test.jsx b/src/progressive-profiling/tests/ProgressiveProfiling.test.jsx index d49fcc29..a29f1121 100644 --- a/src/progressive-profiling/tests/ProgressiveProfiling.test.jsx +++ b/src/progressive-profiling/tests/ProgressiveProfiling.test.jsx @@ -14,6 +14,7 @@ import { COMPLETE_STATE, DEFAULT_REDIRECT_URL, EMBEDDED, FAILURE_STATE, + PENDING_STATE, RECOMMENDATIONS, } from '../../data/constants'; import { saveUserProfile } from '../data/actions'; @@ -292,6 +293,28 @@ describe('ProgressiveProfilingTests', () => { expect(sendTrackEvent).toHaveBeenCalledWith('edx.bi.welcome.page.skip.link.clicked', { host }); }); + it('should show spinner while fetching the optional fields', () => { + delete window.location; + window.location = { + assign: jest.fn().mockImplementation((value) => { window.location.href = value; }), + href: getConfig().BASE_URL.concat(AUTHN_PROGRESSIVE_PROFILING), + search: `?host=${host}&variant=${EMBEDDED}`, + }; + + store = mockStore({ + ...initialState, + commonComponents: { + ...initialState.commonComponents, + thirdPartyAuthApiStatus: PENDING_STATE, + optionalFields, + }, + }); + + const progressiveProfilingPage = mount(reduxWrapper()); + + expect(progressiveProfilingPage.find('#tpa-spinner').exists()).toBeTruthy(); + }); + it('should set host property value to host where iframe is embedded for on ramp experience', () => { const expectedEventProperties = { isGenderSelected: false,