diff --git a/app/ghostery-browser-hub/Views/AppView/AppView.jsx b/app/ghostery-browser-hub/Views/AppView/AppView.jsx index 6f42793e4..108d77346 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 b43f3675f..8da153fda 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..dc265c27b 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 @@ -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={() => ( -
+
@@ -50,7 +51,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 a09ada285..dbb9aef80 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 @@ -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/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..7f53c3b5d 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 @@ -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,10 @@ const WelcomeView = (props) => { }; export default WelcomeView; + +// PropTypes ensure we pass required props of the correct type +WelcomeView.propTypes = { + actions: PropTypes.shape({ + setSetupStep: PropTypes.func.isRequired + }).isRequired, +}; 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/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..c43c09c8a --- /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 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 { 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/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 33c96999c..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 @@ -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/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 new file mode 100644 index 000000000..9810bd29d --- /dev/null +++ b/app/ghostery-browser-hub/Views/OnboardingViews/Step1_CreateAccountForm/__tests__/Step1_CreateAccountForm.test.jsx @@ -0,0 +1,88 @@ +/** + * Create Account View 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 { Step1_CreateAccountForm } from '../Step1_CreateAccountForm'; + + +jest.mock('../../../../../shared-components/ToggleCheckbox', () => { + const ToggleCheckbox = () =>
; + return 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 component = renderer.create( + + + + ).toJSON(); + expect(component).toMatchSnapshot(); + }); + }); + + describe('Shallow snapshot tests rendered with Enzyme', () => { + test('the happy path of the component', () => { + const component = shallow(); + + 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 initialStateFail = { + ...initialState, + emailError: true, + confirmEmail: 'badConfirmEmail@example.com', + confirmEmailError: true, + isUpdatesChecked: false, + legalConsentChecked: false, + password: 'password', + confirmPassword: 'password', + passwordInvalidError: true, + passwordLengthError: true, + } + + 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/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 1f8044c43..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 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 new file mode 100644 index 000000000..7ab8e56a5 --- /dev/null +++ b/app/ghostery-browser-hub/Views/OnboardingViews/Step1_CreateAccountView/__tests__/Step1_CreateAccountView.test.jsx @@ -0,0 +1,61 @@ +/** + * Create Account View 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 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', () => { + const initialState = { + user: null, + actions: { + setSetupStep: noop + } + }; + describe('Snapshot tests with react-test-renderer', () => { + test('Create Account Form view is rendered correctly', () => { + 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 plusUserState = { + ...initialState, + user: { + plusAccess: true + } + }; + + const component = shallow(); + }); + }); +}); 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..ef2454236 --- /dev/null +++ b/app/ghostery-browser-hub/Views/OnboardingViews/Step1_CreateAccountView/__tests__/__snapshots__/Step1_CreateAccountView.test.jsx.snap @@ -0,0 +1,70 @@ +// 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 +
+
+
+
+
+`; 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 new file mode 100644 index 000000000..c64fb0a34 --- /dev/null +++ b/app/ghostery-browser-hub/Views/OnboardingViews/Step1_LogInForm/__tests__/Step1_LoginForm.test.jsx @@ -0,0 +1,75 @@ +/** + * Create Account View 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 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 component = renderer.create( + + + + ).toJSON(); + expect(component).toMatchSnapshot(); + }); + }); + + describe('Shallow snapshot tests rendered with Enzyme', () => { + test('the happy path of the component', () => { + const happyState = { + ...initialState, + email: 'test@example.com', + password: 'examplePassword', + handleSubmit: jest.fn(), + } + + const component = shallow(); + expect(happyState.handleSubmit.mock.calls.length).toBe(0); + component.find('form').simulate('submit'); + expect(happyState.handleSubmit.mock.calls.length).toBe(1); + }); + + test('the sad path of the component with errors', () => { + const sadState = { + ...initialState, + email: 'test@example.com', + password: 'examplePassword', + emailError: true, + passwordError: true, + handleSubmit: jest.fn(), + }; + + const component = shallow(); + + expect(sadState.handleSubmit.mock.calls.length).toBe(0); + component.find('form').simulate('submit'); + expect(sadState.handleSubmit.mock.calls.length).toBe(1); + }) + }); +}); 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 +
+
+
+
+
+ +
+
+`; 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 8ac15511a..1f2d3074c 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 @@ -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'; @@ -229,3 +230,16 @@ class BlockSettingsView extends Component { } export default BlockSettingsView; + +// PropTypes ensure we pass required props of the correct type +BlockSettingsView.propTypes = { + actions: PropTypes.shape({ + 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, + }).isRequired, +}; 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/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..5b9d5229c --- /dev/null +++ b/app/ghostery-browser-hub/Views/OnboardingViews/Step2_BlockSettingsView/__tests__/BlockSettingsView.test.jsx @@ -0,0 +1,86 @@ +/** + * BlockSettings View 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 BlockSettingsView from '../BlockSettingsView'; + +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 component = renderer.create( + + + + ).toJSON(); + expect(component).toMatchSnapshot(); + }); + }); + + describe('Shallow snapshot tests rendered with Enzyme', () => { + test('BlockSettings View happy path', () => { + const happyState = { + ...initialState, + actions: { + logout: noop, + setAntiTracking: jest.fn(), + setAdBlock: jest.fn(), + setSmartBlocking: jest.fn(), + setBlockingPolicy: jest.fn(), + setToast: noop, + setSetupStep: jest.fn(), + }, + history: { + push: noop + } + }; + const component = shallow(); + + 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(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/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/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 71ac9b443..6ca34da40 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 @@ -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,16 @@ 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) - */} + 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 +367,7 @@ class ChoosePlanView extends React.Component {
)}
- +
); } } 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/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..9457ee6e8 --- /dev/null +++ b/app/ghostery-browser-hub/Views/OnboardingViews/Step4_ChoosePlanView/__tests__/ChoosePlanView.test.jsx @@ -0,0 +1,101 @@ +/** + * ChoosePlanView 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 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 component = renderer.create( + + + + ).toJSON(); + expect(component).toMatchSnapshot(); + }); + }); + + describe('Shallow snapshot tests rendered with Enzyme', () => { + test('ChoosePlanView View with user not logged in', () => { + const component = shallow(); + + 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 basicUserState = { + ...initialState, + user: { + plusAccess: false, + premiumAccess: false + } + }; + + const component = shallow(); + + expect(component).toMatchSnapshot(); + }); + + test('ChoosePlanView View with plus user logged in', () => { + const plusUserState = { + ...initialState, + user: { + plusAccess: true, + premiumAccess: false + }, + }; + + const component = shallow(); + + expect(component).toMatchSnapshot(); + }); + + test('ChoosePlanView View with premium user logged in', () => { + const premiumUserState = { + ...initialState, + user: { + plusAccess: true, + premiumAccess: true + } + }; + + const component = shallow(); + + 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..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 @@ -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/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; 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..7136d4ad6 --- /dev/null +++ b/app/ghostery-browser-hub/Views/OnboardingViews/Step5_SuccessView/__tests__/SuccessView.test.jsx @@ -0,0 +1,37 @@ +/** + * SuccessView View 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 { MemoryRouter } from 'react-router'; +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..6508140e8 --- /dev/null +++ b/app/ghostery-browser-hub/Views/OnboardingViews/Step5_SuccessView/__tests__/__snapshots__/SuccessView.test.jsx.snap @@ -0,0 +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 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 +
+ + +
, +] +`; 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..7d52f15c1 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 @@ -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/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/__tests__/StepProgressBar.test.jsx b/app/ghostery-browser-hub/Views/OnboardingViews/StepProgressBar/__tests__/StepProgressBar.test.jsx new file mode 100644 index 000000000..a4320310e --- /dev/null +++ b/app/ghostery-browser-hub/Views/OnboardingViews/StepProgressBar/__tests__/StepProgressBar.test.jsx @@ -0,0 +1,93 @@ +/** + * 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', () => { + const initialState = { + currentStep: LOGIN, + actions: { + logout: noop + } + }; + describe('Snapshot tests with react-test-renderer', () => { + test('StepProgressBar is rendered correctly', () => { + const component = renderer.create( + + + + ).toJSON(); + expect(component).toMatchSnapshot(); + }); + }); + + describe('Shallow snapshot tests rendered with Enzyme', () => { + test('StepProgressBar View step 0', () => { + const step_0_initialState = { + ...initialState, + currentStep: WELCOME, + }; + + const component = shallow(); + + expect(component).toMatchSnapshot(); + }); + test('StepProgressBar View step 1', () => { + const step_1_initialState = { + ...initialState, + currentStep: LOGIN + }; + + const component = shallow(); + + expect(component).toMatchSnapshot(); + }); + + test('StepProgressBar View step 2', () => { + const step_2_initialState = { + ...initialState, + currentStep: BLOCK_SETTINGS + }; + + const component = shallow(); + }); + + test('StepProgressBar View step 4', () => { + const step_4_initialState = { + currentStep: CHOOSE_PLAN + }; + + const component = shallow(); + + expect(component).toMatchSnapshot(); + }); + + test('StepProgressBar View step 5', () => { + const step_5_initialState = { + ...initialState, + currentStep: SUCCESS + }; + + const component = shallow(); + + 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..e389612c4 --- /dev/null +++ b/app/ghostery-browser-hub/Views/OnboardingViews/StepProgressBar/__tests__/__snapshots__/StepProgressBar.test.jsx.snap @@ -0,0 +1,81 @@ +// 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 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 +
+
+
+
+`; 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 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', () => { 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..f61816760 --- /dev/null +++ b/app/shared-hub/actions/__tests__/AntiSuiteActions.test.js @@ -0,0 +1,88 @@ +/** + * 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_AD_BLOCK, SET_ANTI_TRACKING, SET_SMART_BLOCK } from '../../constants/AntiSuiteConstants'; + +const middlewares = [thunk]; +const mockStore = configureStore(middlewares); + +const testData = { test: true }; + +const mockSendMessageInPromise = jest.fn((dispatch, name, message) => new Promise((resolve, reject) => { + dispatch({ + type: name, + testData + }); + switch (name) { + case 'SET_ANTI_TRACKING': { + resolve(testData); + break; + } + case 'SET_AD_BLOCK': { + resolve(testData); + break; + } + case 'SET_SMART_BLOCK': { + resolve(testData); + break; + } + default: resolve(testData); + } +})); + +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 expectedPayload = { testData, type: SET_AD_BLOCK }; + return store.dispatch(AntiSuiteActions.setAdBlock()).then(() => { + const actions = store.getActions(); + expect(actions).toEqual([expectedPayload]); + }); + }); + + test('setAntiTracking action should return correctly', () => { + const initialState = {}; + const store = mockStore(initialState); + + const data = testData; + const expectedPayload = { testData, 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 = { 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 new file mode 100644 index 000000000..a99af2443 --- /dev/null +++ b/app/shared-hub/actions/__tests__/BlockingPolicyActions.test.js @@ -0,0 +1,56 @@ +/** + * 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 }; + +const mockSendMessageInPromise = jest.fn((dispatch, name, message) => new Promise((resolve, reject) => { + dispatch({ + type: name, + testData + }); + switch (name) { + case 'SET_BLOCKING_POLICY': { + resolve(testData); + break; + } + default: resolve(testData); + } +})); + +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 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 new file mode 100644 index 000000000..9dc24db65 --- /dev/null +++ b/app/shared-hub/actions/__tests__/MetricsActions.test.js @@ -0,0 +1,56 @@ +/** + * 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 }; + +const mockSendMessageInPromise = jest.fn((dispatch, name, message) => new Promise((resolve, reject) => { + dispatch({ + type: name, + testData + }); + switch (name) { + case 'SEND_PING': { + resolve(testData); + break; + } + default: resolve(testData); + } +})); + +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 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 new file mode 100644 index 000000000..18a780804 --- /dev/null +++ b/app/shared-hub/actions/__tests__/SetupLifecycleActions.test.js @@ -0,0 +1,89 @@ +/** + * 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 }; + +const mockSendMessageInPromise = jest.fn((dispatch, name, message) => new Promise((resolve, reject) => { + dispatch({ + type: name, + testData + }); + 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); + } +})); + +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 = {}; + 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 = { testData, 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 = { 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/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]); + }); +}); 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..3bd25668f --- /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: false, + enable_anti_tracking: false, + enable_smart_block: false + } +}); + +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..e0808d3f1 --- /dev/null +++ b/app/shared-hub/reducers/__tests__/ToastReducer.test.js @@ -0,0 +1,39 @@ +/** + * 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({ + toast: {} +}); + +describe('app/shared-hub/reducers/ToastReducer', () => { + test('initial state is correct', () => { + expect(ToastReducer(undefined, {})).toEqual({}); + }); + + test('reducer correctly handles SET_TOAST', () => { + const data = { + toastMessage: 'Toaster', + toastClass: 'danger' + }; + const action = { data, type: SET_TOAST }; + + const updatedToastReducerState = Immutable.merge(initialState.toast, data); + expect(ToastReducer(initialState, action)).toEqual({ + toast: updatedToastReducerState + }); + }); +}); diff --git a/app/shared-hub/utils/index.js b/app/shared-hub/utils/index.js index 55f478196..601e9eb22 100644 --- a/app/shared-hub/utils/index.js +++ b/app/shared-hub/utils/index.js @@ -20,7 +20,6 @@ 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'; @@ -107,14 +106,14 @@ function buildReduxHOC(stateKeys, actionCreators, baseComponent) { actions: bindActionCreators(actionCreators, dispatch) }); - return withRouter(connect(mapStateToProps, mapDispatchToProps)(baseComponent)); + return connect(mapStateToProps, mapDispatchToProps)(baseComponent); } export { buildReduxHOC, makeStoreCreator, - makeDeferredDispatcher, log, sendMessage, - sendMessageInPromise + sendMessageInPromise, + makeDeferredDispatcher };