From 7503e6c5cb06672ca939cdc01e4b15481b13065d Mon Sep 17 00:00:00 2001 From: Muhammad Abdullah Waheed <42172960+abdullahwaheed@users.noreply.github.com> Date: Thu, 18 Aug 2022 10:41:50 +0500 Subject: [PATCH] Paragon form component deprecations (#596) * refactor: removed ValidationFormGroup deprecations * refactor: updated unit tests * fix: linting issue * refactor: added unit tests for some uncovered code --- src/profile/ProfilePage.test.jsx | 87 + .../__snapshots__/ProfilePage.test.jsx.snap | 6788 ++++++++++++++++- src/profile/forms/Bio.jsx | 16 +- src/profile/forms/Country.jsx | 16 +- src/profile/forms/Education.jsx | 16 +- src/profile/forms/PreferredLanguage.jsx | 16 +- 6 files changed, 6913 insertions(+), 26 deletions(-) diff --git a/src/profile/ProfilePage.test.jsx b/src/profile/ProfilePage.test.jsx index e82ba50..ba9b190 100644 --- a/src/profile/ProfilePage.test.jsx +++ b/src/profile/ProfilePage.test.jsx @@ -146,6 +146,93 @@ describe('', () => { expect(tree).toMatchSnapshot(); }); + it('while saving an edited bio with error', () => { + const storeData = JSON.parse(JSON.stringify(storeMocks.savingEditedBio)); + storeData.profilePage.errors.bio = { userMessage: 'bio error' }; + const component = ( + + + + + + + + ); + const tree = renderer.create(component).toJSON(); + expect(tree).toMatchSnapshot(); + }); + + it('test country edit with error', () => { + const storeData = JSON.parse(JSON.stringify(storeMocks.savingEditedBio)); + storeData.profilePage.errors.country = { userMessage: 'country error' }; + storeData.profilePage.currentlyEditingField = 'country'; + const component = ( + + + + + + + + ); + const tree = renderer.create(component).toJSON(); + expect(tree).toMatchSnapshot(); + }); + + it('test education edit with error', () => { + const storeData = JSON.parse(JSON.stringify(storeMocks.savingEditedBio)); + storeData.profilePage.errors.levelOfEducation = { userMessage: 'education error' }; + storeData.profilePage.currentlyEditingField = 'levelOfEducation'; + const component = ( + + + + + + + + ); + const tree = renderer.create(component).toJSON(); + expect(tree).toMatchSnapshot(); + }); + + it('test preferreded language edit with error', () => { + const storeData = JSON.parse(JSON.stringify(storeMocks.savingEditedBio)); + storeData.profilePage.errors.languageProficiencies = { userMessage: 'preferred language error' }; + storeData.profilePage.currentlyEditingField = 'languageProficiencies'; + const component = ( + + + + + + + + ); + const tree = renderer.create(component).toJSON(); + expect(tree).toMatchSnapshot(); + }); + it('without credentials service', () => { const config = getConfig(); config.CREDENTIALS_BASE_URL = ''; diff --git a/src/profile/__snapshots__/ProfilePage.test.jsx.snap b/src/profile/__snapshots__/ProfilePage.test.jsx.snap index 068207c..b5682da 100644 --- a/src/profile/__snapshots__/ProfilePage.test.jsx.snap +++ b/src/profile/__snapshots__/ProfilePage.test.jsx.snap @@ -31,6 +31,5654 @@ exports[` Renders correctly in various states app loading 1`] = ` `; +exports[` Renders correctly in various states test country edit with error 1`] = ` +
+
+
+
+
+
+
+
+
+
+ +
+
+ profile avatar +
+
+ +
+
+
+
+
+
+ +

+ staff +

+

+ + Member since + + 2017 + + +

+
+
+
+ +
+
+
+
+
+ +

+ staff +

+

+ + Member since + + 2017 + + +

+
+
+
+ +
+
+
+

+ Full Name + +

+

+ + + + Just me + +

+
+

+ Lemon Seltzer +

+ + This is the name that appears in your account and on your certificates. + +
+
+
+
+
+
+
+ + +
+ country error +
+
+
+
+ + + + + + + +
+
+ + +
+
+
+
+
+
+
+
+
+

+ Primary Language Spoken + +

+

+ + + + Everyone on localhost + +

+
+

+ Yoruba +

+
+
+
+
+
+

+ Education + +

+

+ + + + Just me + +

+
+

+ Elementary/primary school +

+
+
+
+
+
+

+ Social Links + +

+

+ + + + Everyone on localhost + +

+
+ +
+
+
+
+
+
+
+

+ About Me + +

+

+ + + + Everyone on localhost + +

+
+

+ This is my bio +

+
+
+
+
+
+

+ My Certificates + +

+

+ + + + Everyone on localhost + +

+
+
+
+
+
+
+
+

+ Verified Certificate +

+

+ edX Demonstration Course +

+
+

+ + From + +

+

+ edX +

+
+

+ + Completed on + + 3/4/2019 + + +

+ +
+
+
+
+
+
+
+
+
+
+`; + +exports[` Renders correctly in various states test education edit with error 1`] = ` +
+
+
+
+
+
+
+
+
+
+ +
+
+ profile avatar +
+
+ +
+
+
+
+
+
+ +

+ staff +

+

+ + Member since + + 2017 + + +

+
+
+
+ +
+
+
+
+
+ +

+ staff +

+

+ + Member since + + 2017 + + +

+
+
+
+ +
+
+
+

+ Full Name + +

+

+ + + + Just me + +

+
+

+ Lemon Seltzer +

+ + This is the name that appears in your account and on your certificates. + +
+
+
+
+
+

+ Location + +

+

+ + + + Everyone on localhost + +

+
+

+ Montenegro +

+
+
+
+
+
+

+ Primary Language Spoken + +

+

+ + + + Everyone on localhost + +

+
+

+ Yoruba +

+
+
+
+
+
+
+
+ + +
+ education error +
+
+
+
+ + + + + + + +
+
+ + +
+
+
+
+
+
+
+
+
+

+ Social Links + +

+

+ + + + Everyone on localhost + +

+
+ +
+
+
+
+
+
+
+

+ About Me + +

+

+ + + + Everyone on localhost + +

+
+

+ This is my bio +

+
+
+
+
+
+

+ My Certificates + +

+

+ + + + Everyone on localhost + +

+
+
+
+
+
+
+
+

+ Verified Certificate +

+

+ edX Demonstration Course +

+
+

+ + From + +

+

+ edX +

+
+

+ + Completed on + + 3/4/2019 + + +

+ +
+
+
+
+
+
+
+
+
+
+`; + +exports[` Renders correctly in various states test preferreded language edit with error 1`] = ` +
+
+
+
+
+
+
+
+
+
+ +
+
+ profile avatar +
+
+ +
+
+
+
+
+
+ +

+ staff +

+

+ + Member since + + 2017 + + +

+
+
+
+ +
+
+
+
+
+ +

+ staff +

+

+ + Member since + + 2017 + + +

+
+
+
+ +
+
+
+

+ Full Name + +

+

+ + + + Just me + +

+
+

+ Lemon Seltzer +

+ + This is the name that appears in your account and on your certificates. + +
+
+
+
+
+

+ Location + +

+

+ + + + Everyone on localhost + +

+
+

+ Montenegro +

+
+
+
+
+
+
+
+ + +
+ preferred language error +
+
+
+
+ + + + + + + +
+
+ + +
+
+
+
+
+
+
+
+
+

+ Education + +

+

+ + + + Just me + +

+
+

+ Elementary/primary school +

+
+
+
+
+
+

+ Social Links + +

+

+ + + + Everyone on localhost + +

+
+ +
+
+
+
+
+
+
+

+ About Me + +

+

+ + + + Everyone on localhost + +

+
+

+ This is my bio +

+
+
+
+
+
+

+ My Certificates + +

+

+ + + + Everyone on localhost + +

+
+
+
+
+
+
+
+

+ Verified Certificate +

+

+ edX Demonstration Course +

+
+

+ + From + +

+

+ edX +

+
+

+ + Completed on + + 3/4/2019 + + +

+ +
+
+
+
+
+
+
+
+
+
+`; + exports[` Renders correctly in various states viewing other profile 1`] = `
Renders correctly in various states while saving an edi onSubmit={[Function]} >