fix: Checkbox incorrectly tied to profile name

Fixed a bug that incorrectly rendered the certificate preference checkbox upon each page render. The bug caused the 1) the checkboxes to both be selected at the same time, 2) the checkbox to always be selected for the profile name, and 3) wouldn't allow the proper UI changes upon saving a verified name. The checkbox selection works correctly now, and the save button for the verified name field also works as expected.
This commit is contained in:
Alie Langston
2021-09-29 08:09:23 -04:00
parent d6519bc825
commit db319b6cdf
4 changed files with 17 additions and 2 deletions

View File

@@ -192,6 +192,8 @@ class AccountSettingsPage extends React.Component {
}
if (values !== this.props.committedValues?.verified_name) {
this.props.beginNameChange(formId);
} else {
this.props.saveSettings(formId, values);
}
}

View File

@@ -76,7 +76,7 @@ function CertificatePreference({
}
useEffect(() => {
if (fieldName === 'verifiedName') {
if (fieldName === 'verified_name') {
setChecked(useVerifiedNameForCerts);
} else {
setChecked(!useVerifiedNameForCerts);

View File

@@ -158,4 +158,17 @@ describe('NameChange', () => {
type: 'ACCOUNT_SETTINGS__SAVE_SETTINGS',
});
});
it('checks box for verified name', () => {
props = {
...props,
fieldName: 'verified_name',
useVerifiedNameForCerts: true,
};
render(reduxWrapper(<IntlCertificatePreference {...props} />));
const checkbox = screen.getByLabelText(labelText);
expect(checkbox.checked).toEqual(true);
});
});

View File

@@ -63,7 +63,7 @@ const valuesSelector = createSelector(
mostRecentApprovedVerifiedNameValueSelector,
(accountSettings, mostRecentApprovedVerifiedNameValue) => {
let useVerifiedNameForCerts = (
accountSettings.values.verifiedNameHistory?.use_verified_name_for_certs || false
accountSettings.verifiedNameHistory?.use_verified_name_for_certs || false
);
if (Object.keys(accountSettings.confirmationValues).includes('useVerifiedNameForCerts')) {