From 7ea26d5ffc7940a055d411ef61ff5f457fc9b888 Mon Sep 17 00:00:00 2001 From: alipov_d Date: Thu, 31 Aug 2023 15:18:21 +0300 Subject: [PATCH] feat: add toggling for the hardcode support link Add a toggling mechanism for the "unlink all social media accounts" text to show it as a link or text depending on the MFE env setting. --- .env | 1 + .env.development | 2 +- .env.test | 1 + .../delete-account/BeforeProceedingBanner.jsx | 4 +- .../BeforeProceedingBanner.test.jsx | 48 +++++++++++++ .../delete-account/DeleteAccount.jsx | 3 +- .../BeforeProceedingBanner.test.jsx.snap | 68 +++++++++++++++++++ 7 files changed, 124 insertions(+), 3 deletions(-) create mode 100644 src/account-settings/delete-account/BeforeProceedingBanner.test.jsx create mode 100644 src/account-settings/delete-account/__snapshots__/BeforeProceedingBanner.test.jsx.snap diff --git a/.env b/.env index 90fa5d9eb..f1edebe17 100644 --- a/.env +++ b/.env @@ -31,3 +31,4 @@ MARKETING_EMAILS_OPT_IN='' APP_ID= MFE_CONFIG_API_URL= PASSWORD_RESET_SUPPORT_LINK='' +SUPPORT_URL_TO_UNLINK_SOCIAL_MEDIA_ACCOUNT='https://support.edx.org/hc/en-us/articles/207206067' diff --git a/.env.development b/.env.development index b2cb20c53..f354bb8da 100644 --- a/.env.development +++ b/.env.development @@ -32,4 +32,4 @@ MARKETING_EMAILS_OPT_IN='' APP_ID= MFE_CONFIG_API_URL= PASSWORD_RESET_SUPPORT_LINK='mailto:support@example.com' - +SUPPORT_URL_TO_UNLINK_SOCIAL_MEDIA_ACCOUNT='https://support.edx.org/hc/en-us/articles/207206067' diff --git a/.env.test b/.env.test index 7b20d2376..0a5e56127 100644 --- a/.env.test +++ b/.env.test @@ -30,3 +30,4 @@ ENABLE_DOB_UPDATE='' MARKETING_EMAILS_OPT_IN='' APP_ID= MFE_CONFIG_API_URL= +SUPPORT_URL_TO_UNLINK_SOCIAL_MEDIA_ACCOUNT='https://support.edx.org/hc/en-us/articles/207206067' diff --git a/src/account-settings/delete-account/BeforeProceedingBanner.jsx b/src/account-settings/delete-account/BeforeProceedingBanner.jsx index 6f051323a..36eb748e8 100644 --- a/src/account-settings/delete-account/BeforeProceedingBanner.jsx +++ b/src/account-settings/delete-account/BeforeProceedingBanner.jsx @@ -25,10 +25,12 @@ const BeforeProceedingBanner = (props) => { defaultMessage="Before proceeding, please {actionLink}." description="Error that appears if you are trying to delete your account, but something about your account needs attention first. The actionLink will be instructions, such as 'unlink your Facebook account'." values={{ - actionLink: ( + actionLink: supportArticleUrl ? ( {intl.formatMessage(messages[instructionMessageId])} + ) : ( + intl.formatMessage(messages[instructionMessageId]) ), siteName: getConfig().SITE_NAME, }} diff --git a/src/account-settings/delete-account/BeforeProceedingBanner.test.jsx b/src/account-settings/delete-account/BeforeProceedingBanner.test.jsx new file mode 100644 index 000000000..4800cdf23 --- /dev/null +++ b/src/account-settings/delete-account/BeforeProceedingBanner.test.jsx @@ -0,0 +1,48 @@ +import React from 'react'; +import ReactDOM from 'react-dom'; +import renderer from 'react-test-renderer'; +import { IntlProvider, injectIntl, createIntl } from '@edx/frontend-platform/i18n'; + +ReactDOM.createPortal = node => node; + +import BeforeProceedingBanner from './BeforeProceedingBanner'; // eslint-disable-line import/first + +const IntlBeforeProceedingBanner = injectIntl(BeforeProceedingBanner); + +describe('BeforeProceedingBanner', () => { + it('should match the snapshot if SUPPORT_URL_TO_UNLINK_SOCIAL_MEDIA_ACCOUNT does not have a support link', () => { + const props = { + instructionMessageId: 'account.settings.delete.account.please.unlink', + intl: createIntl({ locale: 'en' }), + supportArticleUrl: '', + }; + const tree = renderer + .create(( + + + + )) + .toJSON(); + expect(tree).toMatchSnapshot(); + }); + + it('should match the snapshot when SUPPORT_URL_TO_UNLINK_SOCIAL_MEDIA_ACCOUNT has a support link', () => { + const props = { + instructionMessageId: 'account.settings.delete.account.please.unlink', + intl: createIntl({ locale: 'en' }), + supportArticleUrl: 'http://test-support.edx', + }; + const tree = renderer + .create(( + + + + )) + .toJSON(); + expect(tree).toMatchSnapshot(); + }); +}); diff --git a/src/account-settings/delete-account/DeleteAccount.jsx b/src/account-settings/delete-account/DeleteAccount.jsx index 5cf806af4..6a6323d94 100644 --- a/src/account-settings/delete-account/DeleteAccount.jsx +++ b/src/account-settings/delete-account/DeleteAccount.jsx @@ -59,6 +59,7 @@ export class DeleteAccount extends React.Component { hasLinkedTPA, isVerifiedAccount, status, errorType, intl, } = this.props; const canDelete = isVerifiedAccount && !hasLinkedTPA; + const supportArticleUrl = process.env.SUPPORT_URL_TO_UNLINK_SOCIAL_MEDIA_ACCOUNT; // TODO: We lack a good way of providing custom language for a particular site. This is a hack // to allow edx.org to fulfill its business requirements. @@ -122,7 +123,7 @@ export class DeleteAccount extends React.Component { {hasLinkedTPA ? ( ) : null} diff --git a/src/account-settings/delete-account/__snapshots__/BeforeProceedingBanner.test.jsx.snap b/src/account-settings/delete-account/__snapshots__/BeforeProceedingBanner.test.jsx.snap new file mode 100644 index 000000000..9a62d94f9 --- /dev/null +++ b/src/account-settings/delete-account/__snapshots__/BeforeProceedingBanner.test.jsx.snap @@ -0,0 +1,68 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`BeforeProceedingBanner should match the snapshot if SUPPORT_URL_TO_UNLINK_SOCIAL_MEDIA_ACCOUNT does not have a support link 1`] = ` +
+
+ +
+
+ Before proceeding, please unlink all social media accounts. +
+
+`; + +exports[`BeforeProceedingBanner should match the snapshot when SUPPORT_URL_TO_UNLINK_SOCIAL_MEDIA_ACCOUNT has a support link 1`] = ` +
+
+ +
+
+ Before proceeding, please + + unlink all social media accounts + + . +
+
+`;