From 6d510c24e5728dc062e16ad4594741cfb4f49690 Mon Sep 17 00:00:00 2001 From: Ben Date: Wed, 6 Jan 2021 09:59:02 -0500 Subject: [PATCH 01/22] Add tests for Welcome and success viwe --- .../__tests__/WelcomeView.test.jsx | 37 +++++++++++++++ .../__snapshots__/WelcomeView.test.jsx.snap | 32 +++++++++++++ .../__tests__/BlockSettingsView.test.jsx | 47 +++++++++++++++++++ .../__tests__/SuccessView.test.jsx | 34 ++++++++++++++ .../__snapshots__/SuccessView.test.jsx.snap | 29 ++++++++++++ 5 files changed, 179 insertions(+) create mode 100644 app/ghostery-browser-hub/Views/OnboardingViews/Step0_WelcomeView/__tests__/WelcomeView.test.jsx create mode 100644 app/ghostery-browser-hub/Views/OnboardingViews/Step0_WelcomeView/__tests__/__snapshots__/WelcomeView.test.jsx.snap create mode 100644 app/ghostery-browser-hub/Views/OnboardingViews/Step2_BlockSettingsView/__tests__/BlockSettingsView.test.jsx create mode 100644 app/ghostery-browser-hub/Views/OnboardingViews/Step5_SuccessView/__tests__/SuccessView.test.jsx create mode 100644 app/ghostery-browser-hub/Views/OnboardingViews/Step5_SuccessView/__tests__/__snapshots__/SuccessView.test.jsx.snap diff --git a/app/ghostery-browser-hub/Views/OnboardingViews/Step0_WelcomeView/__tests__/WelcomeView.test.jsx b/app/ghostery-browser-hub/Views/OnboardingViews/Step0_WelcomeView/__tests__/WelcomeView.test.jsx new file mode 100644 index 000000000..dc4de556a --- /dev/null +++ b/app/ghostery-browser-hub/Views/OnboardingViews/Step0_WelcomeView/__tests__/WelcomeView.test.jsx @@ -0,0 +1,37 @@ +/** + * Welcome View Test Component + * + * Ghostery Browser Extension + * https://www.ghostery.com/ + * + * Copyright 2020 Ghostery, Inc. All rights reserved. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0 + */ + +import React from 'react'; +import renderer from 'react-test-renderer'; +import { MemoryRouter } from 'react-router'; +import WelcomeView from '../WelcomeView'; + +const noop = () => {}; + +describe('app/ghostery-browser-hub/Views/OnboardingViews/Step0_WelcomeView/WelcomeView.test.jsx', () => { + describe('Snapshot tests with react-test-renderer', () => { + test('Welcome View is rendered correctly', () => { + const initialState = { + actions: { + setSetupStep: noop + } + }; + const component = renderer.create( + + + + ).toJSON(); + expect(component).toMatchSnapshot(); + }); + }); +}); diff --git a/app/ghostery-browser-hub/Views/OnboardingViews/Step0_WelcomeView/__tests__/__snapshots__/WelcomeView.test.jsx.snap b/app/ghostery-browser-hub/Views/OnboardingViews/Step0_WelcomeView/__tests__/__snapshots__/WelcomeView.test.jsx.snap new file mode 100644 index 000000000..6d26c9fcc --- /dev/null +++ b/app/ghostery-browser-hub/Views/OnboardingViews/Step0_WelcomeView/__tests__/__snapshots__/WelcomeView.test.jsx.snap @@ -0,0 +1,32 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`app/ghostery-browser-hub/Views/OnboardingViews/Step0_WelcomeView/WelcomeView.test.jsx Snapshot tests with react-test-renderer Welcome View is rendered correctly 1`] = ` +
+
+ ghostery_browser_hub_onboarding_welcome +
+
+ ghostery_browser_hub_onboarding_lets_begin +
+ + + + ghostery_browser_hub_onboarding_lets_do_this + + +
+`; diff --git a/app/ghostery-browser-hub/Views/OnboardingViews/Step2_BlockSettingsView/__tests__/BlockSettingsView.test.jsx b/app/ghostery-browser-hub/Views/OnboardingViews/Step2_BlockSettingsView/__tests__/BlockSettingsView.test.jsx new file mode 100644 index 000000000..ec5edaa2e --- /dev/null +++ b/app/ghostery-browser-hub/Views/OnboardingViews/Step2_BlockSettingsView/__tests__/BlockSettingsView.test.jsx @@ -0,0 +1,47 @@ +/** + * BlockSettings View Test Component + * + * Ghostery Browser Extension + * https://www.ghostery.com/ + * + * Copyright 2020 Ghostery, Inc. All rights reserved. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0 + */ + +import React from 'react'; +import renderer from 'react-test-renderer'; +import { MemoryRouter } from 'react-router'; +import BlockSettingsView from '../BlockSettingsView'; + +const noop = () => {}; + +describe('app/ghostery-browser-hub/Views/OnboardingViews/Step2_BlockSettingsView/BlockSettingsView.test.jsx', () => { + describe('Snapshot tests with react-test-renderer', () => { + test('BlockSettings View is rendered correctly', () => { + const initialState = { + recommendedChoices: false, + blockAds: null, + kindsOfTrackers: null, + antiTracking: null, + smartBrowsing: null, + actions: { + setAntiTracking: noop, + setAdBlock: noop, + setSmartBlocking: noop, + setBlockingPolicy: noop, + setToast: noop, + setSetupStep: noop, + } + }; + const component = renderer.create( + + + + ).toJSON(); + expect(component).toMatchSnapshot(); + }); + }); +}); diff --git a/app/ghostery-browser-hub/Views/OnboardingViews/Step5_SuccessView/__tests__/SuccessView.test.jsx b/app/ghostery-browser-hub/Views/OnboardingViews/Step5_SuccessView/__tests__/SuccessView.test.jsx new file mode 100644 index 000000000..c23c627fd --- /dev/null +++ b/app/ghostery-browser-hub/Views/OnboardingViews/Step5_SuccessView/__tests__/SuccessView.test.jsx @@ -0,0 +1,34 @@ +/** + * SuccessView View Test Component + * + * Ghostery Browser Extension + * https://www.ghostery.com/ + * + * Copyright 2020 Ghostery, Inc. All rights reserved. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0 + */ + +import React from 'react'; +import renderer from 'react-test-renderer'; +import SuccessView from '../SuccessView'; + +const noop = () => {}; + +describe('app/ghostery-browser-hub/Views/OnboardingViews/Step0_SuccessView/SuccessView.test.jsx', () => { + describe('Snapshot tests with react-test-renderer', () => { + test('Success View is rendered correctly', () => { + const initialState = { + actions: { + sendPing: noop + } + }; + const component = renderer.create( + + ).toJSON(); + expect(component).toMatchSnapshot(); + }); + }); +}); diff --git a/app/ghostery-browser-hub/Views/OnboardingViews/Step5_SuccessView/__tests__/__snapshots__/SuccessView.test.jsx.snap b/app/ghostery-browser-hub/Views/OnboardingViews/Step5_SuccessView/__tests__/__snapshots__/SuccessView.test.jsx.snap new file mode 100644 index 000000000..08240b227 --- /dev/null +++ b/app/ghostery-browser-hub/Views/OnboardingViews/Step5_SuccessView/__tests__/__snapshots__/SuccessView.test.jsx.snap @@ -0,0 +1,29 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`app/ghostery-browser-hub/Views/OnboardingViews/Step0_SuccessView/SuccessView.test.jsx Snapshot tests with react-test-renderer Welcome View is rendered correctly 1`] = ` +
+
+ ghostery_browser_hub_onboarding_youve_successfully_set_up_your_browser +
+
+ ghostery_browser_hub_onboarding_surf_with_ease +
+ + +
+`; From bcd6150e726e8bd421155e2c9458e3e3ef6c4c2b Mon Sep 17 00:00:00 2001 From: Ben Date: Sat, 9 Jan 2021 20:25:17 -0500 Subject: [PATCH 02/22] Add tests for Welcome, Success, BlockSettingsView and ChoosePlanView --- .../Step1_CreateAccountView.jsx | 2 +- .../__tests__/BlockSettingsView.test.jsx | 48 ++- .../BlockSettingsView.test.jsx.snap | 324 +++++++++++++++ .../Step4_ChoosePlanView/ChoosePlanView.jsx | 12 +- .../__tests__/ChoosePlanView.test.jsx | 122 ++++++ .../ChoosePlanView.test.jsx.snap | 387 ++++++++++++++++++ .../Step5_SuccessView/SuccessView.jsx | 2 +- .../__tests__/SuccessView.test.jsx | 5 +- .../__snapshots__/SuccessView.test.jsx.snap | 68 ++- .../SetupAntiSuiteView.test.jsx.snap | 4 +- .../SetupBlockingDropdown.test.jsx.snap | 2 +- .../SetupBlockingView.test.jsx.snap | 4 +- .../__snapshots__/SetupDoneView.test.jsx.snap | 2 +- .../__snapshots__/SetupHeader.test.jsx.snap | 2 +- .../SetupHumanWebView.test.jsx.snap | 2 +- .../BuildingBlocks/__tests__/PauseButton.jsx | 2 +- 16 files changed, 940 insertions(+), 48 deletions(-) create mode 100644 app/ghostery-browser-hub/Views/OnboardingViews/Step2_BlockSettingsView/__tests__/__snapshots__/BlockSettingsView.test.jsx.snap create mode 100644 app/ghostery-browser-hub/Views/OnboardingViews/Step4_ChoosePlanView/__tests__/ChoosePlanView.test.jsx create mode 100644 app/ghostery-browser-hub/Views/OnboardingViews/Step4_ChoosePlanView/__tests__/__snapshots__/ChoosePlanView.test.jsx.snap diff --git a/app/ghostery-browser-hub/Views/OnboardingViews/Step1_CreateAccountView/Step1_CreateAccountView.jsx b/app/ghostery-browser-hub/Views/OnboardingViews/Step1_CreateAccountView/Step1_CreateAccountView.jsx index 1f8044c43..6d7bca870 100644 --- a/app/ghostery-browser-hub/Views/OnboardingViews/Step1_CreateAccountView/Step1_CreateAccountView.jsx +++ b/app/ghostery-browser-hub/Views/OnboardingViews/Step1_CreateAccountView/Step1_CreateAccountView.jsx @@ -162,4 +162,4 @@ Step1_CreateAccountView.defaultProps = { }, }; -export default Step1_CreateAccountView; +export default Step1_CreateAccountForm; diff --git a/app/ghostery-browser-hub/Views/OnboardingViews/Step2_BlockSettingsView/__tests__/BlockSettingsView.test.jsx b/app/ghostery-browser-hub/Views/OnboardingViews/Step2_BlockSettingsView/__tests__/BlockSettingsView.test.jsx index ec5edaa2e..b17b34c1e 100644 --- a/app/ghostery-browser-hub/Views/OnboardingViews/Step2_BlockSettingsView/__tests__/BlockSettingsView.test.jsx +++ b/app/ghostery-browser-hub/Views/OnboardingViews/Step2_BlockSettingsView/__tests__/BlockSettingsView.test.jsx @@ -13,20 +13,17 @@ import React from 'react'; import renderer from 'react-test-renderer'; +import { shallow } from 'enzyme'; import { MemoryRouter } from 'react-router'; import BlockSettingsView from '../BlockSettingsView'; const noop = () => {}; +jest.mock('../../../../../shared-components/Tooltip'); describe('app/ghostery-browser-hub/Views/OnboardingViews/Step2_BlockSettingsView/BlockSettingsView.test.jsx', () => { describe('Snapshot tests with react-test-renderer', () => { test('BlockSettings View is rendered correctly', () => { const initialState = { - recommendedChoices: false, - blockAds: null, - kindsOfTrackers: null, - antiTracking: null, - smartBrowsing: null, actions: { setAntiTracking: noop, setAdBlock: noop, @@ -44,4 +41,45 @@ describe('app/ghostery-browser-hub/Views/OnboardingViews/Step2_BlockSettingsView expect(component).toMatchSnapshot(); }); }); + + describe('Shallow snapshot tests rendered with Enzyme', () => { + test('BlockSettings View happy path', () => { + const initialState = { + actions: { + setAntiTracking: jest.fn(), + setAdBlock: jest.fn(), + setSmartBlocking: jest.fn(), + setBlockingPolicy: jest.fn(), + setToast: noop, + setSetupStep: jest.fn(), + }, + history: { + push: noop + } + }; + const component = shallow(); + expect(component.find('.BlockSettingsView_checkbox').length).toBe(1); + expect(component.find('.BlockSettingsView__radioButtonContainer').length).toBe(9); + + const instance = component.instance(); + + instance.toggleRecommendedChoices(true); + expect(component.state('blockAds')).toBe(true); + expect(component.state('kindsOfTrackers')).toBe(1); + expect(component.state('antiTracking')).toBe(true); + expect(component.state('smartBrowsing')).toBe(true); + + instance.handleAnswerChange('blockAds', false); + expect(component.state('blockAds')).toBe(false); + + instance.handleSubmit(); + expect(initialState.actions.setAntiTracking.mock.calls.length).toBe(1); + expect(initialState.actions.setAdBlock.mock.calls.length).toBe(1); + expect(initialState.actions.setSmartBlocking.mock.calls.length).toBe(1); + expect(initialState.actions.setBlockingPolicy.mock.calls.length).toBe(1); + expect(initialState.actions.setSetupStep.mock.calls.length).toBe(1); + + expect(component).toMatchSnapshot(); + }); + }); }); diff --git a/app/ghostery-browser-hub/Views/OnboardingViews/Step2_BlockSettingsView/__tests__/__snapshots__/BlockSettingsView.test.jsx.snap b/app/ghostery-browser-hub/Views/OnboardingViews/Step2_BlockSettingsView/__tests__/__snapshots__/BlockSettingsView.test.jsx.snap new file mode 100644 index 000000000..e4753d50d --- /dev/null +++ b/app/ghostery-browser-hub/Views/OnboardingViews/Step2_BlockSettingsView/__tests__/__snapshots__/BlockSettingsView.test.jsx.snap @@ -0,0 +1,324 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`app/ghostery-browser-hub/Views/OnboardingViews/Step2_BlockSettingsView/BlockSettingsView.test.jsx Shallow snapshot tests rendered with Enzyme BlockSettings View happy path 1`] = `ShallowWrapper {}`; + +exports[`app/ghostery-browser-hub/Views/OnboardingViews/Step2_BlockSettingsView/BlockSettingsView.test.jsx Snapshot tests with react-test-renderer BlockSettings View is rendered correctly 1`] = ` +Array [ +
+ +
, +
+
+ ghostery_browser_hub_onboarding_which_privacy_plan +
+
+ ghostery_browser_hub_onboarding_tell_us_your_preferences +
+
+
+
+ + + +
+
+ ghostery_browser_hub_onboarding_recommended_choices +
+
+
    +
  1. + ghostery_browser_hub_onboarding_question_block_ads +
  2. +
    +
    + + + + + +
    +
    + hub_setup_modal_button_yes +
    +
    +
    +
    + + + + + +
    +
    + hub_setup_modal_button_no +
    +
    +
  3. +
    + ghostery_browser_hub_onboarding_question_kinds_of_trackers +
    +
    +
    +
    + + + + + +
    +
    + ghostery_browser_hub_onboarding_kinds_of_trackers_all +
    +
    +
    +
    + + + + + +
    +
    + ghostery_browser_hub_onboarding_kinds_of_trackers_ad_and_analytics +
    +
    +
    +
    + + + + + +
    +
    + ghostery_browser_hub_onboarding_kinds_of_trackers_none +
    +
    +
  4. +
    + ghostery_browser_hub_onboarding_question_anti_tracking +
    +
    +
  5. +
    +
    + + + + + +
    +
    + hub_setup_modal_button_yes +
    +
    +
    +
    + + + + + +
    +
    + hub_setup_modal_button_no +
    +
    +
  6. +
    + ghostery_browser_hub_onboarding_question_smart_browsing +
    +
    +
  7. +
    +
    + + + + + +
    +
    + hub_setup_modal_button_yes +
    +
    +
    +
    + + + + + +
    +
    + hub_setup_modal_button_no +
    +
    + +
+
+ +
, +] +`; diff --git a/app/ghostery-browser-hub/Views/OnboardingViews/Step4_ChoosePlanView/ChoosePlanView.jsx b/app/ghostery-browser-hub/Views/OnboardingViews/Step4_ChoosePlanView/ChoosePlanView.jsx index 71ac9b443..0f5dd7d99 100644 --- a/app/ghostery-browser-hub/Views/OnboardingViews/Step4_ChoosePlanView/ChoosePlanView.jsx +++ b/app/ghostery-browser-hub/Views/OnboardingViews/Step4_ChoosePlanView/ChoosePlanView.jsx @@ -284,7 +284,7 @@ class ChoosePlanView extends React.Component { const { setSetupStep } = actions; const { expanded, selectedPlan } = this.state; - const isBasic = !user; + const isBasic = !user || (user && !user.plusAccess && !user.premiumAccess); const isPlus = (user && user.plusAccess && !user.premiumAccess) || false; const isPremium = (user && user.premiumAccess) || false; @@ -294,7 +294,7 @@ class ChoosePlanView extends React.Component { }); return ( - +
@@ -304,17 +304,11 @@ class ChoosePlanView extends React.Component {
-
{this.renderTitleText()}
{this.renderSubtitleText(didNotSelectGhosterySearch)}
{didNotSelectGhosterySearch && isBasic && ( {searchPromo()} - {/* TODO: For the CTA button below, - 1. If user is signed in, activate the user’s 7-day free trial for the Ghostery Search Plus plan - and move them to Step 5 if signed in - 2. If user is signed out, clicking this should take them to Step 4b (linked) - */}
{t('ghostery_browser_hub_onboarding_start_trial')}
{t('ghostery_browser_hub_onboarding_see_all_plans')}
@@ -368,7 +362,7 @@ class ChoosePlanView extends React.Component {
)}
- +
); } } diff --git a/app/ghostery-browser-hub/Views/OnboardingViews/Step4_ChoosePlanView/__tests__/ChoosePlanView.test.jsx b/app/ghostery-browser-hub/Views/OnboardingViews/Step4_ChoosePlanView/__tests__/ChoosePlanView.test.jsx new file mode 100644 index 000000000..d468f183b --- /dev/null +++ b/app/ghostery-browser-hub/Views/OnboardingViews/Step4_ChoosePlanView/__tests__/ChoosePlanView.test.jsx @@ -0,0 +1,122 @@ +/** + * ChoosePlanView Test Component + * + * Ghostery Browser Extension + * https://www.ghostery.com/ + * + * Copyright 2020 Ghostery, Inc. All rights reserved. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0 + */ + +import React from 'react'; +import renderer from 'react-test-renderer'; +import { shallow } from 'enzyme'; +import { MemoryRouter } from 'react-router'; +import ChoosePlanView from '../ChoosePlanView'; + +const noop = () => {}; + +describe('app/ghostery-browser-hub/Views/OnboardingViews/Step4_ChoosePlanView/ChoosePlanView.test.jsx', () => { + describe('Snapshot tests with react-test-renderer', () => { + test('ChoosePlanView is rendered correctly', () => { + const initialState = { + user: null, + didNotSelectGhosterySearch: false, + actions: { + setSetupStep: noop + } + }; + const component = renderer.create( + + + + ).toJSON(); + expect(component).toMatchSnapshot(); + }); + }); + + describe('Shallow snapshot tests rendered with Enzyme', () => { + test('ChoosePlanView View with user not logged in', () => { + const initialState = { + user: null, + didNotSelectGhosterySearch: false, + actions: { + setSetupStep: noop + }, + }; + + const component = shallow(); + + expect(component.find('.ChoosePlanView__card').length).toBe(3); + const instance = component.instance(); + + instance.selectBasicPlan(); + expect(component.state('selectedPlan')).toBe('BASIC'); + + instance.selectPlusPlan(); + expect(component.state('selectedPlan')).toBe('PLUS'); + + instance.selectPremiumPlan(); + expect(component.state('selectedPlan')).toBe('PREMIUM'); + + expect(component).toMatchSnapshot(); + }); + + test('ChoosePlanView View with basic user logged in', () => { + const initialState = { + user: { + plusAccess: false, + premiumAccess: false + }, + didNotSelectGhosterySearch: false, + actions: { + setSetupStep: noop + }, + }; + + const component = shallow(); + + expect(component.find('.ChoosePlanView__card').length).toBe(3); + expect(component).toMatchSnapshot(); + }); + + test('ChoosePlanView View with plus user logged in', () => { + const initialState = { + user: { + plusAccess: true, + premiumAccess: false + }, + didNotSelectGhosterySearch: false, + actions: { + setSetupStep: noop + }, + }; + + const component = shallow(); + + expect(component.find('.ChoosePlanView__card').length).toBe(2); + expect(component).toMatchSnapshot(); + }); + + test('ChoosePlanView View with premium user logged in', () => { + const initialState = { + user: { + plusAccess: true, + premiumAccess: true + }, + didNotSelectGhosterySearch: false, + actions: { + setSetupStep: noop + }, + }; + + const component = shallow(); + + expect(component.find('.ChoosePlanView__card').length).toBe(1); + expect(component).toMatchSnapshot(); + }); + }); +}); diff --git a/app/ghostery-browser-hub/Views/OnboardingViews/Step4_ChoosePlanView/__tests__/__snapshots__/ChoosePlanView.test.jsx.snap b/app/ghostery-browser-hub/Views/OnboardingViews/Step4_ChoosePlanView/__tests__/__snapshots__/ChoosePlanView.test.jsx.snap new file mode 100644 index 000000000..28e39c2ea --- /dev/null +++ b/app/ghostery-browser-hub/Views/OnboardingViews/Step4_ChoosePlanView/__tests__/__snapshots__/ChoosePlanView.test.jsx.snap @@ -0,0 +1,387 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`app/ghostery-browser-hub/Views/OnboardingViews/Step4_ChoosePlanView/ChoosePlanView.test.jsx Shallow snapshot tests rendered with Enzyme ChoosePlanView View with basic user logged in 1`] = `ShallowWrapper {}`; + +exports[`app/ghostery-browser-hub/Views/OnboardingViews/Step4_ChoosePlanView/ChoosePlanView.test.jsx Shallow snapshot tests rendered with Enzyme ChoosePlanView View with plus user logged in 1`] = `ShallowWrapper {}`; + +exports[`app/ghostery-browser-hub/Views/OnboardingViews/Step4_ChoosePlanView/ChoosePlanView.test.jsx Shallow snapshot tests rendered with Enzyme ChoosePlanView View with premium user logged in 1`] = `ShallowWrapper {}`; + +exports[`app/ghostery-browser-hub/Views/OnboardingViews/Step4_ChoosePlanView/ChoosePlanView.test.jsx Shallow snapshot tests rendered with Enzyme ChoosePlanView View with user not logged in 1`] = `ShallowWrapper {}`; + +exports[`app/ghostery-browser-hub/Views/OnboardingViews/Step4_ChoosePlanView/ChoosePlanView.test.jsx Snapshot tests with react-test-renderer ChoosePlanView is rendered correctly 1`] = ` +
+ +
+
+ ghostery_browser_hub_onboarding_your_privacy_plan +
+
+ ghostery_browser_hub_onboarding_choose_an_option +
+
+
+
+
+
+ + + + + +
+
+
+
+
+

+ Ghostery +

+
+

+ hub_upgrade_plan_free +

+
+

+ + hub_upgrade_basic_protection + +

+
+
+ + ghostery_browser_hub_onboarding_private_search +
+
+ + ghostery_browser_hub_onboarding_tracker_protection +
+
+ + ghostery_browser_hub_onboarding_speedy_page_loads +
+
+ + ghostery_browser_hub_onboarding_intelligence_technology +
+
+
+
+
+
+
+ + + + + +
+
+
+
+

+ Ghostery Plus +

+
+

+ $4.99 +

+

+ per_month +

+
+

+ + hub_upgrade_additional_protection + +

+
+
+ + ghostery_browser_hub_onboarding_private_search +
+
+ + ghostery_browser_hub_onboarding_tracker_protection +
+
+ + ghostery_browser_hub_onboarding_speedy_page_loads +
+
+ + ghostery_browser_hub_onboarding_intelligence_technology +
+
+ + ghostery_browser_hub_onboarding_ad_free +
+
+ + ghostery_browser_hub_onboarding_supports_ghosterys_mission +
+
+
+
+
+
+
+ + + + + +
+
+
+
+
+

+ Ghostery Premium +

+
+

+ $11.99 +

+

+ per_month +

+
+

+ + hub_upgrade_maximum_protection + +

+
+
+ + ghostery_browser_hub_onboarding_private_search +
+
+ + ghostery_browser_hub_onboarding_tracker_protection +
+
+ + ghostery_browser_hub_onboarding_speedy_page_loads +
+
+ + ghostery_browser_hub_onboarding_intelligence_technology +
+
+ + ghostery_browser_hub_onboarding_ad_free +
+
+ + ghostery_browser_hub_onboarding_supports_ghosterys_mission +
+
+ + VPN +
+
+ + ghostery_browser_hub_onboarding_unlimited_bandwidth +
+
+
+
+
+
+
+
+
+`; diff --git a/app/ghostery-browser-hub/Views/OnboardingViews/Step5_SuccessView/SuccessView.jsx b/app/ghostery-browser-hub/Views/OnboardingViews/Step5_SuccessView/SuccessView.jsx index e4ae3351e..4ba81590c 100644 --- a/app/ghostery-browser-hub/Views/OnboardingViews/Step5_SuccessView/SuccessView.jsx +++ b/app/ghostery-browser-hub/Views/OnboardingViews/Step5_SuccessView/SuccessView.jsx @@ -37,7 +37,7 @@ const SuccessView = (props) => {
{`${t('ghostery_browser_hub_onboarding_surf_with_ease')} Ghostery`}
- +
); diff --git a/app/ghostery-browser-hub/Views/OnboardingViews/Step5_SuccessView/__tests__/SuccessView.test.jsx b/app/ghostery-browser-hub/Views/OnboardingViews/Step5_SuccessView/__tests__/SuccessView.test.jsx index c23c627fd..0c835375b 100644 --- a/app/ghostery-browser-hub/Views/OnboardingViews/Step5_SuccessView/__tests__/SuccessView.test.jsx +++ b/app/ghostery-browser-hub/Views/OnboardingViews/Step5_SuccessView/__tests__/SuccessView.test.jsx @@ -13,6 +13,7 @@ import React from 'react'; import renderer from 'react-test-renderer'; +import { MemoryRouter } from 'react-router'; import SuccessView from '../SuccessView'; const noop = () => {}; @@ -26,7 +27,9 @@ describe('app/ghostery-browser-hub/Views/OnboardingViews/Step0_SuccessView/Succe } }; const component = renderer.create( - + + + ).toJSON(); expect(component).toMatchSnapshot(); }); diff --git a/app/ghostery-browser-hub/Views/OnboardingViews/Step5_SuccessView/__tests__/__snapshots__/SuccessView.test.jsx.snap b/app/ghostery-browser-hub/Views/OnboardingViews/Step5_SuccessView/__tests__/__snapshots__/SuccessView.test.jsx.snap index 08240b227..1fc14b63e 100644 --- a/app/ghostery-browser-hub/Views/OnboardingViews/Step5_SuccessView/__tests__/__snapshots__/SuccessView.test.jsx.snap +++ b/app/ghostery-browser-hub/Views/OnboardingViews/Step5_SuccessView/__tests__/__snapshots__/SuccessView.test.jsx.snap @@ -1,29 +1,53 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`app/ghostery-browser-hub/Views/OnboardingViews/Step0_SuccessView/SuccessView.test.jsx Snapshot tests with react-test-renderer Welcome View is rendered correctly 1`] = ` -
+exports[`app/ghostery-browser-hub/Views/OnboardingViews/Step0_SuccessView/SuccessView.test.jsx Snapshot tests with react-test-renderer Success View is rendered correctly 1`] = ` +Array [
- ghostery_browser_hub_onboarding_youve_successfully_set_up_your_browser -
+ +
,
- ghostery_browser_hub_onboarding_surf_with_ease -
- - -
+
+ ghostery_browser_hub_onboarding_youve_successfully_set_up_your_browser +
+
+ ghostery_browser_hub_onboarding_surf_with_ease Ghostery +
+ + +
, +] `; diff --git a/app/hub/Views/SetupViews/SetupAntiSuiteView/__tests__/__snapshots__/SetupAntiSuiteView.test.jsx.snap b/app/hub/Views/SetupViews/SetupAntiSuiteView/__tests__/__snapshots__/SetupAntiSuiteView.test.jsx.snap index ae5d25fe6..38e132141 100644 --- a/app/hub/Views/SetupViews/SetupAntiSuiteView/__tests__/__snapshots__/SetupAntiSuiteView.test.jsx.snap +++ b/app/hub/Views/SetupViews/SetupAntiSuiteView/__tests__/__snapshots__/SetupAntiSuiteView.test.jsx.snap @@ -1,6 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`app/hub/Views/SetupViews/SetupAntiSuiteView component More Snapshot tests with react-test-renderer, but for edge cases edge case where features is an empty array 1`] = ` +exports[`app/hub/Views/OnboardingViews/SetupAntiSuiteView component More Snapshot tests with react-test-renderer, but for edge cases edge case where features is an empty array 1`] = `
@@ -10,7 +10,7 @@ exports[`app/hub/Views/SetupViews/SetupAntiSuiteView component More Snapshot tes
`; -exports[`app/hub/Views/SetupViews/SetupAntiSuiteView component Snapshot tests with react-test-renderer setup anti-suite view is rendered correctly 1`] = ` +exports[`app/hub/Views/OnboardingViews/SetupAntiSuiteView component Snapshot tests with react-test-renderer setup anti-suite view is rendered correctly 1`] = `
diff --git a/app/hub/Views/SetupViews/SetupBlockingDropdown/__tests__/__snapshots__/SetupBlockingDropdown.test.jsx.snap b/app/hub/Views/SetupViews/SetupBlockingDropdown/__tests__/__snapshots__/SetupBlockingDropdown.test.jsx.snap index 1bbb9a35c..48144a180 100644 --- a/app/hub/Views/SetupViews/SetupBlockingDropdown/__tests__/__snapshots__/SetupBlockingDropdown.test.jsx.snap +++ b/app/hub/Views/SetupViews/SetupBlockingDropdown/__tests__/__snapshots__/SetupBlockingDropdown.test.jsx.snap @@ -1,6 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`app/hub/Views/SetupViews/SetupBlockingDropdown component Snapshot tests with react-test-renderer setup blocking dropdown component is rendered correctly 1`] = ` +exports[`app/hub/Views/OnboardingViews/SetupBlockingDropdown component Snapshot tests with react-test-renderer setup blocking dropdown component is rendered correctly 1`] = `
diff --git a/app/hub/Views/SetupViews/SetupBlockingView/__tests__/__snapshots__/SetupBlockingView.test.jsx.snap b/app/hub/Views/SetupViews/SetupBlockingView/__tests__/__snapshots__/SetupBlockingView.test.jsx.snap index 10bd7022a..c6059f7a7 100644 --- a/app/hub/Views/SetupViews/SetupBlockingView/__tests__/__snapshots__/SetupBlockingView.test.jsx.snap +++ b/app/hub/Views/SetupViews/SetupBlockingView/__tests__/__snapshots__/SetupBlockingView.test.jsx.snap @@ -1,6 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`app/hub/Views/SetupViews/SetupBlockingView component More Snapshot tests with react-test-renderer, but for edge cases edge case where choices is an empty array 1`] = ` +exports[`app/hub/Views/OnboardingViews/SetupBlockingView component More Snapshot tests with react-test-renderer, but for edge cases edge case where choices is an empty array 1`] = `
@@ -18,7 +18,7 @@ exports[`app/hub/Views/SetupViews/SetupBlockingView component More Snapshot test
`; -exports[`app/hub/Views/SetupViews/SetupBlockingView component Snapshot tests with react-test-renderer setup blocking view is rendered correctly 1`] = ` +exports[`app/hub/Views/OnboardingViews/SetupBlockingView component Snapshot tests with react-test-renderer setup blocking view is rendered correctly 1`] = `
diff --git a/app/hub/Views/SetupViews/SetupDoneView/__tests__/__snapshots__/SetupDoneView.test.jsx.snap b/app/hub/Views/SetupViews/SetupDoneView/__tests__/__snapshots__/SetupDoneView.test.jsx.snap index 6509da93e..30f6e540b 100644 --- a/app/hub/Views/SetupViews/SetupDoneView/__tests__/__snapshots__/SetupDoneView.test.jsx.snap +++ b/app/hub/Views/SetupViews/SetupDoneView/__tests__/__snapshots__/SetupDoneView.test.jsx.snap @@ -1,6 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`app/hub/Views/SetupViews/SetupDoneView component Snapshot tests with react-test-renderer setup human web view is rendered correctly 1`] = ` +exports[`app/hub/Views/OnboardingViews/SetupDoneView component Snapshot tests with react-test-renderer setup human web view is rendered correctly 1`] = `
diff --git a/app/hub/Views/SetupViews/SetupHeader/__tests__/__snapshots__/SetupHeader.test.jsx.snap b/app/hub/Views/SetupViews/SetupHeader/__tests__/__snapshots__/SetupHeader.test.jsx.snap index 8b72c56c1..86061f3b4 100644 --- a/app/hub/Views/SetupViews/SetupHeader/__tests__/__snapshots__/SetupHeader.test.jsx.snap +++ b/app/hub/Views/SetupViews/SetupHeader/__tests__/__snapshots__/SetupHeader.test.jsx.snap @@ -1,6 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`app/hub/Views/SetupViews/SetupHeader component Snapshot tests with react-test-renderer setup header is rendered correctly 1`] = ` +exports[`app/hub/Views/OnboardingViews/SetupHeader component Snapshot tests with react-test-renderer setup header is rendered correctly 1`] = `
diff --git a/app/hub/Views/SetupViews/SetupHumanWebView/__tests__/__snapshots__/SetupHumanWebView.test.jsx.snap b/app/hub/Views/SetupViews/SetupHumanWebView/__tests__/__snapshots__/SetupHumanWebView.test.jsx.snap index a6ad2f881..6b94ff87b 100644 --- a/app/hub/Views/SetupViews/SetupHumanWebView/__tests__/__snapshots__/SetupHumanWebView.test.jsx.snap +++ b/app/hub/Views/SetupViews/SetupHumanWebView/__tests__/__snapshots__/SetupHumanWebView.test.jsx.snap @@ -1,6 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`app/hub/Views/SetupViews/SetupHumanWebView component Snapshot tests with react-test-renderer setup human web view is rendered correctly 1`] = ` +exports[`app/hub/Views/OnboardingViews/SetupHumanWebView component Snapshot tests with react-test-renderer setup human web view is rendered correctly 1`] = `
diff --git a/app/panel/components/BuildingBlocks/__tests__/PauseButton.jsx b/app/panel/components/BuildingBlocks/__tests__/PauseButton.jsx index 37ba604ee..6855ad663 100644 --- a/app/panel/components/BuildingBlocks/__tests__/PauseButton.jsx +++ b/app/panel/components/BuildingBlocks/__tests__/PauseButton.jsx @@ -22,7 +22,7 @@ global.t = function(str) { }; // Fake the Tooltip implementation -jest.mock('../../Tooltip'); +jest.mock('../../../../shared-components/Tooltip'); describe('app/panel/components/BuildingBlocks/PauseButton.jsx', () => { describe('Snapshot tests with react-test-renderer', () => { From 6960ff44a33033dd22935c9a4c8cfcfe621032c4 Mon Sep 17 00:00:00 2001 From: Ben Date: Sat, 9 Jan 2021 21:08:48 -0500 Subject: [PATCH 03/22] Add tests for Step1_CreateAccountForm --- .../Step1_CreateAccountForm.jsx | 2 +- .../Step1_CreateAccountForm.test.jsx | 116 ++++++++++ .../Step1_CreateAccountForm.test.jsx.snap | 203 ++++++++++++++++++ .../__snapshots__/SuccessView.test.jsx.snap | 2 +- 4 files changed, 321 insertions(+), 2 deletions(-) create mode 100644 app/ghostery-browser-hub/Views/OnboardingViews/Step1_CreateAccountForm/__tests__/Step1_CreateAccountForm.test.jsx create mode 100644 app/ghostery-browser-hub/Views/OnboardingViews/Step1_CreateAccountForm/__tests__/__snapshots__/Step1_CreateAccountForm.test.jsx.snap diff --git a/app/ghostery-browser-hub/Views/OnboardingViews/Step1_CreateAccountForm/Step1_CreateAccountForm.jsx b/app/ghostery-browser-hub/Views/OnboardingViews/Step1_CreateAccountForm/Step1_CreateAccountForm.jsx index 33c96999c..567bb6243 100644 --- a/app/ghostery-browser-hub/Views/OnboardingViews/Step1_CreateAccountForm/Step1_CreateAccountForm.jsx +++ b/app/ghostery-browser-hub/Views/OnboardingViews/Step1_CreateAccountForm/Step1_CreateAccountForm.jsx @@ -23,7 +23,7 @@ const promoString = `${t('ghostery_browser_hub_onboarding_send_me')} Ghostery ${ * @return {JSX} JSX for rendering the Browser Create Account View of the Hub app * @memberof GhosteryBrowserHubViews */ -const Step1_CreateAccountForm = (props) => { +export const Step1_CreateAccountForm = (props) => { const { email, emailError, diff --git a/app/ghostery-browser-hub/Views/OnboardingViews/Step1_CreateAccountForm/__tests__/Step1_CreateAccountForm.test.jsx b/app/ghostery-browser-hub/Views/OnboardingViews/Step1_CreateAccountForm/__tests__/Step1_CreateAccountForm.test.jsx new file mode 100644 index 000000000..df7ac60bd --- /dev/null +++ b/app/ghostery-browser-hub/Views/OnboardingViews/Step1_CreateAccountForm/__tests__/Step1_CreateAccountForm.test.jsx @@ -0,0 +1,116 @@ +/** + * Create Account View Test Component + * + * Ghostery Browser Extension + * https://www.ghostery.com/ + * + * Copyright 2019 Ghostery, Inc. All rights reserved. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0 + */ + +import React from 'react'; +import renderer from 'react-test-renderer'; +import { shallow } from 'enzyme'; +import { MemoryRouter } from 'react-router'; +import { Step1_CreateAccountForm } from '../Step1_CreateAccountForm'; + + +jest.mock('../../../../../shared-components/ToggleCheckbox', () => { + const ToggleCheckbox = () =>
; + return ToggleCheckbox; +}); + +const noop = () => {}; +describe('app/hub/Views/Step1_CreateAccountForm component', () => { + describe('Snapshot tests with react-test-renderer', () => { + test('create account view is rendered correctly', () => { + const initialState = { + email: 'test@example.com', + emailError: false, + confirmEmail: 'test@example.com', + confirmEmailError: false, + firstName: 'First', + lastName: 'Last', + isUpdatesChecked: true, + legalConsentChecked: true, + password: '', + confirmPassword: '', + passwordInvalidError: false, + passwordLengthError: false, + handleInputChange: noop, + handleUpdatesCheckboxChange: noop, + handleLegalConsentCheckboxChange: noop, + handleSubmit: jest.fn(), + }; + + const component = renderer.create( + + + + ).toJSON(); + expect(component).toMatchSnapshot(); + }); + }); + + describe('Shallow snapshot tests rendered with Enzyme', () => { + test('the happy path of the component', () => { + const initialState = { + email: 'test@example.com', + emailError: false, + confirmEmail: 'test@example.com', + confirmEmailError: false, + firstName: 'First', + lastName: 'Last', + isUpdatesChecked: true, + legalConsentChecked: true, + password: '', + confirmPassword: '', + passwordInvalidError: false, + passwordLengthError: false, + handleInputChange: noop, + handleUpdatesCheckboxChange: noop, + handleLegalConsentCheckboxChange: noop, + handleSubmit: jest.fn(), + }; + + const component = shallow(); + + expect(component.find('.Step1_CreateAccountForm__inputBox').length).toBe(6); + expect(component.find('.Step1_CreateAccountForm__ctaButton').length).toBe(1); + + expect(initialState.handleSubmit.mock.calls.length).toBe(0); + component.find('form').simulate('submit'); + expect(initialState.handleSubmit.mock.calls.length).toBe(1); + }); + + test('the sad path of the component with errors', () => { + const initialState = { + email: 'test@example.com', + emailError: true, + confirmEmail: 'badConfirmEmail@example.com', + confirmEmailError: true, + firstName: 'First', + lastName: 'Last', + isUpdatesChecked: false, + legalConsentChecked: false, + password: 'password', + confirmPassword: 'badPassword', + passwordInvalidError: true, + passwordLengthError: true, + handleInputChange: noop, + handleUpdatesCheckboxChange: noop, + handleLegalConsentCheckboxChange: noop, + handleSubmit: jest.fn(), + }; + + const component = shallow(); + component.find('form').simulate('submit'); + expect(component.find('.Step1_CreateAccountForm__inputErrorContainer').length).toBe(4); + expect(component).toMatchSnapshot(); + + }); + }); +}); diff --git a/app/ghostery-browser-hub/Views/OnboardingViews/Step1_CreateAccountForm/__tests__/__snapshots__/Step1_CreateAccountForm.test.jsx.snap b/app/ghostery-browser-hub/Views/OnboardingViews/Step1_CreateAccountForm/__tests__/__snapshots__/Step1_CreateAccountForm.test.jsx.snap new file mode 100644 index 000000000..a03bbdbf6 --- /dev/null +++ b/app/ghostery-browser-hub/Views/OnboardingViews/Step1_CreateAccountForm/__tests__/__snapshots__/Step1_CreateAccountForm.test.jsx.snap @@ -0,0 +1,203 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`app/hub/Views/Step1_CreateAccountForm component Shallow snapshot tests rendered with Enzyme the sad path of the component with errors 1`] = `ShallowWrapper {}`; + +exports[`app/hub/Views/Step1_CreateAccountForm component Snapshot tests with react-test-renderer create account view is rendered correctly 1`] = ` +
+
+
+ + +
+
+ + +
+
+
+
+ + +
+
+ + +
+
+
+
+ + +
+
+ + +
+
+
+
+
+
+ +
+
+
+
+
+
+
+
+ +
+
+
+
+
+ +
+ +`; diff --git a/app/ghostery-browser-hub/Views/OnboardingViews/Step5_SuccessView/__tests__/__snapshots__/SuccessView.test.jsx.snap b/app/ghostery-browser-hub/Views/OnboardingViews/Step5_SuccessView/__tests__/__snapshots__/SuccessView.test.jsx.snap index 1fc14b63e..6508140e8 100644 --- a/app/ghostery-browser-hub/Views/OnboardingViews/Step5_SuccessView/__tests__/__snapshots__/SuccessView.test.jsx.snap +++ b/app/ghostery-browser-hub/Views/OnboardingViews/Step5_SuccessView/__tests__/__snapshots__/SuccessView.test.jsx.snap @@ -46,7 +46,7 @@ Array [ onClick={[Function]} type="button" > - ghostery_browser_hub_onboarding_lets_search + ghostery_browser_hub_onboarding_start_browsing
, ] From 0872b0d058f7c7c1be5abdec22589c458104ce90 Mon Sep 17 00:00:00 2001 From: Ben Date: Sat, 9 Jan 2021 21:21:26 -0500 Subject: [PATCH 04/22] Add tests for Step1_LoginForm --- .../__tests__/Step1_LoginForm.test.jsx | 86 +++++++++++++++++++ .../Step1_LoginForm.test.jsx.snap | 85 ++++++++++++++++++ 2 files changed, 171 insertions(+) create mode 100644 app/ghostery-browser-hub/Views/OnboardingViews/Step1_LogInForm/__tests__/Step1_LoginForm.test.jsx create mode 100644 app/ghostery-browser-hub/Views/OnboardingViews/Step1_LogInForm/__tests__/__snapshots__/Step1_LoginForm.test.jsx.snap diff --git a/app/ghostery-browser-hub/Views/OnboardingViews/Step1_LogInForm/__tests__/Step1_LoginForm.test.jsx b/app/ghostery-browser-hub/Views/OnboardingViews/Step1_LogInForm/__tests__/Step1_LoginForm.test.jsx new file mode 100644 index 000000000..f279885e3 --- /dev/null +++ b/app/ghostery-browser-hub/Views/OnboardingViews/Step1_LogInForm/__tests__/Step1_LoginForm.test.jsx @@ -0,0 +1,86 @@ +/** + * Create Account View Test Component + * + * Ghostery Browser Extension + * https://www.ghostery.com/ + * + * Copyright 2019 Ghostery, Inc. All rights reserved. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0 + */ + +import React from 'react'; +import renderer from 'react-test-renderer'; +import { shallow } from 'enzyme'; +import { MemoryRouter } from 'react-router'; +import Step1_LoginForm from '../Step1_LoginForm'; + +const noop = () => {}; +describe('app/hub/Views/Step1_LoginForm component', () => { + describe('Snapshot tests with react-test-renderer', () => { + test('Login Form view is rendered correctly', () => { + const initialState = { + email: '', + password: '', + emailError: false, + passwordError: false, + handleSubmit: noop, + handleInputChange: noop, + handleForgotPassword: noop + }; + + const component = renderer.create( + + + + ).toJSON(); + expect(component).toMatchSnapshot(); + }); + }); + + describe('Shallow snapshot tests rendered with Enzyme', () => { + test('the happy path of the component', () => { + const initialState = { + email: 'test@example.com', + password: 'examplePassword', + emailError: false, + passwordError: false, + handleSubmit: jest.fn(), + handleInputChange: () => {}, + handleForgotPassword: noop + }; + + const component = shallow(); + expect(component.find('.Step1_LogInForm').length).toBe(1); + expect(component.find('.Step1_LogInForm__inputBox').length).toBe(2); + expect(component.find('.Step1_LogInForm__forgotPassword').length).toBe(1); + expect(component.find('.Step1_LogInForm__ctaButton').length).toBe(1); + + expect(initialState.handleSubmit.mock.calls.length).toBe(0); + component.find('form').simulate('submit'); + expect(initialState.handleSubmit.mock.calls.length).toBe(1); + }); + + test('the sad path of the component with errors', () => { + const initialState = { + email: 'test@example.com', + password: 'examplePassword', + emailError: true, + passwordError: true, + handleSubmit: jest.fn(), + handleInputChange: () => {}, + handleForgotPassword: noop + }; + + const component = shallow(); + + expect(initialState.handleSubmit.mock.calls.length).toBe(0); + component.find('form').simulate('submit'); + expect(initialState.handleSubmit.mock.calls.length).toBe(1); + expect(component.find('.Step1_LogInForm__inputError').length).toBe(2); + + }) + }); +}); diff --git a/app/ghostery-browser-hub/Views/OnboardingViews/Step1_LogInForm/__tests__/__snapshots__/Step1_LoginForm.test.jsx.snap b/app/ghostery-browser-hub/Views/OnboardingViews/Step1_LogInForm/__tests__/__snapshots__/Step1_LoginForm.test.jsx.snap new file mode 100644 index 000000000..b747c6459 --- /dev/null +++ b/app/ghostery-browser-hub/Views/OnboardingViews/Step1_LogInForm/__tests__/__snapshots__/Step1_LoginForm.test.jsx.snap @@ -0,0 +1,85 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`app/hub/Views/Step1_LoginForm component Snapshot tests with react-test-renderer Login Form view is rendered correctly 1`] = ` +
+
+
+ + +
+
+
+
+ + +
+
+
+
+ +
+ forgot_password +
+
+
+
+
+ +
+
+`; From 8721f8db2c097c49537ae72d646ef4c516b2f536 Mon Sep 17 00:00:00 2001 From: Ben Date: Sat, 9 Jan 2021 21:45:05 -0500 Subject: [PATCH 05/22] Add tests for Step1_CreateAccountView --- .../Step1_CreateAccountView.jsx | 4 +- .../Step1_CreateAccountView.test.jsx | 65 ++++++++ .../Step1_CreateAccountView.test.jsx.snap | 139 ++++++++++++++++++ 3 files changed, 206 insertions(+), 2 deletions(-) create mode 100644 app/ghostery-browser-hub/Views/OnboardingViews/Step1_CreateAccountView/__tests__/Step1_CreateAccountView.test.jsx create mode 100644 app/ghostery-browser-hub/Views/OnboardingViews/Step1_CreateAccountView/__tests__/__snapshots__/Step1_CreateAccountView.test.jsx.snap diff --git a/app/ghostery-browser-hub/Views/OnboardingViews/Step1_CreateAccountView/Step1_CreateAccountView.jsx b/app/ghostery-browser-hub/Views/OnboardingViews/Step1_CreateAccountView/Step1_CreateAccountView.jsx index 6d7bca870..b6351bf2c 100644 --- a/app/ghostery-browser-hub/Views/OnboardingViews/Step1_CreateAccountView/Step1_CreateAccountView.jsx +++ b/app/ghostery-browser-hub/Views/OnboardingViews/Step1_CreateAccountView/Step1_CreateAccountView.jsx @@ -53,7 +53,7 @@ const renderFAQListItem = (icon, label, description) => ( * @return {JSX} JSX for rendering the Browser Create Account View of the Hub app * @memberof GhosteryBrowserHubViews */ -const Step1_CreateAccountView = (props) => { +export const Step1_CreateAccountView = (props) => { const { user, actions } = props; const { setSetupStep } = actions; const email = user && user.email; @@ -162,4 +162,4 @@ Step1_CreateAccountView.defaultProps = { }, }; -export default Step1_CreateAccountForm; +export default Step1_CreateAccountView; diff --git a/app/ghostery-browser-hub/Views/OnboardingViews/Step1_CreateAccountView/__tests__/Step1_CreateAccountView.test.jsx b/app/ghostery-browser-hub/Views/OnboardingViews/Step1_CreateAccountView/__tests__/Step1_CreateAccountView.test.jsx new file mode 100644 index 000000000..c69db8491 --- /dev/null +++ b/app/ghostery-browser-hub/Views/OnboardingViews/Step1_CreateAccountView/__tests__/Step1_CreateAccountView.test.jsx @@ -0,0 +1,65 @@ +/** + * Create Account View Test Component + * + * Ghostery Browser Extension + * https://www.ghostery.com/ + * + * Copyright 2019 Ghostery, Inc. All rights reserved. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0 + */ + +import React from 'react'; +import renderer from 'react-test-renderer'; +import { shallow } from 'enzyme'; +import { MemoryRouter } from 'react-router'; +import Step1_CreateAccountView from '../Step1_CreateAccountView'; + +jest.mock('../../Step1_CreateAccountForm', () => { + const CreateAccountForm = () =>
; + return CreateAccountForm; +}); + +jest.mock('../../Step1_LogInForm', () => { + const LogInForm = () =>
; + return LogInForm; +}); + +const noop = () => {}; +describe('app/hub/Views/Step1_CreateAccountView component', () => { + describe('Snapshot tests with react-test-renderer', () => { + test('Create Account Form view is rendered correctly', () => { + const initialState = { + user: null, + actions: { + setSetupStep: noop + } + }; + + const component = renderer.create( + + + + ).toJSON(); + expect(component).toMatchSnapshot(); + }); + }); + + describe('Shallow snapshot tests rendered with Enzyme', () => { + test('Create Account Form view is rendered correctly when user is logged in', () => { + const initialState = { + user: { + plusAccess: true + }, + actions: { + setSetupStep: noop + } + }; + + const component = shallow(); + expect(component.find('.Step1_CreateAccountView__alreadySignedIn').length).toBe(1); + }); + }); +}); diff --git a/app/ghostery-browser-hub/Views/OnboardingViews/Step1_CreateAccountView/__tests__/__snapshots__/Step1_CreateAccountView.test.jsx.snap b/app/ghostery-browser-hub/Views/OnboardingViews/Step1_CreateAccountView/__tests__/__snapshots__/Step1_CreateAccountView.test.jsx.snap new file mode 100644 index 000000000..30217daae --- /dev/null +++ b/app/ghostery-browser-hub/Views/OnboardingViews/Step1_CreateAccountView/__tests__/__snapshots__/Step1_CreateAccountView.test.jsx.snap @@ -0,0 +1,139 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`app/hub/Views/Step1_CreateAccountView component Snapshot tests with react-test-renderer Create Account Form view is rendered correctly 1`] = ` +
+
+ ghostery_browser_hub_onboarding_create_a_ghostery_account +
+
+ ghostery_browser_hub_onboarding_sync_settings +
+
+
+ ghostery_browser_hub_onboarding_already_have_account +
+
+
+
+
+ +
+
+ ghostery_browser_hub_onboarding_we_take_your_privacy_very_seriously +
+
+
+
+
+`; + +exports[`app/hub/Views/Step1_CreateAccountView component Snapshot tests with react-test-renderer Login Form view is rendered correctly 1`] = ` +
+
+ ghostery_browser_hub_onboarding_create_a_ghostery_account +
+
+ ghostery_browser_hub_onboarding_sync_settings +
+
+
+ ghostery_browser_hub_onboarding_already_have_account +
+
+
+
+
+ +
+
+ ghostery_browser_hub_onboarding_we_take_your_privacy_very_seriously +
+
+
+
+
+`; From a870aef051159f03f8da2d74add730445618adcf Mon Sep 17 00:00:00 2001 From: Ben Date: Mon, 11 Jan 2021 02:02:46 -0500 Subject: [PATCH 06/22] Add tests for hub reducers --- .../__tests__/AntiSuiteReducer.test.js | 69 +++++++++++++++++++ .../__tests__/BlockingPolicyReducer.test.js | 41 +++++++++++ .../__tests__/SetupLifeCycleReducer.test.js | 42 +++++++++++ .../reducers/__tests__/ToastReducer.test.js | 41 +++++++++++ 4 files changed, 193 insertions(+) create mode 100644 app/shared-hub/reducers/__tests__/AntiSuiteReducer.test.js create mode 100644 app/shared-hub/reducers/__tests__/BlockingPolicyReducer.test.js create mode 100644 app/shared-hub/reducers/__tests__/SetupLifeCycleReducer.test.js create mode 100644 app/shared-hub/reducers/__tests__/ToastReducer.test.js diff --git a/app/shared-hub/reducers/__tests__/AntiSuiteReducer.test.js b/app/shared-hub/reducers/__tests__/AntiSuiteReducer.test.js new file mode 100644 index 000000000..246ca814d --- /dev/null +++ b/app/shared-hub/reducers/__tests__/AntiSuiteReducer.test.js @@ -0,0 +1,69 @@ +/** + * AntiSuite Test Reducer + * + * Ghostery Browser Extension + * https://www.ghostery.com/ + * + * Copyright 2021 Ghostery, Inc. All rights reserved. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0 + */ + +import Immutable from 'seamless-immutable'; +import AntiSuiteReducer from '../AntiSuiteReducer'; +import { SET_AD_BLOCK, SET_ANTI_TRACKING, SET_SMART_BLOCK } from '../../constants/AntiSuiteConstants'; + +const initialState = Immutable({ + setup: { + enable_ad_block: true, + enable_anti_tracking: true, + enable_smart_block: true + } +}); + +describe('app/shared-hub/reducers/AntiSuiteReducer', () => { + test('initial state is correct', () => { + expect(AntiSuiteReducer(undefined, {})).toEqual({}); + }); + + test('reducer correctly handles SET_AD_BLOCK', () => { + const data = { + enable_ad_block: true, + }; + const action = { data, type: SET_AD_BLOCK }; + + const updatedAntiSuiteState = Immutable.merge(initialState.setup, data); + + expect(AntiSuiteReducer(initialState, action)).toEqual({ + setup: updatedAntiSuiteState + }); + }); + + test('reducer correctly handles SET_ANTI_TRACKING', () => { + const data = { + enable_anti_tracking: true, + }; + const action = { data, type: SET_ANTI_TRACKING }; + + const updatedAntiSuiteState = Immutable.merge(initialState.setup, data); + + expect(AntiSuiteReducer(initialState, action)).toEqual({ + setup: updatedAntiSuiteState + }); + }); + + test('reducer correctly handles SET_SMART_BLOCK', () => { + const data = { + enable_smart_block: true, + }; + const action = { data, type: SET_SMART_BLOCK }; + + const updatedAntiSuiteState = Immutable.merge(initialState.setup, data); + + expect(AntiSuiteReducer(initialState, action)).toEqual({ + setup: updatedAntiSuiteState + }); + }); +}); diff --git a/app/shared-hub/reducers/__tests__/BlockingPolicyReducer.test.js b/app/shared-hub/reducers/__tests__/BlockingPolicyReducer.test.js new file mode 100644 index 000000000..b97efc8b1 --- /dev/null +++ b/app/shared-hub/reducers/__tests__/BlockingPolicyReducer.test.js @@ -0,0 +1,41 @@ +/** + * BlockingPolicy Test Reducer + * + * Ghostery Browser Extension + * https://www.ghostery.com/ + * + * Copyright 2021 Ghostery, Inc. All rights reserved. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0 + */ + +import Immutable from 'seamless-immutable'; +import BlockingPolicyReducer from '../BlockingPolicyReducer'; +import { SET_BLOCKING_POLICY } from '../../constants/BlockingPolicyConstants'; + +const initialState = Immutable({ + setup: { + blockingPolicy: true + } +}); + +describe('app/shared-hub/reducers/BlockingPolicy', () => { + test('initial state is correct', () => { + expect(BlockingPolicyReducer(undefined, {})).toEqual({}); + }); + + test('reducer correctly handles SET_BLOCKING_POLICY', () => { + const data = { + blockingPolicy: true, + }; + const action = { data, type: SET_BLOCKING_POLICY }; + + const updatedBlockingPolicyState = Immutable.merge(initialState.setup, data); + + expect(BlockingPolicyReducer(initialState, action)).toEqual({ + setup: updatedBlockingPolicyState + }); + }); +}); diff --git a/app/shared-hub/reducers/__tests__/SetupLifeCycleReducer.test.js b/app/shared-hub/reducers/__tests__/SetupLifeCycleReducer.test.js new file mode 100644 index 000000000..49659a6c1 --- /dev/null +++ b/app/shared-hub/reducers/__tests__/SetupLifeCycleReducer.test.js @@ -0,0 +1,42 @@ +/** + * SetupLifecycle Test Reducer + * + * Ghostery Browser Extension + * https://www.ghostery.com/ + * + * Copyright 2021 Ghostery, Inc. All rights reserved. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0 + */ + +import Immutable from 'seamless-immutable'; +import SetupLifecycleReducer from '../SetupLifecycleReducer'; +import { INIT_SETUP_PROPS } from '../../constants/SetupLifecycleConstants'; + +const initialState = Immutable({ + setup: {} +}); + +describe('app/shared-hub/reducers/SetupLifecycleReducer', () => { + test('initial state is correct', () => { + expect(SetupLifecycleReducer(undefined, {})).toEqual({}); + }); + + test('reducer correctly handles INIT_SETUP_PROPS', () => { + const data = { + blockingPolicy: true, + enable_anti_tracking: true, + enable_ad_block: true, + enable_smart_block: true, + }; + const action = { data, type: INIT_SETUP_PROPS }; + + const updatedSetupLifecycleState = Immutable.merge(initialState.setup, data); + + expect(SetupLifecycleReducer(initialState, action)).toEqual({ + setup: updatedSetupLifecycleState + }); + }); +}); diff --git a/app/shared-hub/reducers/__tests__/ToastReducer.test.js b/app/shared-hub/reducers/__tests__/ToastReducer.test.js new file mode 100644 index 000000000..6b4295569 --- /dev/null +++ b/app/shared-hub/reducers/__tests__/ToastReducer.test.js @@ -0,0 +1,41 @@ +/** + * Toast Test Reducer + * + * Ghostery Browser Extension + * https://www.ghostery.com/ + * + * Copyright 2021 Ghostery, Inc. All rights reserved. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0 + */ + +import Immutable from 'seamless-immutable'; +import ToastReducer from '../ToastReducer'; +import SET_TOAST from '../../constants/ToastConstants'; + +const initialState = Immutable({ + app: {} +}); + +describe('app/shared-hub/reducers/ToastReducer', () => { + test('initial state is correct', () => { + expect(ToastReducer(undefined, {})).toEqual({}); + }); + + test('reducer correctly handles SET_TOAST', () => { + const data = { + toastMessage: 'hey', + toastClass: 'danger' + }; + const action = { data, type: SET_TOAST }; + + const updatedToastReducerState = Immutable.merge(initialState.app, data); + console.log(ToastReducer(initialState, action)); + + expect(ToastReducer(initialState, action)).toEqual({ + app: updatedToastReducerState + }); + }); +}); From af713283c10dee34e84d23d433db91dbc52ad8c3 Mon Sep 17 00:00:00 2001 From: Ben Date: Mon, 11 Jan 2021 02:30:35 -0500 Subject: [PATCH 07/22] Update copyright year --- app/ghostery-browser-hub/Views/AppView/AppView.jsx | 2 +- app/ghostery-browser-hub/Views/AppView/index.js | 2 +- .../Views/OnboardingView/OnboardingView.jsx | 2 +- .../Views/OnboardingView/OnboardingViewContainer.jsx | 2 +- app/ghostery-browser-hub/Views/OnboardingView/index.js | 2 +- .../Views/OnboardingViews/Step0_WelcomeView/WelcomeView.jsx | 2 +- .../Step0_WelcomeView/__tests__/WelcomeView.test.jsx | 2 +- .../Views/OnboardingViews/Step0_WelcomeView/index.js | 2 +- .../Step1_CreateAccountForm/Step1_CreateAccountForm.jsx | 2 +- .../Step1_CreateAccountForm/Step1_CreateAccountForm.scss | 2 +- .../Step1_CreateAccountFormContainer.jsx | 2 +- .../__tests__/Step1_CreateAccountForm.test.jsx | 2 +- .../Views/OnboardingViews/Step1_CreateAccountForm/index.js | 2 +- .../Step1_CreateAccountView/Step1_CreateAccountView.jsx | 4 ++-- .../Step1_CreateAccountView/Step1_CreateAccountView.scss | 2 +- .../__tests__/Step1_CreateAccountView.test.jsx | 2 +- .../Views/OnboardingViews/Step1_CreateAccountView/index.js | 5 ++--- .../OnboardingViews/Step1_LogInForm/Step1_LogInForm.jsx | 2 +- .../OnboardingViews/Step1_LogInForm/Step1_LogInForm.scss | 2 +- .../Step1_LogInForm/Step1_LogInFormContainer.jsx | 2 +- .../Step1_LogInForm/__tests__/Step1_LoginForm.test.jsx | 2 +- .../Views/OnboardingViews/Step1_LogInForm/index.js | 2 +- .../Step2_BlockSettingsView/BlockSettingsView.jsx | 2 +- .../__tests__/BlockSettingsView.test.jsx | 2 +- .../Views/OnboardingViews/Step2_BlockSettingsView/index.js | 2 +- .../OnboardingViews/Step4_ChoosePlanView/ChoosePlanView.jsx | 2 +- .../Step4_ChoosePlanView/__tests__/ChoosePlanView.test.jsx | 2 +- .../Views/OnboardingViews/Step5_SuccessView/SuccessView.jsx | 2 +- .../Step5_SuccessView/__tests__/SuccessView.test.jsx | 2 +- .../Views/OnboardingViews/Step5_SuccessView/index.js | 2 +- .../Views/OnboardingViews/StepNavigator/StepNavigator.jsx | 2 +- .../Views/OnboardingViews/StepNavigator/index.js | 2 +- .../OnboardingViews/StepProgressBar/StepProgressBar.jsx | 2 +- .../OnboardingViews/StepProgressBar/StepProgressBar.scss | 2 +- .../Views/OnboardingViews/StepProgressBar/index.js | 2 +- app/ghostery-browser-hub/createStore.js | 2 +- app/ghostery-browser-hub/index.jsx | 2 +- 37 files changed, 39 insertions(+), 40 deletions(-) diff --git a/app/ghostery-browser-hub/Views/AppView/AppView.jsx b/app/ghostery-browser-hub/Views/AppView/AppView.jsx index 21a7559a4..9b3e08ded 100644 --- a/app/ghostery-browser-hub/Views/AppView/AppView.jsx +++ b/app/ghostery-browser-hub/Views/AppView/AppView.jsx @@ -4,7 +4,7 @@ * Ghostery Browser Extension * https://www.ghostery.com/ * - * Copyright 2020 Ghostery, Inc. All rights reserved. + * Copyright 2021 Ghostery, Inc. All rights reserved. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/app/ghostery-browser-hub/Views/AppView/index.js b/app/ghostery-browser-hub/Views/AppView/index.js index fc8848870..3ede70cf5 100644 --- a/app/ghostery-browser-hub/Views/AppView/index.js +++ b/app/ghostery-browser-hub/Views/AppView/index.js @@ -4,7 +4,7 @@ * Ghostery Browser Extension * https://www.ghostery.com/ * - * Copyright 2020 Ghostery, Inc. All rights reserved. + * Copyright 2021 Ghostery, Inc. All rights reserved. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/app/ghostery-browser-hub/Views/OnboardingView/OnboardingView.jsx b/app/ghostery-browser-hub/Views/OnboardingView/OnboardingView.jsx index 2a3ee0c9d..49084f329 100644 --- a/app/ghostery-browser-hub/Views/OnboardingView/OnboardingView.jsx +++ b/app/ghostery-browser-hub/Views/OnboardingView/OnboardingView.jsx @@ -4,7 +4,7 @@ * Ghostery Browser Extension * https://www.ghostery.com/ * - * Copyright 2020 Ghostery, Inc. All rights reserved. + * Copyright 2021 Ghostery, Inc. All rights reserved. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/app/ghostery-browser-hub/Views/OnboardingView/OnboardingViewContainer.jsx b/app/ghostery-browser-hub/Views/OnboardingView/OnboardingViewContainer.jsx index a09ada285..d86ba0fdc 100644 --- a/app/ghostery-browser-hub/Views/OnboardingView/OnboardingViewContainer.jsx +++ b/app/ghostery-browser-hub/Views/OnboardingView/OnboardingViewContainer.jsx @@ -4,7 +4,7 @@ * Ghostery Browser Extension * https://www.ghostery.com/ * - * Copyright 2020 Ghostery, Inc. All rights reserved. + * Copyright 2021 Ghostery, Inc. All rights reserved. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/app/ghostery-browser-hub/Views/OnboardingView/index.js b/app/ghostery-browser-hub/Views/OnboardingView/index.js index a332709b4..5a2e62f81 100644 --- a/app/ghostery-browser-hub/Views/OnboardingView/index.js +++ b/app/ghostery-browser-hub/Views/OnboardingView/index.js @@ -4,7 +4,7 @@ * Ghostery Browser Extension * https://www.ghostery.com/ * - * Copyright 2020 Ghostery, Inc. All rights reserved. + * Copyright 2021 Ghostery, Inc. All rights reserved. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/app/ghostery-browser-hub/Views/OnboardingViews/Step0_WelcomeView/WelcomeView.jsx b/app/ghostery-browser-hub/Views/OnboardingViews/Step0_WelcomeView/WelcomeView.jsx index d11dbfe1a..e7bd2ba91 100644 --- a/app/ghostery-browser-hub/Views/OnboardingViews/Step0_WelcomeView/WelcomeView.jsx +++ b/app/ghostery-browser-hub/Views/OnboardingViews/Step0_WelcomeView/WelcomeView.jsx @@ -4,7 +4,7 @@ * Ghostery Browser Extension * https://www.ghostery.com/ * - * Copyright 2020 Ghostery, Inc. All rights reserved. + * Copyright 2021 Ghostery, Inc. All rights reserved. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/app/ghostery-browser-hub/Views/OnboardingViews/Step0_WelcomeView/__tests__/WelcomeView.test.jsx b/app/ghostery-browser-hub/Views/OnboardingViews/Step0_WelcomeView/__tests__/WelcomeView.test.jsx index dc4de556a..c43c09c8a 100644 --- a/app/ghostery-browser-hub/Views/OnboardingViews/Step0_WelcomeView/__tests__/WelcomeView.test.jsx +++ b/app/ghostery-browser-hub/Views/OnboardingViews/Step0_WelcomeView/__tests__/WelcomeView.test.jsx @@ -4,7 +4,7 @@ * Ghostery Browser Extension * https://www.ghostery.com/ * - * Copyright 2020 Ghostery, Inc. All rights reserved. + * Copyright 2021 Ghostery, Inc. All rights reserved. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/app/ghostery-browser-hub/Views/OnboardingViews/Step0_WelcomeView/index.js b/app/ghostery-browser-hub/Views/OnboardingViews/Step0_WelcomeView/index.js index c649d5a74..66d3190ee 100644 --- a/app/ghostery-browser-hub/Views/OnboardingViews/Step0_WelcomeView/index.js +++ b/app/ghostery-browser-hub/Views/OnboardingViews/Step0_WelcomeView/index.js @@ -4,7 +4,7 @@ * Ghostery Browser Extension * https://www.ghostery.com/ * - * Copyright 2020 Ghostery, Inc. All rights reserved. + * Copyright 2021 Ghostery, Inc. All rights reserved. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/app/ghostery-browser-hub/Views/OnboardingViews/Step1_CreateAccountForm/Step1_CreateAccountForm.jsx b/app/ghostery-browser-hub/Views/OnboardingViews/Step1_CreateAccountForm/Step1_CreateAccountForm.jsx index 567bb6243..5d2c74352 100644 --- a/app/ghostery-browser-hub/Views/OnboardingViews/Step1_CreateAccountForm/Step1_CreateAccountForm.jsx +++ b/app/ghostery-browser-hub/Views/OnboardingViews/Step1_CreateAccountForm/Step1_CreateAccountForm.jsx @@ -4,7 +4,7 @@ * Ghostery Browser Extension * https://www.ghostery.com/ * - * Copyright 2020 Ghostery, Inc. All rights reserved. + * Copyright 2021 Ghostery, Inc. All rights reserved. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/app/ghostery-browser-hub/Views/OnboardingViews/Step1_CreateAccountForm/Step1_CreateAccountForm.scss b/app/ghostery-browser-hub/Views/OnboardingViews/Step1_CreateAccountForm/Step1_CreateAccountForm.scss index 964008ede..2b217c66b 100644 --- a/app/ghostery-browser-hub/Views/OnboardingViews/Step1_CreateAccountForm/Step1_CreateAccountForm.scss +++ b/app/ghostery-browser-hub/Views/OnboardingViews/Step1_CreateAccountForm/Step1_CreateAccountForm.scss @@ -4,7 +4,7 @@ * Ghostery Browser Extension * https://www.ghostery.com/ * - * Copyright 2019 Ghostery, Inc. All rights reserved. + * Copyright 2021 Ghostery, Inc. All rights reserved. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/app/ghostery-browser-hub/Views/OnboardingViews/Step1_CreateAccountForm/Step1_CreateAccountFormContainer.jsx b/app/ghostery-browser-hub/Views/OnboardingViews/Step1_CreateAccountForm/Step1_CreateAccountFormContainer.jsx index 31f9ffc76..f8c922431 100644 --- a/app/ghostery-browser-hub/Views/OnboardingViews/Step1_CreateAccountForm/Step1_CreateAccountFormContainer.jsx +++ b/app/ghostery-browser-hub/Views/OnboardingViews/Step1_CreateAccountForm/Step1_CreateAccountFormContainer.jsx @@ -4,7 +4,7 @@ * Ghostery Browser Extension * https://www.ghostery.com/ * - * Copyright 2020, Inc. All rights reserved. + * Copyright 2021, Inc. All rights reserved. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/app/ghostery-browser-hub/Views/OnboardingViews/Step1_CreateAccountForm/__tests__/Step1_CreateAccountForm.test.jsx b/app/ghostery-browser-hub/Views/OnboardingViews/Step1_CreateAccountForm/__tests__/Step1_CreateAccountForm.test.jsx index df7ac60bd..a4160bf5a 100644 --- a/app/ghostery-browser-hub/Views/OnboardingViews/Step1_CreateAccountForm/__tests__/Step1_CreateAccountForm.test.jsx +++ b/app/ghostery-browser-hub/Views/OnboardingViews/Step1_CreateAccountForm/__tests__/Step1_CreateAccountForm.test.jsx @@ -4,7 +4,7 @@ * Ghostery Browser Extension * https://www.ghostery.com/ * - * Copyright 2019 Ghostery, Inc. All rights reserved. + * Copyright 2021 Ghostery, Inc. All rights reserved. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/app/ghostery-browser-hub/Views/OnboardingViews/Step1_CreateAccountForm/index.js b/app/ghostery-browser-hub/Views/OnboardingViews/Step1_CreateAccountForm/index.js index 4dcac5d05..b6d7f7592 100644 --- a/app/ghostery-browser-hub/Views/OnboardingViews/Step1_CreateAccountForm/index.js +++ b/app/ghostery-browser-hub/Views/OnboardingViews/Step1_CreateAccountForm/index.js @@ -4,7 +4,7 @@ * Ghostery Browser Extension * https://www.ghostery.com/ * - * Copyright 2020 Ghostery, Inc. All rights reserved. + * Copyright 2021 Ghostery, Inc. All rights reserved. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/app/ghostery-browser-hub/Views/OnboardingViews/Step1_CreateAccountView/Step1_CreateAccountView.jsx b/app/ghostery-browser-hub/Views/OnboardingViews/Step1_CreateAccountView/Step1_CreateAccountView.jsx index b6351bf2c..d664ad1ea 100644 --- a/app/ghostery-browser-hub/Views/OnboardingViews/Step1_CreateAccountView/Step1_CreateAccountView.jsx +++ b/app/ghostery-browser-hub/Views/OnboardingViews/Step1_CreateAccountView/Step1_CreateAccountView.jsx @@ -4,7 +4,7 @@ * Ghostery Browser Extension * https://www.ghostery.com/ * - * Copyright 2020 Ghostery, Inc. All rights reserved. + * Copyright 2021 Ghostery, Inc. All rights reserved. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this @@ -53,7 +53,7 @@ const renderFAQListItem = (icon, label, description) => ( * @return {JSX} JSX for rendering the Browser Create Account View of the Hub app * @memberof GhosteryBrowserHubViews */ -export const Step1_CreateAccountView = (props) => { +const Step1_CreateAccountView = (props) => { const { user, actions } = props; const { setSetupStep } = actions; const email = user && user.email; diff --git a/app/ghostery-browser-hub/Views/OnboardingViews/Step1_CreateAccountView/Step1_CreateAccountView.scss b/app/ghostery-browser-hub/Views/OnboardingViews/Step1_CreateAccountView/Step1_CreateAccountView.scss index 93fabacfd..f2fa8acb5 100644 --- a/app/ghostery-browser-hub/Views/OnboardingViews/Step1_CreateAccountView/Step1_CreateAccountView.scss +++ b/app/ghostery-browser-hub/Views/OnboardingViews/Step1_CreateAccountView/Step1_CreateAccountView.scss @@ -4,7 +4,7 @@ * Ghostery Browser Extension * https://www.ghostery.com/ * - * Copyright 2020 Ghostery, Inc. All rights reserved. + * Copyright 2021 Ghostery, Inc. All rights reserved. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/app/ghostery-browser-hub/Views/OnboardingViews/Step1_CreateAccountView/__tests__/Step1_CreateAccountView.test.jsx b/app/ghostery-browser-hub/Views/OnboardingViews/Step1_CreateAccountView/__tests__/Step1_CreateAccountView.test.jsx index c69db8491..1ce83fd09 100644 --- a/app/ghostery-browser-hub/Views/OnboardingViews/Step1_CreateAccountView/__tests__/Step1_CreateAccountView.test.jsx +++ b/app/ghostery-browser-hub/Views/OnboardingViews/Step1_CreateAccountView/__tests__/Step1_CreateAccountView.test.jsx @@ -4,7 +4,7 @@ * Ghostery Browser Extension * https://www.ghostery.com/ * - * Copyright 2019 Ghostery, Inc. All rights reserved. + * Copyright 2021 Ghostery, Inc. All rights reserved. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/app/ghostery-browser-hub/Views/OnboardingViews/Step1_CreateAccountView/index.js b/app/ghostery-browser-hub/Views/OnboardingViews/Step1_CreateAccountView/index.js index 3015cae6f..09b839fa8 100644 --- a/app/ghostery-browser-hub/Views/OnboardingViews/Step1_CreateAccountView/index.js +++ b/app/ghostery-browser-hub/Views/OnboardingViews/Step1_CreateAccountView/index.js @@ -4,14 +4,13 @@ * Ghostery Browser Extension * https://www.ghostery.com/ * - * Copyright 2020 Ghostery, Inc. All rights reserved. + * Copyright 2021 Ghostery, Inc. All rights reserved. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0 */ -import { withRouter } from 'react-router-dom'; import { buildReduxHOC } from '../../../../shared-hub/utils'; import Step1_CreateAccountView from './Step1_CreateAccountView'; import { setSetupStep } from '../../../../shared-hub/actions/SetupLifecycleActions'; @@ -20,4 +19,4 @@ const actionCreators = { setSetupStep, }; -export default withRouter(buildReduxHOC(['account'], actionCreators, Step1_CreateAccountView)); +export default buildReduxHOC(['account'], actionCreators, Step1_CreateAccountView); diff --git a/app/ghostery-browser-hub/Views/OnboardingViews/Step1_LogInForm/Step1_LogInForm.jsx b/app/ghostery-browser-hub/Views/OnboardingViews/Step1_LogInForm/Step1_LogInForm.jsx index 26c86f4f2..70972a1f7 100644 --- a/app/ghostery-browser-hub/Views/OnboardingViews/Step1_LogInForm/Step1_LogInForm.jsx +++ b/app/ghostery-browser-hub/Views/OnboardingViews/Step1_LogInForm/Step1_LogInForm.jsx @@ -4,7 +4,7 @@ * Ghostery Browser Extension * https://www.ghostery.com/ * - * Copyright 2019 Ghostery, Inc. All rights reserved. + * Copyright 2021 Ghostery, Inc. All rights reserved. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/app/ghostery-browser-hub/Views/OnboardingViews/Step1_LogInForm/Step1_LogInForm.scss b/app/ghostery-browser-hub/Views/OnboardingViews/Step1_LogInForm/Step1_LogInForm.scss index 9121a1d53..bb8bfdf30 100644 --- a/app/ghostery-browser-hub/Views/OnboardingViews/Step1_LogInForm/Step1_LogInForm.scss +++ b/app/ghostery-browser-hub/Views/OnboardingViews/Step1_LogInForm/Step1_LogInForm.scss @@ -4,7 +4,7 @@ * Ghostery Browser Extension * https://www.ghostery.com/ * - * Copyright 2019 Ghostery, Inc. All rights reserved. + * Copyright 2021 Ghostery, Inc. All rights reserved. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/app/ghostery-browser-hub/Views/OnboardingViews/Step1_LogInForm/Step1_LogInFormContainer.jsx b/app/ghostery-browser-hub/Views/OnboardingViews/Step1_LogInForm/Step1_LogInFormContainer.jsx index 67d15b3ae..bcb6b3ff0 100644 --- a/app/ghostery-browser-hub/Views/OnboardingViews/Step1_LogInForm/Step1_LogInFormContainer.jsx +++ b/app/ghostery-browser-hub/Views/OnboardingViews/Step1_LogInForm/Step1_LogInFormContainer.jsx @@ -4,7 +4,7 @@ * Ghostery Browser Extension * https://www.ghostery.com/ * - * Copyright 2019 Ghostery, Inc. All rights reserved. + * Copyright 2021 Ghostery, Inc. All rights reserved. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/app/ghostery-browser-hub/Views/OnboardingViews/Step1_LogInForm/__tests__/Step1_LoginForm.test.jsx b/app/ghostery-browser-hub/Views/OnboardingViews/Step1_LogInForm/__tests__/Step1_LoginForm.test.jsx index f279885e3..c2e7b9a4e 100644 --- a/app/ghostery-browser-hub/Views/OnboardingViews/Step1_LogInForm/__tests__/Step1_LoginForm.test.jsx +++ b/app/ghostery-browser-hub/Views/OnboardingViews/Step1_LogInForm/__tests__/Step1_LoginForm.test.jsx @@ -4,7 +4,7 @@ * Ghostery Browser Extension * https://www.ghostery.com/ * - * Copyright 2019 Ghostery, Inc. All rights reserved. + * Copyright 2021 Ghostery, Inc. All rights reserved. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/app/ghostery-browser-hub/Views/OnboardingViews/Step1_LogInForm/index.js b/app/ghostery-browser-hub/Views/OnboardingViews/Step1_LogInForm/index.js index 21a7378e6..f6b4ecd25 100644 --- a/app/ghostery-browser-hub/Views/OnboardingViews/Step1_LogInForm/index.js +++ b/app/ghostery-browser-hub/Views/OnboardingViews/Step1_LogInForm/index.js @@ -4,7 +4,7 @@ * Ghostery Browser Extension * https://www.ghostery.com/ * - * Copyright 2020 Ghostery, Inc. All rights reserved. + * Copyright 2021 Ghostery, Inc. All rights reserved. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/app/ghostery-browser-hub/Views/OnboardingViews/Step2_BlockSettingsView/BlockSettingsView.jsx b/app/ghostery-browser-hub/Views/OnboardingViews/Step2_BlockSettingsView/BlockSettingsView.jsx index 6e74690cb..8bf52896a 100644 --- a/app/ghostery-browser-hub/Views/OnboardingViews/Step2_BlockSettingsView/BlockSettingsView.jsx +++ b/app/ghostery-browser-hub/Views/OnboardingViews/Step2_BlockSettingsView/BlockSettingsView.jsx @@ -4,7 +4,7 @@ * Ghostery Browser Extension * https://www.ghostery.com/ * - * Copyright 2020 Ghostery, Inc. All rights reserved. + * Copyright 2021 Ghostery, Inc. All rights reserved. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/app/ghostery-browser-hub/Views/OnboardingViews/Step2_BlockSettingsView/__tests__/BlockSettingsView.test.jsx b/app/ghostery-browser-hub/Views/OnboardingViews/Step2_BlockSettingsView/__tests__/BlockSettingsView.test.jsx index b17b34c1e..33f5d6672 100644 --- a/app/ghostery-browser-hub/Views/OnboardingViews/Step2_BlockSettingsView/__tests__/BlockSettingsView.test.jsx +++ b/app/ghostery-browser-hub/Views/OnboardingViews/Step2_BlockSettingsView/__tests__/BlockSettingsView.test.jsx @@ -4,7 +4,7 @@ * Ghostery Browser Extension * https://www.ghostery.com/ * - * Copyright 2020 Ghostery, Inc. All rights reserved. + * Copyright 2021 Ghostery, Inc. All rights reserved. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/app/ghostery-browser-hub/Views/OnboardingViews/Step2_BlockSettingsView/index.js b/app/ghostery-browser-hub/Views/OnboardingViews/Step2_BlockSettingsView/index.js index 9394bfdc0..d3bfb3ae0 100644 --- a/app/ghostery-browser-hub/Views/OnboardingViews/Step2_BlockSettingsView/index.js +++ b/app/ghostery-browser-hub/Views/OnboardingViews/Step2_BlockSettingsView/index.js @@ -4,7 +4,7 @@ * Ghostery Browser Extension * https://www.ghostery.com/ * - * Copyright 2020 Ghostery, Inc. All rights reserved. + * Copyright 2021 Ghostery, Inc. All rights reserved. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/app/ghostery-browser-hub/Views/OnboardingViews/Step4_ChoosePlanView/ChoosePlanView.jsx b/app/ghostery-browser-hub/Views/OnboardingViews/Step4_ChoosePlanView/ChoosePlanView.jsx index 0f5dd7d99..24447a5a9 100644 --- a/app/ghostery-browser-hub/Views/OnboardingViews/Step4_ChoosePlanView/ChoosePlanView.jsx +++ b/app/ghostery-browser-hub/Views/OnboardingViews/Step4_ChoosePlanView/ChoosePlanView.jsx @@ -4,7 +4,7 @@ * Ghostery Browser Extension * https://www.ghostery.com/ * - * Copyright 2020 Ghostery, Inc. All rights reserved. + * Copyright 2021 Ghostery, Inc. All rights reserved. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/app/ghostery-browser-hub/Views/OnboardingViews/Step4_ChoosePlanView/__tests__/ChoosePlanView.test.jsx b/app/ghostery-browser-hub/Views/OnboardingViews/Step4_ChoosePlanView/__tests__/ChoosePlanView.test.jsx index d468f183b..6932c5500 100644 --- a/app/ghostery-browser-hub/Views/OnboardingViews/Step4_ChoosePlanView/__tests__/ChoosePlanView.test.jsx +++ b/app/ghostery-browser-hub/Views/OnboardingViews/Step4_ChoosePlanView/__tests__/ChoosePlanView.test.jsx @@ -4,7 +4,7 @@ * Ghostery Browser Extension * https://www.ghostery.com/ * - * Copyright 2020 Ghostery, Inc. All rights reserved. + * Copyright 2021 Ghostery, Inc. All rights reserved. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/app/ghostery-browser-hub/Views/OnboardingViews/Step5_SuccessView/SuccessView.jsx b/app/ghostery-browser-hub/Views/OnboardingViews/Step5_SuccessView/SuccessView.jsx index 4ba81590c..94ca0a611 100644 --- a/app/ghostery-browser-hub/Views/OnboardingViews/Step5_SuccessView/SuccessView.jsx +++ b/app/ghostery-browser-hub/Views/OnboardingViews/Step5_SuccessView/SuccessView.jsx @@ -4,7 +4,7 @@ * Ghostery Browser Extension * https://www.ghostery.com/ * - * Copyright 2020 Ghostery, Inc. All rights reserved. + * Copyright 2021 Ghostery, Inc. All rights reserved. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/app/ghostery-browser-hub/Views/OnboardingViews/Step5_SuccessView/__tests__/SuccessView.test.jsx b/app/ghostery-browser-hub/Views/OnboardingViews/Step5_SuccessView/__tests__/SuccessView.test.jsx index 0c835375b..7136d4ad6 100644 --- a/app/ghostery-browser-hub/Views/OnboardingViews/Step5_SuccessView/__tests__/SuccessView.test.jsx +++ b/app/ghostery-browser-hub/Views/OnboardingViews/Step5_SuccessView/__tests__/SuccessView.test.jsx @@ -4,7 +4,7 @@ * Ghostery Browser Extension * https://www.ghostery.com/ * - * Copyright 2020 Ghostery, Inc. All rights reserved. + * Copyright 2021 Ghostery, Inc. All rights reserved. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/app/ghostery-browser-hub/Views/OnboardingViews/Step5_SuccessView/index.js b/app/ghostery-browser-hub/Views/OnboardingViews/Step5_SuccessView/index.js index 9b5cf3814..ae5abc940 100644 --- a/app/ghostery-browser-hub/Views/OnboardingViews/Step5_SuccessView/index.js +++ b/app/ghostery-browser-hub/Views/OnboardingViews/Step5_SuccessView/index.js @@ -4,7 +4,7 @@ * Ghostery Browser Extension * https://www.ghostery.com/ * - * Copyright 2020 Ghostery, Inc. All rights reserved. + * Copyright 2021 Ghostery, Inc. All rights reserved. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/app/ghostery-browser-hub/Views/OnboardingViews/StepNavigator/StepNavigator.jsx b/app/ghostery-browser-hub/Views/OnboardingViews/StepNavigator/StepNavigator.jsx index 86ed9c650..8d6af03e0 100644 --- a/app/ghostery-browser-hub/Views/OnboardingViews/StepNavigator/StepNavigator.jsx +++ b/app/ghostery-browser-hub/Views/OnboardingViews/StepNavigator/StepNavigator.jsx @@ -4,7 +4,7 @@ * Ghostery Browser Extension * https://www.ghostery.com/ * - * Copyright 2020 Ghostery, Inc. All rights reserved. + * Copyright 2021 Ghostery, Inc. All rights reserved. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/app/ghostery-browser-hub/Views/OnboardingViews/StepNavigator/index.js b/app/ghostery-browser-hub/Views/OnboardingViews/StepNavigator/index.js index 9324423ed..4228a3345 100644 --- a/app/ghostery-browser-hub/Views/OnboardingViews/StepNavigator/index.js +++ b/app/ghostery-browser-hub/Views/OnboardingViews/StepNavigator/index.js @@ -4,7 +4,7 @@ * Ghostery Browser Extension * https://www.ghostery.com/ * - * Copyright 2020 Ghostery, Inc. All rights reserved. + * Copyright 2021 Ghostery, Inc. All rights reserved. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/app/ghostery-browser-hub/Views/OnboardingViews/StepProgressBar/StepProgressBar.jsx b/app/ghostery-browser-hub/Views/OnboardingViews/StepProgressBar/StepProgressBar.jsx index d4be7e485..d4411852a 100644 --- a/app/ghostery-browser-hub/Views/OnboardingViews/StepProgressBar/StepProgressBar.jsx +++ b/app/ghostery-browser-hub/Views/OnboardingViews/StepProgressBar/StepProgressBar.jsx @@ -4,7 +4,7 @@ * Ghostery Browser Extension * https://www.ghostery.com/ * - * Copyright 2020 Ghostery, Inc. All rights reserved. + * Copyright 2021 Ghostery, Inc. All rights reserved. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/app/ghostery-browser-hub/Views/OnboardingViews/StepProgressBar/StepProgressBar.scss b/app/ghostery-browser-hub/Views/OnboardingViews/StepProgressBar/StepProgressBar.scss index 7fbbb2a02..da4abb86e 100644 --- a/app/ghostery-browser-hub/Views/OnboardingViews/StepProgressBar/StepProgressBar.scss +++ b/app/ghostery-browser-hub/Views/OnboardingViews/StepProgressBar/StepProgressBar.scss @@ -4,7 +4,7 @@ * Ghostery Browser Extension * https://www.ghostery.com/ * - * Copyright 2019 Ghostery, Inc. All rights reserved. + * Copyright 2021 Ghostery, Inc. All rights reserved. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/app/ghostery-browser-hub/Views/OnboardingViews/StepProgressBar/index.js b/app/ghostery-browser-hub/Views/OnboardingViews/StepProgressBar/index.js index 127b75783..1f20a3fc0 100644 --- a/app/ghostery-browser-hub/Views/OnboardingViews/StepProgressBar/index.js +++ b/app/ghostery-browser-hub/Views/OnboardingViews/StepProgressBar/index.js @@ -4,7 +4,7 @@ * Ghostery Browser Extension * https://www.ghostery.com/ * - * Copyright 2020 Ghostery, Inc. All rights reserved. + * Copyright 2021 Ghostery, Inc. All rights reserved. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/app/ghostery-browser-hub/createStore.js b/app/ghostery-browser-hub/createStore.js index d94cf838d..44c6d9fcc 100644 --- a/app/ghostery-browser-hub/createStore.js +++ b/app/ghostery-browser-hub/createStore.js @@ -4,7 +4,7 @@ * Ghostery Browser Extension * https://www.ghostery.com/ * - * Copyright 2020 Ghostery, Inc. All rights reserved. + * Copyright 2021 Ghostery, Inc. All rights reserved. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/app/ghostery-browser-hub/index.jsx b/app/ghostery-browser-hub/index.jsx index 67d2e3d2b..9a9aa4a39 100644 --- a/app/ghostery-browser-hub/index.jsx +++ b/app/ghostery-browser-hub/index.jsx @@ -4,7 +4,7 @@ * Ghostery Browser Extension * https://www.ghostery.com/ * - * Copyright 2020 Ghostery, Inc. All rights reserved. + * Copyright 2021 Ghostery, Inc. All rights reserved. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this From 6ebf2e59f68be9736fab9d30a1468d265416559a Mon Sep 17 00:00:00 2001 From: Ben Date: Mon, 11 Jan 2021 02:32:15 -0500 Subject: [PATCH 08/22] Add copyright to sass files --- .../Step0_WelcomeView/WelcomeView.scss | 13 +++++++++++++ .../Step2_BlockSettingsView/BlockSettingsView.scss | 14 ++++++++++++++ .../Step4_ChoosePlanView/ChoosePlanView.scss | 13 +++++++++++++ .../Step5_SuccessView/SuccessView.scss | 13 +++++++++++++ 4 files changed, 53 insertions(+) diff --git a/app/ghostery-browser-hub/Views/OnboardingViews/Step0_WelcomeView/WelcomeView.scss b/app/ghostery-browser-hub/Views/OnboardingViews/Step0_WelcomeView/WelcomeView.scss index 21530b88e..935bc6de3 100644 --- a/app/ghostery-browser-hub/Views/OnboardingViews/Step0_WelcomeView/WelcomeView.scss +++ b/app/ghostery-browser-hub/Views/OnboardingViews/Step0_WelcomeView/WelcomeView.scss @@ -1,3 +1,16 @@ +/** + * WelcomeView Sass + * + * Ghostery Browser Extension + * https://www.ghostery.com/ + * + * Copyright 2021 Ghostery, Inc. All rights reserved. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0 + */ + .WelcomeView__container { display: flex; justify-content: center; diff --git a/app/ghostery-browser-hub/Views/OnboardingViews/Step2_BlockSettingsView/BlockSettingsView.scss b/app/ghostery-browser-hub/Views/OnboardingViews/Step2_BlockSettingsView/BlockSettingsView.scss index 85b35e75c..8482b7f7a 100644 --- a/app/ghostery-browser-hub/Views/OnboardingViews/Step2_BlockSettingsView/BlockSettingsView.scss +++ b/app/ghostery-browser-hub/Views/OnboardingViews/Step2_BlockSettingsView/BlockSettingsView.scss @@ -1,3 +1,17 @@ +/** + * BlockSettingsView Sass + * + * Ghostery Browser Extension + * https://www.ghostery.com/ + * + * Copyright 2021 Ghostery, Inc. All rights reserved. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0 + */ + + .BlockSettingsView__container { display: flex; flex-direction: column; diff --git a/app/ghostery-browser-hub/Views/OnboardingViews/Step4_ChoosePlanView/ChoosePlanView.scss b/app/ghostery-browser-hub/Views/OnboardingViews/Step4_ChoosePlanView/ChoosePlanView.scss index 31312470f..c42906b0e 100644 --- a/app/ghostery-browser-hub/Views/OnboardingViews/Step4_ChoosePlanView/ChoosePlanView.scss +++ b/app/ghostery-browser-hub/Views/OnboardingViews/Step4_ChoosePlanView/ChoosePlanView.scss @@ -1,3 +1,16 @@ +/** + * WelcomeView Sass + * + * Ghostery Browser Extension + * https://www.ghostery.com/ + * + * Copyright 2021 Ghostery, Inc. All rights reserved. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0 + */ + $medium-large-breakpoint: 1118px; // Break when 3 cards on the screen overflow to next line .ChoosePlanView { diff --git a/app/ghostery-browser-hub/Views/OnboardingViews/Step5_SuccessView/SuccessView.scss b/app/ghostery-browser-hub/Views/OnboardingViews/Step5_SuccessView/SuccessView.scss index 074ce5302..9ac706a72 100644 --- a/app/ghostery-browser-hub/Views/OnboardingViews/Step5_SuccessView/SuccessView.scss +++ b/app/ghostery-browser-hub/Views/OnboardingViews/Step5_SuccessView/SuccessView.scss @@ -1,3 +1,16 @@ +/** + * SuccessView Sass + * + * Ghostery Browser Extension + * https://www.ghostery.com/ + * + * Copyright 2021 Ghostery, Inc. All rights reserved. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0 + */ + .SuccessView__container { display: flex; justify-content: center; From f8e9899fbbe162de4985b3e3afca5637970327ae Mon Sep 17 00:00:00 2001 From: Ben Date: Mon, 11 Jan 2021 02:50:03 -0500 Subject: [PATCH 09/22] Add broken AntiSuiteActions test --- .../__tests__/AntiSuiteActions.test.js | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 app/shared-hub/actions/__tests__/AntiSuiteActions.test.js diff --git a/app/shared-hub/actions/__tests__/AntiSuiteActions.test.js b/app/shared-hub/actions/__tests__/AntiSuiteActions.test.js new file mode 100644 index 000000000..a0a5df945 --- /dev/null +++ b/app/shared-hub/actions/__tests__/AntiSuiteActions.test.js @@ -0,0 +1,55 @@ +/** + * Test file for Anti Suite Actions + * + * Ghostery Browser Extension + * https://www.ghostery.com/ + * + * Copyright 2021 Ghostery, Inc. All rights reserved. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0 + */ + +import configureStore from 'redux-mock-store'; +import thunk from 'redux-thunk'; +import * as utils from '../../utils'; +import * as AntiSuiteActions from '../AntiSuiteActions'; +import { SET_ANTI_TRACKING, SET_AD_BLOCK, SET_SMART_BLOCK } from '../../constants/AntiSuiteConstants'; + +const middlewares = [thunk]; +const mockStore = configureStore(middlewares); + +const testData = { test: true }; +utils.sendMessageInPromise = jest.fn((name, message) => new Promise((resolve, reject) => { + switch (name) { + case SET_ANTI_TRACKING: { + resolve(testData); + break; + } + case SET_AD_BLOCK: { + console.log('going in send Message') + resolve(message); + break; + } + case SET_SMART_BLOCK: { + resolve(testData); + break; + } + default: resolve(message); + } +})); + +describe('app/hub/Views/OnboardingView/ actions', () => { + test('getHomeProps action should return correctly', () => { + const initialState = {}; + const store = mockStore(initialState); + + const data = testData; + const expectedPayload = { data, type: SET_AD_BLOCK }; + return store.dispatch(AntiSuiteActions.setAdBlock()).then(() => { + const actions = store.getActions(); + expect(actions).toEqual([expectedPayload]); + }); + }); +}); From bd79fd6aaadd45c00a967f2cdccd1b614b045bfb Mon Sep 17 00:00:00 2001 From: Ben Date: Tue, 12 Jan 2021 00:32:44 -0500 Subject: [PATCH 10/22] Add tests for AntiSuiteActions --- .../__tests__/AntiSuiteActions.test.js | 42 +++++++++++++++---- app/shared-hub/utils/index.js | 10 +++-- 2 files changed, 40 insertions(+), 12 deletions(-) diff --git a/app/shared-hub/actions/__tests__/AntiSuiteActions.test.js b/app/shared-hub/actions/__tests__/AntiSuiteActions.test.js index a0a5df945..2aaac3f68 100644 --- a/app/shared-hub/actions/__tests__/AntiSuiteActions.test.js +++ b/app/shared-hub/actions/__tests__/AntiSuiteActions.test.js @@ -15,33 +15,33 @@ import configureStore from 'redux-mock-store'; import thunk from 'redux-thunk'; import * as utils from '../../utils'; import * as AntiSuiteActions from '../AntiSuiteActions'; -import { SET_ANTI_TRACKING, SET_AD_BLOCK, SET_SMART_BLOCK } from '../../constants/AntiSuiteConstants'; +import { SET_AD_BLOCK, SET_ANTI_TRACKING, SET_SMART_BLOCK } from '../../constants/AntiSuiteConstants'; const middlewares = [thunk]; const mockStore = configureStore(middlewares); const testData = { test: true }; + utils.sendMessageInPromise = jest.fn((name, message) => new Promise((resolve, reject) => { switch (name) { - case SET_ANTI_TRACKING: { + case 'SET_ANTI_TRACKING': { resolve(testData); break; } - case SET_AD_BLOCK: { - console.log('going in send Message') - resolve(message); + case 'SET_AD_BLOCK': { + resolve(testData); break; } - case SET_SMART_BLOCK: { + case 'SET_SMART_BLOCK': { resolve(testData); break; } - default: resolve(message); + default: resolve(testData); } })); -describe('app/hub/Views/OnboardingView/ actions', () => { - test('getHomeProps action should return correctly', () => { +describe('app/shared-hub/actions/AntiSuiteActions', () => { + test('setAdBlock action should return correctly', () => { const initialState = {}; const store = mockStore(initialState); @@ -52,4 +52,28 @@ describe('app/hub/Views/OnboardingView/ actions', () => { expect(actions).toEqual([expectedPayload]); }); }); + + test('setAntiTracking action should return correctly', () => { + const initialState = {}; + const store = mockStore(initialState); + + const data = testData; + const expectedPayload = { data, type: SET_ANTI_TRACKING }; + return store.dispatch(AntiSuiteActions.setAntiTracking()).then(() => { + const actions = store.getActions(); + expect(actions).toEqual([expectedPayload]); + }); + }); + + test('setSmartBlock action should return correctly', () => { + const initialState = {}; + const store = mockStore(initialState); + + const data = testData; + const expectedPayload = { data, type: SET_SMART_BLOCK }; + return store.dispatch(AntiSuiteActions.setSmartBlocking()).then(() => { + const actions = store.getActions(); + expect(actions).toEqual([expectedPayload]); + }); + }); }); diff --git a/app/shared-hub/utils/index.js b/app/shared-hub/utils/index.js index 55f478196..24b511c68 100644 --- a/app/shared-hub/utils/index.js +++ b/app/shared-hub/utils/index.js @@ -26,6 +26,10 @@ import { withRouter } from 'react-router-dom'; import { log } from '../../../src/utils/common'; import { sendMessage as importedSM, sendMessageInPromise as importedSMIP } from '../../panel/utils/msg'; +// Self import this file so makeDeferredDispatcher can mock the sendMessageInPromise function within the same class +// eslint-disable-next-line import/no-self-import +import * as utils from './index'; + const sendMessageInPromise = function(name, message) { return importedSMIP(name, message, 'ghostery-hub'); }; @@ -72,7 +76,7 @@ const makeStoreCreator = function(reducers, middlewares) { */ function makeDeferredDispatcher(action, actionData) { return function(dispatch) { - return sendMessageInPromise(action, actionData).then((data) => { + return utils.sendMessageInPromise(action, actionData).then((data) => { dispatch({ type: action, data, @@ -113,8 +117,8 @@ function buildReduxHOC(stateKeys, actionCreators, baseComponent) { export { buildReduxHOC, makeStoreCreator, - makeDeferredDispatcher, log, sendMessage, - sendMessageInPromise + sendMessageInPromise, + makeDeferredDispatcher }; From 88bdd151fc3e0755178dcd475c35d093023b55c3 Mon Sep 17 00:00:00 2001 From: Ben Date: Tue, 12 Jan 2021 00:39:27 -0500 Subject: [PATCH 11/22] Add test for BlockingPolicyActions --- .../__tests__/BlockingPolicyActions.test.js | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 app/shared-hub/actions/__tests__/BlockingPolicyActions.test.js diff --git a/app/shared-hub/actions/__tests__/BlockingPolicyActions.test.js b/app/shared-hub/actions/__tests__/BlockingPolicyActions.test.js new file mode 100644 index 000000000..8212cdeee --- /dev/null +++ b/app/shared-hub/actions/__tests__/BlockingPolicyActions.test.js @@ -0,0 +1,47 @@ +/** + * Test file for Blocking Policy Actions + * + * Ghostery Browser Extension + * https://www.ghostery.com/ + * + * Copyright 2021 Ghostery, Inc. All rights reserved. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0 + */ + +import configureStore from 'redux-mock-store'; +import thunk from 'redux-thunk'; +import * as utils from '../../utils'; +import setBlockingPolicy from '../BlockingPolicyActions'; +import { SET_BLOCKING_POLICY } from '../../constants/BlockingPolicyConstants' + +const middlewares = [thunk]; +const mockStore = configureStore(middlewares); + +const testData = { test: true }; + +utils.sendMessageInPromise = jest.fn((name, message) => new Promise((resolve, reject) => { + switch (name) { + case 'SET_BLOCKING_POLICY': { + resolve(testData); + break; + } + default: resolve(testData); + } +})); + +describe('app/shared-hub/actions/BlockingPolicyActions', () => { + test('setBlockingPolicy action should return correctly', () => { + const initialState = {}; + const store = mockStore(initialState); + + const data = testData; + const expectedPayload = { data, type: SET_BLOCKING_POLICY }; + return store.dispatch(setBlockingPolicy()).then(() => { + const actions = store.getActions(); + expect(actions).toEqual([expectedPayload]); + }); + }); +}); From 4e5f5079b2b2d60343a201d40b4abf97ee5346a6 Mon Sep 17 00:00:00 2001 From: Ben Date: Tue, 12 Jan 2021 00:46:19 -0500 Subject: [PATCH 12/22] Add test for MetricsActions --- .../actions/__tests__/MetricsActions.test.js | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 app/shared-hub/actions/__tests__/MetricsActions.test.js diff --git a/app/shared-hub/actions/__tests__/MetricsActions.test.js b/app/shared-hub/actions/__tests__/MetricsActions.test.js new file mode 100644 index 000000000..539a8df72 --- /dev/null +++ b/app/shared-hub/actions/__tests__/MetricsActions.test.js @@ -0,0 +1,47 @@ +/** + * Test file for Metrics Actions + * + * Ghostery Browser Extension + * https://www.ghostery.com/ + * + * Copyright 2021 Ghostery, Inc. All rights reserved. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0 + */ + +import configureStore from 'redux-mock-store'; +import thunk from 'redux-thunk'; +import * as utils from '../../utils'; +import sendPing from '../MetricsActions'; +import SEND_PING from '../../constants/MetricsConstants' + +const middlewares = [thunk]; +const mockStore = configureStore(middlewares); + +const testData = { test: true }; + +utils.sendMessageInPromise = jest.fn((name, message) => new Promise((resolve, reject) => { + switch (name) { + case 'SEND_PING': { + resolve(testData); + break; + } + default: resolve(testData); + } +})); + +describe('app/shared-hub/actions/MetricsActions', () => { + test('sendPing action should return correctly', () => { + const initialState = {}; + const store = mockStore(initialState); + + const data = testData; + const expectedPayload = { data, type: SEND_PING }; + return store.dispatch(sendPing()).then(() => { + const actions = store.getActions(); + expect(actions).toEqual([expectedPayload]); + }); + }); +}); From 65a1aa0ac7b67f1862ff9ae0e02d3dfd9d4e740b Mon Sep 17 00:00:00 2001 From: Ben Date: Tue, 12 Jan 2021 01:00:56 -0500 Subject: [PATCH 13/22] Add tests for ToastActions --- .../actions/__tests__/ToastActions.test.js | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 app/shared-hub/actions/__tests__/ToastActions.test.js diff --git a/app/shared-hub/actions/__tests__/ToastActions.test.js b/app/shared-hub/actions/__tests__/ToastActions.test.js new file mode 100644 index 000000000..bed3b286c --- /dev/null +++ b/app/shared-hub/actions/__tests__/ToastActions.test.js @@ -0,0 +1,35 @@ +/** + * Test file for Toast Actions + * + * Ghostery Browser Extension + * https://www.ghostery.com/ + * + * Copyright 2021 Ghostery, Inc. All rights reserved. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0 + */ + +import configureStore from 'redux-mock-store'; +import thunk from 'redux-thunk'; +import setToast from '../ToastActions'; +import SET_TOAST from '../../constants/ToastConstants' + +const middlewares = [thunk]; +const mockStore = configureStore(middlewares); + +const testData = { test: true }; + +describe('app/shared-hub/actions/ToastActions', () => { + test('setToast action should return correctly', () => { + const initialState = {}; + const store = mockStore(initialState); + + const data = testData; + const expectedPayload = { data, type: SET_TOAST }; + store.dispatch(setToast(testData)); + const actions = store.getActions(); + expect(actions).toEqual([expectedPayload]); + }); +}); From 622943d9460df6c1aeeed9e8f25ad232f4cec6d8 Mon Sep 17 00:00:00 2001 From: Ben Date: Tue, 12 Jan 2021 01:06:24 -0500 Subject: [PATCH 14/22] Add tests for SetupLifeCycleActions --- .../__tests__/SetupLifecycleActions.test.js | 78 +++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 app/shared-hub/actions/__tests__/SetupLifecycleActions.test.js diff --git a/app/shared-hub/actions/__tests__/SetupLifecycleActions.test.js b/app/shared-hub/actions/__tests__/SetupLifecycleActions.test.js new file mode 100644 index 000000000..bc682dcc6 --- /dev/null +++ b/app/shared-hub/actions/__tests__/SetupLifecycleActions.test.js @@ -0,0 +1,78 @@ +/** + * Test file for Setup Lifecycle Actions + * + * Ghostery Browser Extension + * https://www.ghostery.com/ + * + * Copyright 2021 Ghostery, Inc. All rights reserved. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0 + */ + +import configureStore from 'redux-mock-store'; +import thunk from 'redux-thunk'; +import * as utils from '../../utils'; +import * as SetupLifecycleActions from '../SetupLifecycleActions'; +import { INIT_SETUP_PROPS, SET_SETUP_STEP, SET_SETUP_COMPLETE } from '../../constants/SetupLifecycleConstants'; + +const middlewares = [thunk]; +const mockStore = configureStore(middlewares); + +const testData = { test: true }; + +utils.sendMessageInPromise = jest.fn((name, message) => new Promise((resolve, reject) => { + switch (name) { + case 'INIT_SETUP_PROPS': { + resolve(testData); + break; + } + case 'SET_SETUP_STEP': { + resolve(testData); + break; + } + case 'SET_SETUP_COMPLETE': { + resolve(testData); + break; + } + default: resolve(testData); + } +})); + +describe('app/shared-hub/actions/AntiSuiteActions', () => { + test('initSetupProps action should return correctly', () => { + const initialState = {}; + const store = mockStore(initialState); + + const data = testData; + const expectedPayload = { data, type: INIT_SETUP_PROPS }; + store.dispatch(SetupLifecycleActions.initSetupProps(testData)); + const actions = store.getActions(); + expect(actions).toEqual([expectedPayload]); + }); + + test('setSetupStep action should return correctly', () => { + const initialState = {}; + const store = mockStore(initialState); + + const data = testData; + const expectedPayload = { data, type: SET_SETUP_STEP }; + return store.dispatch(SetupLifecycleActions.setSetupStep()).then(() => { + const actions = store.getActions(); + expect(actions).toEqual([expectedPayload]); + }); + }); + + test('setSetupStep action should return correctly', () => { + const initialState = {}; + const store = mockStore(initialState); + + const data = testData; + const expectedPayload = { data, type: SET_SETUP_COMPLETE }; + return store.dispatch(SetupLifecycleActions.setSetupComplete()).then(() => { + const actions = store.getActions(); + expect(actions).toEqual([expectedPayload]); + }); + }); +}); From fbf830da5a29e9c90ebd22f66108db66f1ede96e Mon Sep 17 00:00:00 2001 From: Ben Date: Tue, 12 Jan 2021 02:22:32 -0500 Subject: [PATCH 15/22] Add test for StepProgressBar component, fix console errors and use Onboarding Constants as an index to appease PropTypes --- .../Views/OnboardingView/OnboardingView.jsx | 2 +- .../OnboardingViewContainer.jsx | 12 +- .../Step1_CreateAccountView.test.jsx.snap | 69 ---------- .../StepProgressBar/StepProgressBar.jsx | 19 +-- .../__tests__/StepProgressBar.test.jsx | 118 ++++++++++++++++++ .../StepProgressBar.test.jsx.snap | 83 ++++++++++++ 6 files changed, 218 insertions(+), 85 deletions(-) create mode 100644 app/ghostery-browser-hub/Views/OnboardingViews/StepProgressBar/__tests__/StepProgressBar.test.jsx create mode 100644 app/ghostery-browser-hub/Views/OnboardingViews/StepProgressBar/__tests__/__snapshots__/StepProgressBar.test.jsx.snap diff --git a/app/ghostery-browser-hub/Views/OnboardingView/OnboardingView.jsx b/app/ghostery-browser-hub/Views/OnboardingView/OnboardingView.jsx index 49084f329..b04ae166e 100644 --- a/app/ghostery-browser-hub/Views/OnboardingView/OnboardingView.jsx +++ b/app/ghostery-browser-hub/Views/OnboardingView/OnboardingView.jsx @@ -50,7 +50,7 @@ const OnboardingView = (props) => { // PropTypes ensure we pass required props of the correct type OnboardingView.propTypes = { steps: PropTypes.arrayOf(PropTypes.shape({ - index: PropTypes.number.isRequired, + index: PropTypes.string.isRequired, path: PropTypes.string.isRequired, bodyComponents: PropTypes.arrayOf(PropTypes.elementType.isRequired).isRequired, })).isRequired, diff --git a/app/ghostery-browser-hub/Views/OnboardingView/OnboardingViewContainer.jsx b/app/ghostery-browser-hub/Views/OnboardingView/OnboardingViewContainer.jsx index d86ba0fdc..dbb9aef80 100644 --- a/app/ghostery-browser-hub/Views/OnboardingView/OnboardingViewContainer.jsx +++ b/app/ghostery-browser-hub/Views/OnboardingView/OnboardingViewContainer.jsx @@ -82,32 +82,32 @@ class OnboardingViewContainer extends Component { const { sendMountActions } = this.state; const steps = [ { - index: 0, + index: WELCOME, path: `/${ONBOARDING}/${WELCOME}`, bodyComponents: [WelcomeView], }, { - index: 1, + index: LOGIN, path: `/${ONBOARDING}/${LOGIN}`, bodyComponents: [Step1_CreateAccountView], }, { - index: 2, + index: BLOCK_SETTINGS, path: `/${ONBOARDING}/${BLOCK_SETTINGS}`, bodyComponents: [BlockSettingsView], }, { - index: 3, + index: CHOOSE_DEFAULT_SEARCH, path: `/${ONBOARDING}/${CHOOSE_DEFAULT_SEARCH}`, bodyComponents: [ChooseDefaultSearchView], }, { - index: 4, + index: CHOOSE_PLAN, path: `/${ONBOARDING}/${CHOOSE_PLAN}`, bodyComponents: [ChoosePlanView], }, { - index: 5, + index: SUCCESS, path: `/${ONBOARDING}/${SUCCESS}`, bodyComponents: [SuccessView], } diff --git a/app/ghostery-browser-hub/Views/OnboardingViews/Step1_CreateAccountView/__tests__/__snapshots__/Step1_CreateAccountView.test.jsx.snap b/app/ghostery-browser-hub/Views/OnboardingViews/Step1_CreateAccountView/__tests__/__snapshots__/Step1_CreateAccountView.test.jsx.snap index 30217daae..ef2454236 100644 --- a/app/ghostery-browser-hub/Views/OnboardingViews/Step1_CreateAccountView/__tests__/__snapshots__/Step1_CreateAccountView.test.jsx.snap +++ b/app/ghostery-browser-hub/Views/OnboardingViews/Step1_CreateAccountView/__tests__/__snapshots__/Step1_CreateAccountView.test.jsx.snap @@ -68,72 +68,3 @@ exports[`app/hub/Views/Step1_CreateAccountView component Snapshot tests with rea />
`; - -exports[`app/hub/Views/Step1_CreateAccountView component Snapshot tests with react-test-renderer Login Form view is rendered correctly 1`] = ` -
-
- ghostery_browser_hub_onboarding_create_a_ghostery_account -
-
- ghostery_browser_hub_onboarding_sync_settings -
-
-
- ghostery_browser_hub_onboarding_already_have_account -
-
-
-
-
- -
-
- ghostery_browser_hub_onboarding_we_take_your_privacy_very_seriously -
-
-
-
-
-`; diff --git a/app/ghostery-browser-hub/Views/OnboardingViews/StepProgressBar/StepProgressBar.jsx b/app/ghostery-browser-hub/Views/OnboardingViews/StepProgressBar/StepProgressBar.jsx index d4411852a..7d52f15c1 100644 --- a/app/ghostery-browser-hub/Views/OnboardingViews/StepProgressBar/StepProgressBar.jsx +++ b/app/ghostery-browser-hub/Views/OnboardingViews/StepProgressBar/StepProgressBar.jsx @@ -16,8 +16,8 @@ import ClassNames from 'classnames'; import PropTypes from 'prop-types'; import { NavLink } from 'react-router-dom'; import { - ONBOARDING, WELCOME, + ONBOARDING, LOGIN, BLOCK_SETTINGS, CHOOSE_DEFAULT_SEARCH, @@ -54,6 +54,7 @@ const steps = [ */ const StepProgressBar = (props) => { const { currentStep } = props; + const currentStepNumber = parseInt(currentStep, 10); const totalSteps = steps.length; const logoutIfStepOne = (stepId) => { @@ -100,16 +101,16 @@ const StepProgressBar = (props) => { const step = index + 1; return ( - - {(step < currentStep) && renderCompletedStep(steps[index])} - {(step === currentStep) && renderCurrentStep(steps[index])} - {(step > currentStep) && renderIncompleteStep(steps[index])} + + {(step < currentStepNumber) && renderCompletedStep(steps[index])} + {(step === currentStepNumber) && renderCurrentStep(steps[index])} + {(step > currentStepNumber) && renderIncompleteStep(steps[index])} {(step !== totalSteps) && ( - {(step < currentStep) && ( + {(step < currentStepNumber) && (
)} - {(step >= currentStep) && ( + {(step >= currentStepNumber) && (
)} @@ -121,13 +122,13 @@ const StepProgressBar = (props) => { return (
- {(currentStep !== parseInt(WELCOME, 10)) && renderProgressBar()} + {(currentStep !== WELCOME) && renderProgressBar()}
); }; // PropTypes ensure we pass required props of the correct type StepProgressBar.propTypes = { - currentStep: PropTypes.number.isRequired, + currentStep: PropTypes.string.isRequired, }; export default StepProgressBar; diff --git a/app/ghostery-browser-hub/Views/OnboardingViews/StepProgressBar/__tests__/StepProgressBar.test.jsx b/app/ghostery-browser-hub/Views/OnboardingViews/StepProgressBar/__tests__/StepProgressBar.test.jsx new file mode 100644 index 000000000..789c57106 --- /dev/null +++ b/app/ghostery-browser-hub/Views/OnboardingViews/StepProgressBar/__tests__/StepProgressBar.test.jsx @@ -0,0 +1,118 @@ +/** + * StepProgressBar Test Component + * + * Ghostery Browser Extension + * https://www.ghostery.com/ + * + * Copyright 2021 Ghostery, Inc. All rights reserved. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0 + */ + +import React from 'react'; +import renderer from 'react-test-renderer'; +import { shallow } from 'enzyme'; +import { MemoryRouter } from 'react-router'; +import StepProgressBar from '../StepProgressBar'; +import { WELCOME, LOGIN, BLOCK_SETTINGS, CHOOSE_DEFAULT_SEARCH, CHOOSE_PLAN, SUCCESS } from '../../../OnboardingView/OnboardingConstants'; + +const noop = () => {}; + +describe('app/ghostery-browser-hub/Views/OnboardingViews/StepProgressBar/StepProgressBar.test.jsx', () => { + describe('Snapshot tests with react-test-renderer', () => { + test('StepProgressBar is rendered correctly', () => { + const initialState = { + currentStep: LOGIN, + }; + const component = renderer.create( + + + + ).toJSON(); + expect(component).toMatchSnapshot(); + }); + }); + + describe('Shallow snapshot tests rendered with Enzyme', () => { + test('StepProgressBar View step 0', () => { + const initialState = { + currentStep: WELCOME, + actions: { + logout: noop + } + }; + + const component = shallow(); + + expect(component.find('.StepProgressBar__line').length).toBe(0); + expect(component.find('.StepProgressBar__column').length).toBe(0); + expect(component).toMatchSnapshot(); + }); + test('StepProgressBar View step 1', () => { + const initialState = { + currentStep: LOGIN, + actions: { + logout: noop + } + }; + + const component = shallow(); + + expect(component.find('.StepProgressBar__line').length).toBe(3); + expect(component.find('.StepProgressBar__column').length).toBe(4); + expect(component.find('.current').length).toBe(2); + expect(component.find('.incomplete').length).toBe(3); + expect(component).toMatchSnapshot(); + }); + + test('StepProgressBar View step 2', () => { + const initialState = { + currentStep: BLOCK_SETTINGS, + actions: { + logout: noop + } + }; + + const component = shallow(); + + expect(component.find('.step-completed').length).toBe(1); + expect(component.find('.current').length).toBe(2); + expect(component.find('.incomplete').length).toBe(2); + expect(component).toMatchSnapshot(); + }); + + test('StepProgressBar View step 4', () => { + const initialState = { + currentStep: CHOOSE_PLAN, + actions: { + logout: noop + } + }; + + const component = shallow(); + + expect(component.find('.step-completed').length).toBe(3); + expect(component.find('.current').length).toBe(2); + expect(component.find('.incomplete').length).toBe(0); + expect(component).toMatchSnapshot(); + }); + + test('StepProgressBar View step 5', () => { + const initialState = { + currentStep: SUCCESS, + actions: { + logout: noop + } + }; + + const component = shallow(); + + expect(component.find('.step-completed').length).toBe(4); + expect(component.find('.current').length).toBe(0); + expect(component.find('.incomplete').length).toBe(0); + expect(component).toMatchSnapshot(); + }); + }); +}); diff --git a/app/ghostery-browser-hub/Views/OnboardingViews/StepProgressBar/__tests__/__snapshots__/StepProgressBar.test.jsx.snap b/app/ghostery-browser-hub/Views/OnboardingViews/StepProgressBar/__tests__/__snapshots__/StepProgressBar.test.jsx.snap new file mode 100644 index 000000000..f1a6359ba --- /dev/null +++ b/app/ghostery-browser-hub/Views/OnboardingViews/StepProgressBar/__tests__/__snapshots__/StepProgressBar.test.jsx.snap @@ -0,0 +1,83 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`app/ghostery-browser-hub/Views/OnboardingViews/StepProgressBar/StepProgressBar.test.jsx Shallow snapshot tests rendered with Enzyme StepProgressBar View step 0 1`] = `ShallowWrapper {}`; + +exports[`app/ghostery-browser-hub/Views/OnboardingViews/StepProgressBar/StepProgressBar.test.jsx Shallow snapshot tests rendered with Enzyme StepProgressBar View step 1 1`] = `ShallowWrapper {}`; + +exports[`app/ghostery-browser-hub/Views/OnboardingViews/StepProgressBar/StepProgressBar.test.jsx Shallow snapshot tests rendered with Enzyme StepProgressBar View step 2 1`] = `ShallowWrapper {}`; + +exports[`app/ghostery-browser-hub/Views/OnboardingViews/StepProgressBar/StepProgressBar.test.jsx Shallow snapshot tests rendered with Enzyme StepProgressBar View step 3 1`] = `ShallowWrapper {}`; + +exports[`app/ghostery-browser-hub/Views/OnboardingViews/StepProgressBar/StepProgressBar.test.jsx Shallow snapshot tests rendered with Enzyme StepProgressBar View step 4 1`] = `ShallowWrapper {}`; + +exports[`app/ghostery-browser-hub/Views/OnboardingViews/StepProgressBar/StepProgressBar.test.jsx Shallow snapshot tests rendered with Enzyme StepProgressBar View step 5 1`] = `ShallowWrapper {}`; + +exports[`app/ghostery-browser-hub/Views/OnboardingViews/StepProgressBar/StepProgressBar.test.jsx Snapshot tests with react-test-renderer StepProgressBar is rendered correctly 1`] = ` +
+
+ +
+ sign_in +
+
+ +
+
+
+
+ ghostery_browser_hub_onboarding_privacy +
+
+
+
+
+
+ ghostery_browser_hub_onboarding_search +
+
+
+
+
+
+ ghostery_browser_hub_onboarding_plan +
+
+
+
+`; From 8c024f5c79fd47a63f56c62eff9ae7af833bb488 Mon Sep 17 00:00:00 2001 From: Ben Date: Tue, 12 Jan 2021 02:58:14 -0500 Subject: [PATCH 16/22] Update propTypes --- .../Step0_WelcomeView/WelcomeView.jsx | 15 ++++++++++ .../BlockSettingsView.jsx | 28 +++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/app/ghostery-browser-hub/Views/OnboardingViews/Step0_WelcomeView/WelcomeView.jsx b/app/ghostery-browser-hub/Views/OnboardingViews/Step0_WelcomeView/WelcomeView.jsx index e7bd2ba91..84f4b7083 100644 --- a/app/ghostery-browser-hub/Views/OnboardingViews/Step0_WelcomeView/WelcomeView.jsx +++ b/app/ghostery-browser-hub/Views/OnboardingViews/Step0_WelcomeView/WelcomeView.jsx @@ -12,6 +12,7 @@ */ import React from 'react'; +import PropTypes from 'prop-types'; import { NavLink } from 'react-router-dom'; import { LOGIN, WELCOME } from '../../OnboardingView/OnboardingConstants'; @@ -36,3 +37,17 @@ const WelcomeView = (props) => { }; export default WelcomeView; + +// PropTypes ensure we pass required props of the correct type +WelcomeView.propTypes = { + actions: { + setSetupStep: PropTypes.func.isRequired + } +}; + +const noop = () => {}; +WelcomeView.defaultProps = { + actions: { + setSetupStep: noop + } +}; diff --git a/app/ghostery-browser-hub/Views/OnboardingViews/Step2_BlockSettingsView/BlockSettingsView.jsx b/app/ghostery-browser-hub/Views/OnboardingViews/Step2_BlockSettingsView/BlockSettingsView.jsx index 8bf52896a..5526058b2 100644 --- a/app/ghostery-browser-hub/Views/OnboardingViews/Step2_BlockSettingsView/BlockSettingsView.jsx +++ b/app/ghostery-browser-hub/Views/OnboardingViews/Step2_BlockSettingsView/BlockSettingsView.jsx @@ -12,6 +12,7 @@ */ import React, { Fragment, Component } from 'react'; +import PropTypes from 'prop-types'; import { NavLink } from 'react-router-dom'; import Tooltip from '../../../../shared-components/Tooltip'; @@ -228,3 +229,30 @@ class BlockSettingsView extends Component { } export default BlockSettingsView; + +// PropTypes ensure we pass required props of the correct type +BlockSettingsView.propTypes = { + actions: { + logout: PropTypes.func.isRequired, + setAntiTracking: PropTypes.func.isRequired, + setAdBlock: PropTypes.func.isRequired, + setSmartBlocking: PropTypes.func.isRequired, + setBlockingPolicy: PropTypes.func.isRequired, + setToast: PropTypes.func.isRequired, + setSetupStep: PropTypes.func.isRequired, + } +}; + +const noop = () => {}; +BlockSettingsView.defaultProps = { + actions: { + logout: noop, + setAntiTracking: noop, + setAdBlock: noop, + setSmartBlocking: noop, + setBlockingPolicy: noop, + setToast: noop, + setSetupStep: noop, + + } +}; From f085ef188d01e8ba25a17644b33f688e1482a96a Mon Sep 17 00:00:00 2001 From: Ben Date: Tue, 12 Jan 2021 03:03:25 -0500 Subject: [PATCH 17/22] Remove console log --- app/shared-hub/reducers/__tests__/ToastReducer.test.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/app/shared-hub/reducers/__tests__/ToastReducer.test.js b/app/shared-hub/reducers/__tests__/ToastReducer.test.js index 6b4295569..9a7e4bc33 100644 --- a/app/shared-hub/reducers/__tests__/ToastReducer.test.js +++ b/app/shared-hub/reducers/__tests__/ToastReducer.test.js @@ -26,14 +26,12 @@ describe('app/shared-hub/reducers/ToastReducer', () => { test('reducer correctly handles SET_TOAST', () => { const data = { - toastMessage: 'hey', + toastMessage: 'Toaster', toastClass: 'danger' }; const action = { data, type: SET_TOAST }; const updatedToastReducerState = Immutable.merge(initialState.app, data); - console.log(ToastReducer(initialState, action)); - expect(ToastReducer(initialState, action)).toEqual({ app: updatedToastReducerState }); From 3e3c185da385500ddef05287090b5d8fa14a912c Mon Sep 17 00:00:00 2001 From: Ben Date: Tue, 12 Jan 2021 03:18:53 -0500 Subject: [PATCH 18/22] Update proptypes --- .../Step0_WelcomeView/WelcomeView.jsx | 11 ++--------- .../BlockSettingsView.jsx | 18 ++---------------- .../__tests__/BlockSettingsView.test.jsx | 2 ++ .../StepProgressBar.test.jsx.snap | 2 -- 4 files changed, 6 insertions(+), 27 deletions(-) diff --git a/app/ghostery-browser-hub/Views/OnboardingViews/Step0_WelcomeView/WelcomeView.jsx b/app/ghostery-browser-hub/Views/OnboardingViews/Step0_WelcomeView/WelcomeView.jsx index 84f4b7083..7f53c3b5d 100644 --- a/app/ghostery-browser-hub/Views/OnboardingViews/Step0_WelcomeView/WelcomeView.jsx +++ b/app/ghostery-browser-hub/Views/OnboardingViews/Step0_WelcomeView/WelcomeView.jsx @@ -40,14 +40,7 @@ export default WelcomeView; // PropTypes ensure we pass required props of the correct type WelcomeView.propTypes = { - actions: { + actions: PropTypes.shape({ setSetupStep: PropTypes.func.isRequired - } -}; - -const noop = () => {}; -WelcomeView.defaultProps = { - actions: { - setSetupStep: noop - } + }).isRequired, }; diff --git a/app/ghostery-browser-hub/Views/OnboardingViews/Step2_BlockSettingsView/BlockSettingsView.jsx b/app/ghostery-browser-hub/Views/OnboardingViews/Step2_BlockSettingsView/BlockSettingsView.jsx index 3ffe0eee0..1f2d3074c 100644 --- a/app/ghostery-browser-hub/Views/OnboardingViews/Step2_BlockSettingsView/BlockSettingsView.jsx +++ b/app/ghostery-browser-hub/Views/OnboardingViews/Step2_BlockSettingsView/BlockSettingsView.jsx @@ -233,7 +233,7 @@ export default BlockSettingsView; // PropTypes ensure we pass required props of the correct type BlockSettingsView.propTypes = { - actions: { + actions: PropTypes.shape({ logout: PropTypes.func.isRequired, setAntiTracking: PropTypes.func.isRequired, setAdBlock: PropTypes.func.isRequired, @@ -241,19 +241,5 @@ BlockSettingsView.propTypes = { setBlockingPolicy: PropTypes.func.isRequired, setToast: PropTypes.func.isRequired, setSetupStep: PropTypes.func.isRequired, - } -}; - -const noop = () => {}; -BlockSettingsView.defaultProps = { - actions: { - logout: noop, - setAntiTracking: noop, - setAdBlock: noop, - setSmartBlocking: noop, - setBlockingPolicy: noop, - setToast: noop, - setSetupStep: noop, - - } + }).isRequired, }; diff --git a/app/ghostery-browser-hub/Views/OnboardingViews/Step2_BlockSettingsView/__tests__/BlockSettingsView.test.jsx b/app/ghostery-browser-hub/Views/OnboardingViews/Step2_BlockSettingsView/__tests__/BlockSettingsView.test.jsx index 33f5d6672..4c386a13a 100644 --- a/app/ghostery-browser-hub/Views/OnboardingViews/Step2_BlockSettingsView/__tests__/BlockSettingsView.test.jsx +++ b/app/ghostery-browser-hub/Views/OnboardingViews/Step2_BlockSettingsView/__tests__/BlockSettingsView.test.jsx @@ -25,6 +25,7 @@ describe('app/ghostery-browser-hub/Views/OnboardingViews/Step2_BlockSettingsView test('BlockSettings View is rendered correctly', () => { const initialState = { actions: { + logout: noop, setAntiTracking: noop, setAdBlock: noop, setSmartBlocking: noop, @@ -46,6 +47,7 @@ describe('app/ghostery-browser-hub/Views/OnboardingViews/Step2_BlockSettingsView test('BlockSettings View happy path', () => { const initialState = { actions: { + logout: noop, setAntiTracking: jest.fn(), setAdBlock: jest.fn(), setSmartBlocking: jest.fn(), diff --git a/app/ghostery-browser-hub/Views/OnboardingViews/StepProgressBar/__tests__/__snapshots__/StepProgressBar.test.jsx.snap b/app/ghostery-browser-hub/Views/OnboardingViews/StepProgressBar/__tests__/__snapshots__/StepProgressBar.test.jsx.snap index f1a6359ba..e389612c4 100644 --- a/app/ghostery-browser-hub/Views/OnboardingViews/StepProgressBar/__tests__/__snapshots__/StepProgressBar.test.jsx.snap +++ b/app/ghostery-browser-hub/Views/OnboardingViews/StepProgressBar/__tests__/__snapshots__/StepProgressBar.test.jsx.snap @@ -6,8 +6,6 @@ exports[`app/ghostery-browser-hub/Views/OnboardingViews/StepProgressBar/StepProg exports[`app/ghostery-browser-hub/Views/OnboardingViews/StepProgressBar/StepProgressBar.test.jsx Shallow snapshot tests rendered with Enzyme StepProgressBar View step 2 1`] = `ShallowWrapper {}`; -exports[`app/ghostery-browser-hub/Views/OnboardingViews/StepProgressBar/StepProgressBar.test.jsx Shallow snapshot tests rendered with Enzyme StepProgressBar View step 3 1`] = `ShallowWrapper {}`; - exports[`app/ghostery-browser-hub/Views/OnboardingViews/StepProgressBar/StepProgressBar.test.jsx Shallow snapshot tests rendered with Enzyme StepProgressBar View step 4 1`] = `ShallowWrapper {}`; exports[`app/ghostery-browser-hub/Views/OnboardingViews/StepProgressBar/StepProgressBar.test.jsx Shallow snapshot tests rendered with Enzyme StepProgressBar View step 5 1`] = `ShallowWrapper {}`; From 22d567f05382852c54543f934bd0a3906e0ab278 Mon Sep 17 00:00:00 2001 From: Ben Date: Tue, 12 Jan 2021 03:24:05 -0500 Subject: [PATCH 19/22] Update test for ToastReducer --- app/shared-hub/reducers/__tests__/ToastReducer.test.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/shared-hub/reducers/__tests__/ToastReducer.test.js b/app/shared-hub/reducers/__tests__/ToastReducer.test.js index 9a7e4bc33..e0808d3f1 100644 --- a/app/shared-hub/reducers/__tests__/ToastReducer.test.js +++ b/app/shared-hub/reducers/__tests__/ToastReducer.test.js @@ -16,7 +16,7 @@ import ToastReducer from '../ToastReducer'; import SET_TOAST from '../../constants/ToastConstants'; const initialState = Immutable({ - app: {} + toast: {} }); describe('app/shared-hub/reducers/ToastReducer', () => { @@ -31,9 +31,9 @@ describe('app/shared-hub/reducers/ToastReducer', () => { }; const action = { data, type: SET_TOAST }; - const updatedToastReducerState = Immutable.merge(initialState.app, data); + const updatedToastReducerState = Immutable.merge(initialState.toast, data); expect(ToastReducer(initialState, action)).toEqual({ - app: updatedToastReducerState + toast: updatedToastReducerState }); }); }); From f4b4e53960432d415b7565829e137ab3d79ae5f3 Mon Sep 17 00:00:00 2001 From: Ben Date: Tue, 12 Jan 2021 03:26:52 -0500 Subject: [PATCH 20/22] Fix Choose Plan Page screen width --- .../Views/OnboardingView/OnboardingView.jsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/ghostery-browser-hub/Views/OnboardingView/OnboardingView.jsx b/app/ghostery-browser-hub/Views/OnboardingView/OnboardingView.jsx index b04ae166e..dc265c27b 100644 --- a/app/ghostery-browser-hub/Views/OnboardingView/OnboardingView.jsx +++ b/app/ghostery-browser-hub/Views/OnboardingView/OnboardingView.jsx @@ -17,6 +17,7 @@ import { Route } from 'react-router-dom'; import StepProgressBar from '../OnboardingViews/StepProgressBar'; import StepNavigator from '../OnboardingViews/StepNavigator'; +import { CHOOSE_PLAN } from './OnboardingConstants'; /** * A Functional React component for rendering the Onboarding View @@ -35,7 +36,7 @@ const OnboardingView = (props) => { key={`route-${step.index}`} path={step.path} render={() => ( -
+
From 3438d55737ef5aded4f05caad369ab5452770c3c Mon Sep 17 00:00:00 2001 From: Ben Date: Tue, 12 Jan 2021 03:38:21 -0500 Subject: [PATCH 21/22] Add back comment --- .../OnboardingViews/Step4_ChoosePlanView/ChoosePlanView.jsx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/ghostery-browser-hub/Views/OnboardingViews/Step4_ChoosePlanView/ChoosePlanView.jsx b/app/ghostery-browser-hub/Views/OnboardingViews/Step4_ChoosePlanView/ChoosePlanView.jsx index 24447a5a9..6ca34da40 100644 --- a/app/ghostery-browser-hub/Views/OnboardingViews/Step4_ChoosePlanView/ChoosePlanView.jsx +++ b/app/ghostery-browser-hub/Views/OnboardingViews/Step4_ChoosePlanView/ChoosePlanView.jsx @@ -309,6 +309,11 @@ class ChoosePlanView extends React.Component { {didNotSelectGhosterySearch && isBasic && ( {searchPromo()} + {/* TODO: For the CTA button below, + 1. If user is signed in, activate the user’s 7-day free trial for the Ghostery Search Plus plan + and move them to Step 5 if signed in + 2. If user is signed out, clicking this should take them to Step 4b (linked) + */}
{t('ghostery_browser_hub_onboarding_start_trial')}
{t('ghostery_browser_hub_onboarding_see_all_plans')}
From bf3ba739997795c807ff6c9763115632f0aa3d83 Mon Sep 17 00:00:00 2001 From: Ben Date: Thu, 14 Jan 2021 00:46:33 -0500 Subject: [PATCH 22/22] Cleanup unit tests, move withRouter back to component entry path, fix AntiSuiteReducer tests, and mock nested functions in action tests --- .../Step1_CreateAccountForm.test.jsx | 76 ++++++------------- .../Step1_CreateAccountView.test.jsx | 20 ++--- .../__tests__/Step1_LoginForm.test.jsx | 51 +++++-------- .../__tests__/BlockSettingsView.test.jsx | 39 +++++----- .../__tests__/ChoosePlanView.test.jsx | 57 +++++--------- .../__tests__/StepProgressBar.test.jsx | 73 ++++++------------ .../__tests__/AntiSuiteActions.test.js | 19 +++-- .../__tests__/BlockingPolicyActions.test.js | 15 +++- .../actions/__tests__/MetricsActions.test.js | 15 +++- .../__tests__/SetupLifecycleActions.test.js | 17 ++++- .../__tests__/AntiSuiteReducer.test.js | 6 +- app/shared-hub/utils/index.js | 9 +-- 12 files changed, 170 insertions(+), 227 deletions(-) diff --git a/app/ghostery-browser-hub/Views/OnboardingViews/Step1_CreateAccountForm/__tests__/Step1_CreateAccountForm.test.jsx b/app/ghostery-browser-hub/Views/OnboardingViews/Step1_CreateAccountForm/__tests__/Step1_CreateAccountForm.test.jsx index a4160bf5a..9810bd29d 100644 --- a/app/ghostery-browser-hub/Views/OnboardingViews/Step1_CreateAccountForm/__tests__/Step1_CreateAccountForm.test.jsx +++ b/app/ghostery-browser-hub/Views/OnboardingViews/Step1_CreateAccountForm/__tests__/Step1_CreateAccountForm.test.jsx @@ -25,27 +25,27 @@ jest.mock('../../../../../shared-components/ToggleCheckbox', () => { const noop = () => {}; describe('app/hub/Views/Step1_CreateAccountForm component', () => { + const initialState = { + email: 'test@example.com', + emailError: false, + confirmEmail: 'test@example.com', + confirmEmailError: false, + firstName: 'First', + lastName: 'Last', + isUpdatesChecked: true, + legalConsentChecked: true, + password: '', + confirmPassword: '', + passwordInvalidError: false, + passwordLengthError: false, + handleInputChange: noop, + handleUpdatesCheckboxChange: noop, + handleLegalConsentCheckboxChange: noop, + handleSubmit: jest.fn(), + }; + describe('Snapshot tests with react-test-renderer', () => { test('create account view is rendered correctly', () => { - const initialState = { - email: 'test@example.com', - emailError: false, - confirmEmail: 'test@example.com', - confirmEmailError: false, - firstName: 'First', - lastName: 'Last', - isUpdatesChecked: true, - legalConsentChecked: true, - password: '', - confirmPassword: '', - passwordInvalidError: false, - passwordLengthError: false, - handleInputChange: noop, - handleUpdatesCheckboxChange: noop, - handleLegalConsentCheckboxChange: noop, - handleSubmit: jest.fn(), - }; - const component = renderer.create( @@ -57,56 +57,28 @@ describe('app/hub/Views/Step1_CreateAccountForm component', () => { describe('Shallow snapshot tests rendered with Enzyme', () => { test('the happy path of the component', () => { - const initialState = { - email: 'test@example.com', - emailError: false, - confirmEmail: 'test@example.com', - confirmEmailError: false, - firstName: 'First', - lastName: 'Last', - isUpdatesChecked: true, - legalConsentChecked: true, - password: '', - confirmPassword: '', - passwordInvalidError: false, - passwordLengthError: false, - handleInputChange: noop, - handleUpdatesCheckboxChange: noop, - handleLegalConsentCheckboxChange: noop, - handleSubmit: jest.fn(), - }; - const component = shallow(); - expect(component.find('.Step1_CreateAccountForm__inputBox').length).toBe(6); - expect(component.find('.Step1_CreateAccountForm__ctaButton').length).toBe(1); - expect(initialState.handleSubmit.mock.calls.length).toBe(0); component.find('form').simulate('submit'); expect(initialState.handleSubmit.mock.calls.length).toBe(1); }); test('the sad path of the component with errors', () => { - const initialState = { - email: 'test@example.com', + const initialStateFail = { + ...initialState, emailError: true, confirmEmail: 'badConfirmEmail@example.com', confirmEmailError: true, - firstName: 'First', - lastName: 'Last', isUpdatesChecked: false, legalConsentChecked: false, password: 'password', - confirmPassword: 'badPassword', + confirmPassword: 'password', passwordInvalidError: true, passwordLengthError: true, - handleInputChange: noop, - handleUpdatesCheckboxChange: noop, - handleLegalConsentCheckboxChange: noop, - handleSubmit: jest.fn(), - }; + } - const component = shallow(); + const component = shallow(); component.find('form').simulate('submit'); expect(component.find('.Step1_CreateAccountForm__inputErrorContainer').length).toBe(4); expect(component).toMatchSnapshot(); diff --git a/app/ghostery-browser-hub/Views/OnboardingViews/Step1_CreateAccountView/__tests__/Step1_CreateAccountView.test.jsx b/app/ghostery-browser-hub/Views/OnboardingViews/Step1_CreateAccountView/__tests__/Step1_CreateAccountView.test.jsx index 1ce83fd09..7ab8e56a5 100644 --- a/app/ghostery-browser-hub/Views/OnboardingViews/Step1_CreateAccountView/__tests__/Step1_CreateAccountView.test.jsx +++ b/app/ghostery-browser-hub/Views/OnboardingViews/Step1_CreateAccountView/__tests__/Step1_CreateAccountView.test.jsx @@ -29,15 +29,14 @@ jest.mock('../../Step1_LogInForm', () => { const noop = () => {}; describe('app/hub/Views/Step1_CreateAccountView component', () => { + const initialState = { + user: null, + actions: { + setSetupStep: noop + } + }; describe('Snapshot tests with react-test-renderer', () => { test('Create Account Form view is rendered correctly', () => { - const initialState = { - user: null, - actions: { - setSetupStep: noop - } - }; - const component = renderer.create( @@ -49,17 +48,14 @@ describe('app/hub/Views/Step1_CreateAccountView component', () => { describe('Shallow snapshot tests rendered with Enzyme', () => { test('Create Account Form view is rendered correctly when user is logged in', () => { - const initialState = { + const plusUserState = { + ...initialState, user: { plusAccess: true - }, - actions: { - setSetupStep: noop } }; const component = shallow(); - expect(component.find('.Step1_CreateAccountView__alreadySignedIn').length).toBe(1); }); }); }); diff --git a/app/ghostery-browser-hub/Views/OnboardingViews/Step1_LogInForm/__tests__/Step1_LoginForm.test.jsx b/app/ghostery-browser-hub/Views/OnboardingViews/Step1_LogInForm/__tests__/Step1_LoginForm.test.jsx index c2e7b9a4e..c64fb0a34 100644 --- a/app/ghostery-browser-hub/Views/OnboardingViews/Step1_LogInForm/__tests__/Step1_LoginForm.test.jsx +++ b/app/ghostery-browser-hub/Views/OnboardingViews/Step1_LogInForm/__tests__/Step1_LoginForm.test.jsx @@ -19,17 +19,17 @@ import Step1_LoginForm from '../Step1_LoginForm'; const noop = () => {}; describe('app/hub/Views/Step1_LoginForm component', () => { + const initialState = { + email: '', + password: '', + emailError: false, + passwordError: false, + handleSubmit: noop, + handleInputChange: noop, + handleForgotPassword: noop + }; describe('Snapshot tests with react-test-renderer', () => { test('Login Form view is rendered correctly', () => { - const initialState = { - email: '', - password: '', - emailError: false, - passwordError: false, - handleSubmit: noop, - handleInputChange: noop, - handleForgotPassword: noop - }; const component = renderer.create( @@ -42,45 +42,34 @@ describe('app/hub/Views/Step1_LoginForm component', () => { describe('Shallow snapshot tests rendered with Enzyme', () => { test('the happy path of the component', () => { - const initialState = { + const happyState = { + ...initialState, email: 'test@example.com', password: 'examplePassword', - emailError: false, - passwordError: false, handleSubmit: jest.fn(), - handleInputChange: () => {}, - handleForgotPassword: noop - }; + } - const component = shallow(); - expect(component.find('.Step1_LogInForm').length).toBe(1); - expect(component.find('.Step1_LogInForm__inputBox').length).toBe(2); - expect(component.find('.Step1_LogInForm__forgotPassword').length).toBe(1); - expect(component.find('.Step1_LogInForm__ctaButton').length).toBe(1); - - expect(initialState.handleSubmit.mock.calls.length).toBe(0); + const component = shallow(); + expect(happyState.handleSubmit.mock.calls.length).toBe(0); component.find('form').simulate('submit'); - expect(initialState.handleSubmit.mock.calls.length).toBe(1); + expect(happyState.handleSubmit.mock.calls.length).toBe(1); }); test('the sad path of the component with errors', () => { - const initialState = { + const sadState = { + ...initialState, email: 'test@example.com', password: 'examplePassword', emailError: true, passwordError: true, handleSubmit: jest.fn(), - handleInputChange: () => {}, - handleForgotPassword: noop }; - const component = shallow(); + const component = shallow(); - expect(initialState.handleSubmit.mock.calls.length).toBe(0); + expect(sadState.handleSubmit.mock.calls.length).toBe(0); component.find('form').simulate('submit'); - expect(initialState.handleSubmit.mock.calls.length).toBe(1); - expect(component.find('.Step1_LogInForm__inputError').length).toBe(2); - + expect(sadState.handleSubmit.mock.calls.length).toBe(1); }) }); }); diff --git a/app/ghostery-browser-hub/Views/OnboardingViews/Step2_BlockSettingsView/__tests__/BlockSettingsView.test.jsx b/app/ghostery-browser-hub/Views/OnboardingViews/Step2_BlockSettingsView/__tests__/BlockSettingsView.test.jsx index 4c386a13a..5b9d5229c 100644 --- a/app/ghostery-browser-hub/Views/OnboardingViews/Step2_BlockSettingsView/__tests__/BlockSettingsView.test.jsx +++ b/app/ghostery-browser-hub/Views/OnboardingViews/Step2_BlockSettingsView/__tests__/BlockSettingsView.test.jsx @@ -21,19 +21,19 @@ const noop = () => {}; jest.mock('../../../../../shared-components/Tooltip'); describe('app/ghostery-browser-hub/Views/OnboardingViews/Step2_BlockSettingsView/BlockSettingsView.test.jsx', () => { + const initialState = { + actions: { + logout: noop, + setAntiTracking: noop, + setAdBlock: noop, + setSmartBlocking: noop, + setBlockingPolicy: noop, + setToast: noop, + setSetupStep: noop, + } + }; describe('Snapshot tests with react-test-renderer', () => { test('BlockSettings View is rendered correctly', () => { - const initialState = { - actions: { - logout: noop, - setAntiTracking: noop, - setAdBlock: noop, - setSmartBlocking: noop, - setBlockingPolicy: noop, - setToast: noop, - setSetupStep: noop, - } - }; const component = renderer.create( @@ -45,7 +45,8 @@ describe('app/ghostery-browser-hub/Views/OnboardingViews/Step2_BlockSettingsView describe('Shallow snapshot tests rendered with Enzyme', () => { test('BlockSettings View happy path', () => { - const initialState = { + const happyState = { + ...initialState, actions: { logout: noop, setAntiTracking: jest.fn(), @@ -59,9 +60,7 @@ describe('app/ghostery-browser-hub/Views/OnboardingViews/Step2_BlockSettingsView push: noop } }; - const component = shallow(); - expect(component.find('.BlockSettingsView_checkbox').length).toBe(1); - expect(component.find('.BlockSettingsView__radioButtonContainer').length).toBe(9); + const component = shallow(); const instance = component.instance(); @@ -75,11 +74,11 @@ describe('app/ghostery-browser-hub/Views/OnboardingViews/Step2_BlockSettingsView expect(component.state('blockAds')).toBe(false); instance.handleSubmit(); - expect(initialState.actions.setAntiTracking.mock.calls.length).toBe(1); - expect(initialState.actions.setAdBlock.mock.calls.length).toBe(1); - expect(initialState.actions.setSmartBlocking.mock.calls.length).toBe(1); - expect(initialState.actions.setBlockingPolicy.mock.calls.length).toBe(1); - expect(initialState.actions.setSetupStep.mock.calls.length).toBe(1); + expect(happyState.actions.setAntiTracking.mock.calls.length).toBe(1); + expect(happyState.actions.setAdBlock.mock.calls.length).toBe(1); + expect(happyState.actions.setSmartBlocking.mock.calls.length).toBe(1); + expect(happyState.actions.setBlockingPolicy.mock.calls.length).toBe(1); + expect(happyState.actions.setSetupStep.mock.calls.length).toBe(1); expect(component).toMatchSnapshot(); }); diff --git a/app/ghostery-browser-hub/Views/OnboardingViews/Step4_ChoosePlanView/__tests__/ChoosePlanView.test.jsx b/app/ghostery-browser-hub/Views/OnboardingViews/Step4_ChoosePlanView/__tests__/ChoosePlanView.test.jsx index 6932c5500..9457ee6e8 100644 --- a/app/ghostery-browser-hub/Views/OnboardingViews/Step4_ChoosePlanView/__tests__/ChoosePlanView.test.jsx +++ b/app/ghostery-browser-hub/Views/OnboardingViews/Step4_ChoosePlanView/__tests__/ChoosePlanView.test.jsx @@ -20,15 +20,15 @@ import ChoosePlanView from '../ChoosePlanView'; const noop = () => {}; describe('app/ghostery-browser-hub/Views/OnboardingViews/Step4_ChoosePlanView/ChoosePlanView.test.jsx', () => { + const initialState = { + user: null, + didNotSelectGhosterySearch: false, + actions: { + setSetupStep: noop + } + }; describe('Snapshot tests with react-test-renderer', () => { test('ChoosePlanView is rendered correctly', () => { - const initialState = { - user: null, - didNotSelectGhosterySearch: false, - actions: { - setSetupStep: noop - } - }; const component = renderer.create( @@ -40,17 +40,8 @@ describe('app/ghostery-browser-hub/Views/OnboardingViews/Step4_ChoosePlanView/Ch describe('Shallow snapshot tests rendered with Enzyme', () => { test('ChoosePlanView View with user not logged in', () => { - const initialState = { - user: null, - didNotSelectGhosterySearch: false, - actions: { - setSetupStep: noop - }, - }; - const component = shallow(); - expect(component.find('.ChoosePlanView__card').length).toBe(3); const instance = component.instance(); instance.selectBasicPlan(); @@ -66,56 +57,44 @@ describe('app/ghostery-browser-hub/Views/OnboardingViews/Step4_ChoosePlanView/Ch }); test('ChoosePlanView View with basic user logged in', () => { - const initialState = { + const basicUserState = { + ...initialState, user: { plusAccess: false, premiumAccess: false - }, - didNotSelectGhosterySearch: false, - actions: { - setSetupStep: noop - }, + } }; - const component = shallow(); + const component = shallow(); - expect(component.find('.ChoosePlanView__card').length).toBe(3); expect(component).toMatchSnapshot(); }); test('ChoosePlanView View with plus user logged in', () => { - const initialState = { + const plusUserState = { + ...initialState, user: { plusAccess: true, premiumAccess: false }, - didNotSelectGhosterySearch: false, - actions: { - setSetupStep: noop - }, }; - const component = shallow(); + const component = shallow(); - expect(component.find('.ChoosePlanView__card').length).toBe(2); expect(component).toMatchSnapshot(); }); test('ChoosePlanView View with premium user logged in', () => { - const initialState = { + const premiumUserState = { + ...initialState, user: { plusAccess: true, premiumAccess: true - }, - didNotSelectGhosterySearch: false, - actions: { - setSetupStep: noop - }, + } }; - const component = shallow(); + const component = shallow(); - expect(component.find('.ChoosePlanView__card').length).toBe(1); expect(component).toMatchSnapshot(); }); }); diff --git a/app/ghostery-browser-hub/Views/OnboardingViews/StepProgressBar/__tests__/StepProgressBar.test.jsx b/app/ghostery-browser-hub/Views/OnboardingViews/StepProgressBar/__tests__/StepProgressBar.test.jsx index 789c57106..a4320310e 100644 --- a/app/ghostery-browser-hub/Views/OnboardingViews/StepProgressBar/__tests__/StepProgressBar.test.jsx +++ b/app/ghostery-browser-hub/Views/OnboardingViews/StepProgressBar/__tests__/StepProgressBar.test.jsx @@ -21,11 +21,14 @@ import { WELCOME, LOGIN, BLOCK_SETTINGS, CHOOSE_DEFAULT_SEARCH, CHOOSE_PLAN, SUC const noop = () => {}; describe('app/ghostery-browser-hub/Views/OnboardingViews/StepProgressBar/StepProgressBar.test.jsx', () => { + const initialState = { + currentStep: LOGIN, + actions: { + logout: noop + } + }; describe('Snapshot tests with react-test-renderer', () => { test('StepProgressBar is rendered correctly', () => { - const initialState = { - currentStep: LOGIN, - }; const component = renderer.create( @@ -37,81 +40,53 @@ describe('app/ghostery-browser-hub/Views/OnboardingViews/StepProgressBar/StepPro describe('Shallow snapshot tests rendered with Enzyme', () => { test('StepProgressBar View step 0', () => { - const initialState = { + const step_0_initialState = { + ...initialState, currentStep: WELCOME, - actions: { - logout: noop - } }; - const component = shallow(); + const component = shallow(); - expect(component.find('.StepProgressBar__line').length).toBe(0); - expect(component.find('.StepProgressBar__column').length).toBe(0); expect(component).toMatchSnapshot(); }); test('StepProgressBar View step 1', () => { - const initialState = { - currentStep: LOGIN, - actions: { - logout: noop - } + const step_1_initialState = { + ...initialState, + currentStep: LOGIN }; - const component = shallow(); + const component = shallow(); - expect(component.find('.StepProgressBar__line').length).toBe(3); - expect(component.find('.StepProgressBar__column').length).toBe(4); - expect(component.find('.current').length).toBe(2); - expect(component.find('.incomplete').length).toBe(3); expect(component).toMatchSnapshot(); }); test('StepProgressBar View step 2', () => { - const initialState = { - currentStep: BLOCK_SETTINGS, - actions: { - logout: noop - } + const step_2_initialState = { + ...initialState, + currentStep: BLOCK_SETTINGS }; - const component = shallow(); - - expect(component.find('.step-completed').length).toBe(1); - expect(component.find('.current').length).toBe(2); - expect(component.find('.incomplete').length).toBe(2); - expect(component).toMatchSnapshot(); + const component = shallow(); }); test('StepProgressBar View step 4', () => { - const initialState = { - currentStep: CHOOSE_PLAN, - actions: { - logout: noop - } + const step_4_initialState = { + currentStep: CHOOSE_PLAN }; - const component = shallow(); + const component = shallow(); - expect(component.find('.step-completed').length).toBe(3); - expect(component.find('.current').length).toBe(2); - expect(component.find('.incomplete').length).toBe(0); expect(component).toMatchSnapshot(); }); test('StepProgressBar View step 5', () => { - const initialState = { - currentStep: SUCCESS, - actions: { - logout: noop - } + const step_5_initialState = { + ...initialState, + currentStep: SUCCESS }; - const component = shallow(); + const component = shallow(); - expect(component.find('.step-completed').length).toBe(4); - expect(component.find('.current').length).toBe(0); - expect(component.find('.incomplete').length).toBe(0); expect(component).toMatchSnapshot(); }); }); diff --git a/app/shared-hub/actions/__tests__/AntiSuiteActions.test.js b/app/shared-hub/actions/__tests__/AntiSuiteActions.test.js index 2aaac3f68..f61816760 100644 --- a/app/shared-hub/actions/__tests__/AntiSuiteActions.test.js +++ b/app/shared-hub/actions/__tests__/AntiSuiteActions.test.js @@ -22,7 +22,11 @@ const mockStore = configureStore(middlewares); const testData = { test: true }; -utils.sendMessageInPromise = jest.fn((name, message) => new Promise((resolve, reject) => { +const mockSendMessageInPromise = jest.fn((dispatch, name, message) => new Promise((resolve, reject) => { + dispatch({ + type: name, + testData + }); switch (name) { case 'SET_ANTI_TRACKING': { resolve(testData); @@ -40,13 +44,18 @@ utils.sendMessageInPromise = jest.fn((name, message) => new Promise((resolve, re } })); +utils.sendMessageInPromise = mockSendMessageInPromise; + +utils.makeDeferredDispatcher = jest.fn((action, actionData) => dispatch => { + return mockSendMessageInPromise(dispatch, action, actionData); +}) + describe('app/shared-hub/actions/AntiSuiteActions', () => { test('setAdBlock action should return correctly', () => { const initialState = {}; const store = mockStore(initialState); - const data = testData; - const expectedPayload = { data, type: SET_AD_BLOCK }; + const expectedPayload = { testData, type: SET_AD_BLOCK }; return store.dispatch(AntiSuiteActions.setAdBlock()).then(() => { const actions = store.getActions(); expect(actions).toEqual([expectedPayload]); @@ -58,7 +67,7 @@ describe('app/shared-hub/actions/AntiSuiteActions', () => { const store = mockStore(initialState); const data = testData; - const expectedPayload = { data, type: SET_ANTI_TRACKING }; + const expectedPayload = { testData, type: SET_ANTI_TRACKING }; return store.dispatch(AntiSuiteActions.setAntiTracking()).then(() => { const actions = store.getActions(); expect(actions).toEqual([expectedPayload]); @@ -70,7 +79,7 @@ describe('app/shared-hub/actions/AntiSuiteActions', () => { const store = mockStore(initialState); const data = testData; - const expectedPayload = { data, type: SET_SMART_BLOCK }; + const expectedPayload = { testData, type: SET_SMART_BLOCK }; return store.dispatch(AntiSuiteActions.setSmartBlocking()).then(() => { const actions = store.getActions(); expect(actions).toEqual([expectedPayload]); diff --git a/app/shared-hub/actions/__tests__/BlockingPolicyActions.test.js b/app/shared-hub/actions/__tests__/BlockingPolicyActions.test.js index 8212cdeee..a99af2443 100644 --- a/app/shared-hub/actions/__tests__/BlockingPolicyActions.test.js +++ b/app/shared-hub/actions/__tests__/BlockingPolicyActions.test.js @@ -22,7 +22,11 @@ const mockStore = configureStore(middlewares); const testData = { test: true }; -utils.sendMessageInPromise = jest.fn((name, message) => new Promise((resolve, reject) => { +const mockSendMessageInPromise = jest.fn((dispatch, name, message) => new Promise((resolve, reject) => { + dispatch({ + type: name, + testData + }); switch (name) { case 'SET_BLOCKING_POLICY': { resolve(testData); @@ -32,13 +36,18 @@ utils.sendMessageInPromise = jest.fn((name, message) => new Promise((resolve, re } })); +utils.sendMessageInPromise = mockSendMessageInPromise; + +utils.makeDeferredDispatcher = jest.fn((action, actionData) => dispatch => { + return mockSendMessageInPromise(dispatch, action, actionData); +}) + describe('app/shared-hub/actions/BlockingPolicyActions', () => { test('setBlockingPolicy action should return correctly', () => { const initialState = {}; const store = mockStore(initialState); - const data = testData; - const expectedPayload = { data, type: SET_BLOCKING_POLICY }; + const expectedPayload = { testData, type: SET_BLOCKING_POLICY }; return store.dispatch(setBlockingPolicy()).then(() => { const actions = store.getActions(); expect(actions).toEqual([expectedPayload]); diff --git a/app/shared-hub/actions/__tests__/MetricsActions.test.js b/app/shared-hub/actions/__tests__/MetricsActions.test.js index 539a8df72..9dc24db65 100644 --- a/app/shared-hub/actions/__tests__/MetricsActions.test.js +++ b/app/shared-hub/actions/__tests__/MetricsActions.test.js @@ -22,7 +22,11 @@ const mockStore = configureStore(middlewares); const testData = { test: true }; -utils.sendMessageInPromise = jest.fn((name, message) => new Promise((resolve, reject) => { +const mockSendMessageInPromise = jest.fn((dispatch, name, message) => new Promise((resolve, reject) => { + dispatch({ + type: name, + testData + }); switch (name) { case 'SEND_PING': { resolve(testData); @@ -32,13 +36,18 @@ utils.sendMessageInPromise = jest.fn((name, message) => new Promise((resolve, re } })); +utils.sendMessageInPromise = mockSendMessageInPromise; + +utils.makeDeferredDispatcher = jest.fn((action, actionData) => dispatch => { + return mockSendMessageInPromise(dispatch, action, actionData); +}) + describe('app/shared-hub/actions/MetricsActions', () => { test('sendPing action should return correctly', () => { const initialState = {}; const store = mockStore(initialState); - const data = testData; - const expectedPayload = { data, type: SEND_PING }; + const expectedPayload = { testData, type: SEND_PING }; return store.dispatch(sendPing()).then(() => { const actions = store.getActions(); expect(actions).toEqual([expectedPayload]); diff --git a/app/shared-hub/actions/__tests__/SetupLifecycleActions.test.js b/app/shared-hub/actions/__tests__/SetupLifecycleActions.test.js index bc682dcc6..18a780804 100644 --- a/app/shared-hub/actions/__tests__/SetupLifecycleActions.test.js +++ b/app/shared-hub/actions/__tests__/SetupLifecycleActions.test.js @@ -22,7 +22,11 @@ const mockStore = configureStore(middlewares); const testData = { test: true }; -utils.sendMessageInPromise = jest.fn((name, message) => new Promise((resolve, reject) => { +const mockSendMessageInPromise = jest.fn((dispatch, name, message) => new Promise((resolve, reject) => { + dispatch({ + type: name, + testData + }); switch (name) { case 'INIT_SETUP_PROPS': { resolve(testData); @@ -40,6 +44,13 @@ utils.sendMessageInPromise = jest.fn((name, message) => new Promise((resolve, re } })); +utils.sendMessageInPromise = mockSendMessageInPromise; + +utils.makeDeferredDispatcher = jest.fn((action, actionData) => dispatch => { + return mockSendMessageInPromise(dispatch, action, actionData); +}) + + describe('app/shared-hub/actions/AntiSuiteActions', () => { test('initSetupProps action should return correctly', () => { const initialState = {}; @@ -57,7 +68,7 @@ describe('app/shared-hub/actions/AntiSuiteActions', () => { const store = mockStore(initialState); const data = testData; - const expectedPayload = { data, type: SET_SETUP_STEP }; + const expectedPayload = { testData, type: SET_SETUP_STEP }; return store.dispatch(SetupLifecycleActions.setSetupStep()).then(() => { const actions = store.getActions(); expect(actions).toEqual([expectedPayload]); @@ -69,7 +80,7 @@ describe('app/shared-hub/actions/AntiSuiteActions', () => { const store = mockStore(initialState); const data = testData; - const expectedPayload = { data, type: SET_SETUP_COMPLETE }; + const expectedPayload = { testData, type: SET_SETUP_COMPLETE }; return store.dispatch(SetupLifecycleActions.setSetupComplete()).then(() => { const actions = store.getActions(); expect(actions).toEqual([expectedPayload]); diff --git a/app/shared-hub/reducers/__tests__/AntiSuiteReducer.test.js b/app/shared-hub/reducers/__tests__/AntiSuiteReducer.test.js index 246ca814d..3bd25668f 100644 --- a/app/shared-hub/reducers/__tests__/AntiSuiteReducer.test.js +++ b/app/shared-hub/reducers/__tests__/AntiSuiteReducer.test.js @@ -17,9 +17,9 @@ import { SET_AD_BLOCK, SET_ANTI_TRACKING, SET_SMART_BLOCK } from '../../constant const initialState = Immutable({ setup: { - enable_ad_block: true, - enable_anti_tracking: true, - enable_smart_block: true + enable_ad_block: false, + enable_anti_tracking: false, + enable_smart_block: false } }); diff --git a/app/shared-hub/utils/index.js b/app/shared-hub/utils/index.js index 24b511c68..601e9eb22 100644 --- a/app/shared-hub/utils/index.js +++ b/app/shared-hub/utils/index.js @@ -20,16 +20,11 @@ import { bindActionCreators } from 'redux'; import { connect } from 'react-redux'; -import { withRouter } from 'react-router-dom'; // Imports utilities from elsewhere in the codebase to reduce duplicate code import { log } from '../../../src/utils/common'; import { sendMessage as importedSM, sendMessageInPromise as importedSMIP } from '../../panel/utils/msg'; -// Self import this file so makeDeferredDispatcher can mock the sendMessageInPromise function within the same class -// eslint-disable-next-line import/no-self-import -import * as utils from './index'; - const sendMessageInPromise = function(name, message) { return importedSMIP(name, message, 'ghostery-hub'); }; @@ -76,7 +71,7 @@ const makeStoreCreator = function(reducers, middlewares) { */ function makeDeferredDispatcher(action, actionData) { return function(dispatch) { - return utils.sendMessageInPromise(action, actionData).then((data) => { + return sendMessageInPromise(action, actionData).then((data) => { dispatch({ type: action, data, @@ -111,7 +106,7 @@ function buildReduxHOC(stateKeys, actionCreators, baseComponent) { actions: bindActionCreators(actionCreators, dispatch) }); - return withRouter(connect(mapStateToProps, mapDispatchToProps)(baseComponent)); + return connect(mapStateToProps, mapDispatchToProps)(baseComponent); } export {