diff --git a/src/common-components/RedirectLogistration.jsx b/src/common-components/RedirectLogistration.jsx
index f6c30b5015..24603f6a7d 100644
--- a/src/common-components/RedirectLogistration.jsx
+++ b/src/common-components/RedirectLogistration.jsx
@@ -5,7 +5,7 @@ import { Navigate } from 'react-router-dom';
import {
AUTHN_PROGRESSIVE_PROFILING, RECOMMENDATIONS, REDIRECT,
} from '../data/constants';
-import { setCookie } from '../data/utils';
+import setCookie from '../data/utils/cookies';
const RedirectLogistration = (props) => {
const {
diff --git a/src/common-components/tests/SocialAuthProviders.test.jsx b/src/common-components/tests/SocialAuthProviders.test.jsx
index ccc961576f..b1066a19b7 100644
--- a/src/common-components/tests/SocialAuthProviders.test.jsx
+++ b/src/common-components/tests/SocialAuthProviders.test.jsx
@@ -1,16 +1,35 @@
import React from 'react';
+import { Provider } from 'react-redux';
import { IntlProvider } from '@edx/frontend-platform/i18n';
import renderer from 'react-test-renderer';
+import configureStore from 'redux-mock-store';
import registerIcons from '../RegisterFaIcons';
import SocialAuthProviders from '../SocialAuthProviders';
registerIcons();
+const mockStore = configureStore();
describe('SocialAuthProviders', () => {
let props = {};
+ const initialState = {
+ register: {
+ registrationFormData: {
+ configurableFormFields: {
+ marketingEmailsOptIn: true,
+ },
+ },
+ },
+ };
+ const store = mockStore(initialState);
+ const reduxWrapper = children => (
+
+ {children}
+
+ );
+
const appleProvider = {
id: 'oa2-apple-id',
name: 'Apple',
@@ -27,20 +46,19 @@ describe('SocialAuthProviders', () => {
loginUrl: '/auth/login/facebook/?auth_entry=login&next=/dashboard',
};
- // Skipped tests will be fixed later.
- it.skip('should match social auth provider with iconImage snapshot', () => {
+ it('should match social auth provider with iconImage snapshot', () => {
props = { socialAuthProviders: [appleProvider, facebookProvider] };
- const tree = renderer.create(
+ const tree = renderer.create(reduxWrapper(
,
- ).toJSON();
+ )).toJSON();
expect(tree).toMatchSnapshot();
});
- it.skip('should match social auth provider with iconClass snapshot', () => {
+ it('should match social auth provider with iconClass snapshot', () => {
props = {
socialAuthProviders: [{
...appleProvider,
@@ -49,16 +67,16 @@ describe('SocialAuthProviders', () => {
}],
};
- const tree = renderer.create(
+ const tree = renderer.create(reduxWrapper(
,
- ).toJSON();
+ )).toJSON();
expect(tree).toMatchSnapshot();
});
- it.skip('should match social auth provider with default icon snapshot', () => {
+ it('should match social auth provider with default icon snapshot', () => {
props = {
socialAuthProviders: [{
...appleProvider,
@@ -67,11 +85,11 @@ describe('SocialAuthProviders', () => {
}],
};
- const tree = renderer.create(
+ const tree = renderer.create(reduxWrapper(
,
- ).toJSON();
+ )).toJSON();
expect(tree).toMatchSnapshot();
});
diff --git a/src/data/utils/cookies.js b/src/data/utils/cookies.js
index 1aad2858f0..cfddf5eca3 100644
--- a/src/data/utils/cookies.js
+++ b/src/data/utils/cookies.js
@@ -11,3 +11,11 @@ export default function setCookie(cookieName, cookieValue, cookieExpiry) {
cookies.set(cookieName, cookieValue, options);
}
}
+
+export function removeCookie(cookieName) {
+ if (cookieName) {
+ const cookies = new Cookies();
+ const options = { domain: getConfig().SESSION_COOKIE_DOMAIN, path: '/' };
+ cookies.remove(cookieName, options);
+ }
+}
diff --git a/src/data/utils/index.js b/src/data/utils/index.js
index 0553211148..1c9eebbb8a 100644
--- a/src/data/utils/index.js
+++ b/src/data/utils/index.js
@@ -8,4 +8,4 @@ export {
windowScrollTo,
} from './dataUtils';
export { default as AsyncActionType } from './reduxUtils';
-export { default as setCookie } from './cookies';
+export { default as setCookie, removeCookie } from './cookies';
diff --git a/src/register/RegistrationPage.jsx b/src/register/RegistrationPage.jsx
index 0a0a5b5306..50f689bf09 100644
--- a/src/register/RegistrationPage.jsx
+++ b/src/register/RegistrationPage.jsx
@@ -46,7 +46,7 @@ import {
APP_NAME, COMPLETE_STATE, PENDING_STATE, REGISTER_PAGE,
} from '../data/constants';
import {
- getAllPossibleQueryParams, getTpaHint, getTpaProvider, isHostAvailableInQueryParams, setCookie,
+ getAllPossibleQueryParams, getTpaHint, getTpaProvider, isHostAvailableInQueryParams, removeCookie, setCookie,
} from '../data/utils';
import { trackRegistrationPageViewed, trackRegistrationSuccess } from '../tracking/trackers/register';
@@ -187,6 +187,9 @@ const RegistrationPage = (props) => {
// This is used by the "User Retention Rate Event" on GTM
setCookie(getConfig().USER_RETENTION_COOKIE_NAME, true);
+
+ // remove marketingEmailsOptIn cookie that was set on SSO registration flow
+ removeCookie('marketingEmailsOptIn');
}
}, [registrationResult]);