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`] = `
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ staff
+
+
+
+ Member since
+
+ 2017
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ staff
+
+
+
+ Member since
+
+ 2017
+
+
+
+
+
+
+
+
+
+
+
+ Full Name
+
+
+
+
+ Edit
+
+
+
+
+
+
+
+
+ Just me
+
+
+
+
+ Lemon Seltzer
+
+
+ This is the name that appears in your account and on your certificates.
+
+
+
+
+
+
+
+
+ Primary Language Spoken
+
+
+
+
+ Edit
+
+
+
+
+
+
+
+
+ Everyone on localhost
+
+
+
+
+ Yoruba
+
+
+
+
+
+
+
+ Education
+
+
+
+
+ Edit
+
+
+
+
+
+
+
+
+ Just me
+
+
+
+
+ Elementary/primary school
+
+
+
+
+
+
+
+ Social Links
+
+
+
+
+ Edit
+
+
+
+
+
+
+
+
+ Everyone on localhost
+
+
+
+
+
+
+
+
+
+
+
+
+ About Me
+
+
+
+
+ Edit
+
+
+
+
+
+
+
+
+ Everyone on localhost
+
+
+
+
+ This is my bio
+
+
+
+
+
+
+
+ My Certificates
+
+
+
+
+ Edit
+
+
+
+
+
+
+
+
+ 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`] = `
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ staff
+
+
+
+ Member since
+
+ 2017
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ staff
+
+
+
+ Member since
+
+ 2017
+
+
+
+
+
+
+
+
+
+
+
+ Full Name
+
+
+
+
+ Edit
+
+
+
+
+
+
+
+
+ Just me
+
+
+
+
+ Lemon Seltzer
+
+
+ This is the name that appears in your account and on your certificates.
+
+
+
+
+
+
+
+ Location
+
+
+
+
+ Edit
+
+
+
+
+
+
+
+
+ Everyone on localhost
+
+
+
+
+ Montenegro
+
+
+
+
+
+
+
+ Primary Language Spoken
+
+
+
+
+ Edit
+
+
+
+
+
+
+
+
+ Everyone on localhost
+
+
+
+
+ Yoruba
+
+
+
+
+
+
+
+
+ Social Links
+
+
+
+
+ Edit
+
+
+
+
+
+
+
+
+ Everyone on localhost
+
+
+
+
+
+
+
+
+
+
+
+
+ About Me
+
+
+
+
+ Edit
+
+
+
+
+
+
+
+
+ Everyone on localhost
+
+
+
+
+ This is my bio
+
+
+
+
+
+
+
+ My Certificates
+
+
+
+
+ Edit
+
+
+
+
+
+
+
+
+ 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`] = `
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ staff
+
+
+
+ Member since
+
+ 2017
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ staff
+
+
+
+ Member since
+
+ 2017
+
+
+
+
+
+
+
+
+
+
+
+ Full Name
+
+
+
+
+ Edit
+
+
+
+
+
+
+
+
+ Just me
+
+
+
+
+ Lemon Seltzer
+
+
+ This is the name that appears in your account and on your certificates.
+
+
+
+
+
+
+
+ Location
+
+
+
+
+ Edit
+
+
+
+
+
+
+
+
+ Everyone on localhost
+
+
+
+
+ Montenegro
+
+
+
+
+
+
+
+
+ Education
+
+
+
+
+ Edit
+
+
+
+
+
+
+
+
+ Just me
+
+
+
+
+ Elementary/primary school
+
+
+
+
+
+
+
+ Social Links
+
+
+
+
+ Edit
+
+
+
+
+
+
+
+
+ Everyone on localhost
+
+
+
+
+
+
+
+
+
+
+
+
+ About Me
+
+
+
+
+ Edit
+
+
+
+
+
+
+
+
+ Everyone on localhost
+
+
+
+
+ This is my bio
+
+
+
+
+
+
+
+ My Certificates
+
+
+
+
+ Edit
+
+
+
+
+
+
+
+
+ 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]}
>
Renders correctly in various states while saving an edi
About Me
Renders correctly in various states while saving an edi
`;
+exports[` Renders correctly in various states while saving an edited bio with error 1`] = `
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ staff
+
+
+
+ Member since
+
+ 2017
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ staff
+
+
+
+ Member since
+
+ 2017
+
+
+
+
+
+
+
+
+
+
+
+ Full Name
+
+
+
+
+ Edit
+
+
+
+
+
+
+
+
+ Just me
+
+
+
+
+ Lemon Seltzer
+
+
+ This is the name that appears in your account and on your certificates.
+
+
+
+
+
+
+
+ Location
+
+
+
+
+ Edit
+
+
+
+
+
+
+
+
+ Everyone on localhost
+
+
+
+
+ Montenegro
+
+
+
+
+
+
+
+ Primary Language Spoken
+
+
+
+
+ Edit
+
+
+
+
+
+
+
+
+ Everyone on localhost
+
+
+
+
+ Yoruba
+
+
+
+
+
+
+
+ Education
+
+
+
+
+ Edit
+
+
+
+
+
+
+
+
+ Just me
+
+
+
+
+ Elementary/primary school
+
+
+
+
+
+
+
+ Social Links
+
+
+
+
+ Edit
+
+
+
+
+
+
+
+
+ Everyone on localhost
+
+
+
+
+
+
+
+
+
+
+
+
+
+ My Certificates
+
+
+
+
+ Edit
+
+
+
+
+
+
+
+
+ Everyone on localhost
+
+
+
+
+
+
+
+
+
+
+ Verified Certificate
+
+
+ edX Demonstration Course
+
+
+
+
+ From
+
+
+
+ edX
+
+
+
+
+ Completed on
+
+ 3/4/2019
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+`;
+
exports[` Renders correctly in various states without credentials service 1`] = `
-
{intl.formatMessage(messages['profile.bio.about.me'])}
@@ -71,7 +70,12 @@ class Bio extends React.Component {
value={bio}
onChange={this.handleChange}
/>
-
+ {error !== null && (
+
+ {error}
+
+ )}
+
-
{intl.formatMessage(messages['profile.country.label'])}
@@ -89,7 +88,12 @@ class Country extends React.Component {
{name}
))}
-
+ {error !== null && (
+
+ {error}
+
+ )}
+
-
{intl.formatMessage(messages['profile.education.education'])}
@@ -90,7 +89,12 @@ class Education extends React.Component {
))}
-
+ {error !== null && (
+
+ {error}
+
+ )}
+
-
{intl.formatMessage(messages['profile.preferredlanguage.label'])}
@@ -98,7 +97,12 @@ class PreferredLanguage extends React.Component {
{name}
))}
-
+ {error !== null && (
+
+ {error}
+
+ )}
+