diff --git a/app/dawn-hub/Views/OnboardingViews/Step2_BlockSettingsView/BlockSettingsView.jsx b/app/dawn-hub/Views/OnboardingViews/Step2_BlockSettingsView/BlockSettingsView.jsx index 594ab7a04..2fd7f1ba4 100644 --- a/app/dawn-hub/Views/OnboardingViews/Step2_BlockSettingsView/BlockSettingsView.jsx +++ b/app/dawn-hub/Views/OnboardingViews/Step2_BlockSettingsView/BlockSettingsView.jsx @@ -19,6 +19,11 @@ import Tooltip from '../../../../shared-components/Tooltip'; import RadioButton from '../../../../shared-components/RadioButton/RadioButton'; import ToggleCheckbox from '../../../../shared-components/ToggleCheckbox/ToggleCheckbox'; import { BLOCK_SETTINGS, ONBOARDING } from '../../OnboardingView/OnboardingConstants'; +import { + BLOCKING_POLICY_RECOMMENDED, + BLOCKING_POLICY_NOTHING, + BLOCKING_POLICY_EVERYTHING +} from '../../../../shared-hub/constants/BlockingPolicyConstants'; /** * @class Implement the Block Settings View for the Dawn Hub onboarding flow @@ -29,26 +34,61 @@ class BlockSettingsView extends Component { constructor(props) { super(props); this.state = { - recommendedChoices: false, - enable_ad_block: null, kindsOfTrackers: null, + enable_ad_block: null, enable_anti_tracking: null, enable_smart_block: null }; } + componentDidMount() { + const { setupLifecycle: { blockSetupSeen } } = this.props; + + if (blockSetupSeen) { + const { + enable_anti_tracking, + enable_ad_block, + enable_smart_block, + blockingPolicy + } = this.props; + + this.setState({ + kindsOfTrackers: blockingPolicy, + enable_ad_block, + enable_anti_tracking, + enable_smart_block + }); + } + } + + enumerateBlockingPolicy = (blockingPolicy) => { + let decodedPolicy; + switch (blockingPolicy) { + case BLOCKING_POLICY_EVERYTHING: + decodedPolicy = 1; + break; + case BLOCKING_POLICY_RECOMMENDED: + decodedPolicy = 2; + break; + case BLOCKING_POLICY_NOTHING: + decodedPolicy = 3; + break; + default: + break; + } + return decodedPolicy; + } + toggleRecommendedChoices = (value) => { if (value === true) { this.setState({ - recommendedChoices: true, enable_ad_block: true, - kindsOfTrackers: 2, + kindsOfTrackers: BLOCKING_POLICY_RECOMMENDED, enable_anti_tracking: true, enable_smart_block: true }); } else { this.setState({ - recommendedChoices: false, enable_ad_block: null, kindsOfTrackers: null, enable_anti_tracking: null, @@ -57,6 +97,19 @@ class BlockSettingsView extends Component { } } + recommendedChoicesActive = () => { + const { + enable_anti_tracking, + enable_ad_block, + enable_smart_block, + kindsOfTrackers + } = this.state; + if (kindsOfTrackers === BLOCKING_POLICY_RECOMMENDED && enable_ad_block === true && enable_anti_tracking === true && enable_smart_block === true) { + return true; + } + return false; + } + handleAnswerChange = (category, answer) => { this.setState({ [category]: answer }); } @@ -71,7 +124,7 @@ class BlockSettingsView extends Component { } = this.state; const partOne = (enable_ad_block) ? '1' : '2'; - const partTwo = kindsOfTrackers.toString(); + const partTwo = this.enumerateBlockingPolicy(kindsOfTrackers); const partThree = (enable_anti_tracking) ? '1' : '2'; const partFour = (enable_smart_block) ? '1' : '2'; @@ -94,7 +147,7 @@ class BlockSettingsView extends Component { }); const { - setAdBlock, setAntiTracking, setSmartBlocking, setBlockingPolicy, setSetupStep + setAdBlock, setAntiTracking, setSmartBlocking, setBlockingPolicy, setSetupStep, setBlockSetupSeen } = actions; const { history } = this.props; @@ -102,27 +155,14 @@ class BlockSettingsView extends Component { setAntiTracking({ enable_anti_tracking }); setSmartBlocking({ enable_smart_block }); - let blockingPolicy; - switch (kindsOfTrackers) { - case 1: - blockingPolicy = 'BLOCKING_POLICY_EVERYTHING'; - break; - case 2: - blockingPolicy = 'BLOCKING_POLICY_RECOMMENDED'; - break; - case 3: - blockingPolicy = 'BLOCKING_POLICY_NOTHING'; - break; - default: - break; - } - setBlockingPolicy({ blockingPolicy }); + setBlockingPolicy({ blockingPolicy: kindsOfTrackers }); setSetupStep({ setup_step: BLOCK_SETTINGS, dawn_setup_number: this.buildSetupNumberString(), origin: ONBOARDING }); + setBlockSetupSeen(true); history.push('/onboarding/3'); } else { setToast({ @@ -132,6 +172,24 @@ class BlockSettingsView extends Component { } } + renderQuestion = (question, tooltip = null) => { + if (tooltip) { + return ( +
  • +
    + {question} +
    + +
    +
    +
  • + ); + } + return ( +
  • {question}
  • + ); + } + renderAnswerBlock = (checked, category, answer, label) => (
    this.handleAnswerChange(category, answer)}>
    @@ -143,10 +201,12 @@ class BlockSettingsView extends Component { render() { const { - recommendedChoices, enable_ad_block, kindsOfTrackers, enable_anti_tracking, enable_smart_block + enable_ad_block, kindsOfTrackers, enable_anti_tracking, enable_smart_block } = this.state; const { actions } = this.props; const { logout } = actions; + + const recommendedChoicesActive = this.recommendedChoicesActive(); return (
    @@ -164,44 +224,23 @@ class BlockSettingsView extends Component {
    this.toggleRecommendedChoices(!recommendedChoices)} + checked={recommendedChoicesActive} + onChange={() => this.toggleRecommendedChoices(!recommendedChoicesActive)} /> -
    this.toggleRecommendedChoices(!recommendedChoices)}>{t('ghostery_dawn_onboarding_recommended_choices')}
    +
    this.toggleRecommendedChoices(!recommendedChoicesActive)}>{t('ghostery_dawn_onboarding_recommended_choices')}
      -
    1. {t('ghostery_dawn_onboarding_question_block_ads')}
    2. + {this.renderQuestion(t('ghostery_dawn_onboarding_question_block_ads'))} {this.renderAnswerBlock((enable_ad_block === true), 'enable_ad_block', true, t('hub_setup_modal_button_yes'))} {this.renderAnswerBlock((enable_ad_block === false), 'enable_ad_block', false, t('hub_setup_modal_button_no'))} -
    3. -
      - {t('ghostery_dawn_onboarding_question_kinds_of_trackers')} -
      - -
      -
      -
    4. - {this.renderAnswerBlock((kindsOfTrackers === 1), 'kindsOfTrackers', 1, t('ghostery_dawn_onboarding_kinds_of_trackers_all'))} - {this.renderAnswerBlock((kindsOfTrackers === 2), 'kindsOfTrackers', 2, t('ghostery_dawn_onboarding_kinds_of_trackers_ad_and_analytics'))} - {this.renderAnswerBlock((kindsOfTrackers === 3), 'kindsOfTrackers', 3, t('ghostery_dawn_onboarding_kinds_of_trackers_none'))} -
    5. -
      - {t('ghostery_dawn_onboarding_question_anti_tracking')} -
      - -
      -
      -
    6. + {this.renderQuestion(t('ghostery_dawn_onboarding_question_kinds_of_trackers'), t('ghostery_dawn_onboarding_info_blocking_all'))} + {this.renderAnswerBlock((kindsOfTrackers === BLOCKING_POLICY_EVERYTHING), 'kindsOfTrackers', BLOCKING_POLICY_EVERYTHING, t('ghostery_dawn_onboarding_kinds_of_trackers_all'))} + {this.renderAnswerBlock((kindsOfTrackers === BLOCKING_POLICY_RECOMMENDED), 'kindsOfTrackers', BLOCKING_POLICY_RECOMMENDED, t('ghostery_dawn_onboarding_kinds_of_trackers_ad_and_analytics'))} + {this.renderAnswerBlock((kindsOfTrackers === BLOCKING_POLICY_NOTHING), 'kindsOfTrackers', BLOCKING_POLICY_NOTHING, t('ghostery_dawn_onboarding_kinds_of_trackers_none'))} + {this.renderQuestion(t('ghostery_dawn_onboarding_question_anti_tracking'), t('ghostery_dawn_onboarding_info_anti_tracking'))} {this.renderAnswerBlock((enable_anti_tracking === true), 'enable_anti_tracking', true, t('hub_setup_modal_button_yes'))} {this.renderAnswerBlock((enable_anti_tracking === false), 'enable_anti_tracking', false, t('hub_setup_modal_button_no'))} -
    7. -
      - {t('ghostery_dawn_onboarding_question_smart_browsing')} -
      - -
      -
      -
    8. + {this.renderQuestion(t('ghostery_dawn_onboarding_question_smart_browsing'), t('ghostery_dawn_onboarding_info_smart_browsing'))} {this.renderAnswerBlock((enable_smart_block === true), 'enable_smart_block', true, t('hub_setup_modal_button_yes'))} {this.renderAnswerBlock((enable_smart_block === false), 'enable_smart_block', false, t('hub_setup_modal_button_no'))}
    @@ -231,5 +270,13 @@ BlockSettingsView.propTypes = { setBlockingPolicy: PropTypes.func.isRequired, setToast: PropTypes.func.isRequired, setSetupStep: PropTypes.func.isRequired, + setBlockSetupSeen: PropTypes.func.isRequired, + }).isRequired, + setupLifecycle: PropTypes.shape({ + blockSetupSeen: PropTypes.bool.isRequired, }).isRequired, + enable_ad_block: PropTypes.bool.isRequired, + enable_anti_tracking: PropTypes.bool.isRequired, + enable_smart_block: PropTypes.bool.isRequired, + blockingPolicy: PropTypes.string.isRequired }; diff --git a/app/dawn-hub/Views/OnboardingViews/Step2_BlockSettingsView/__tests__/BlockSettingsView.test.jsx b/app/dawn-hub/Views/OnboardingViews/Step2_BlockSettingsView/__tests__/BlockSettingsView.test.jsx index 614643426..673862770 100644 --- a/app/dawn-hub/Views/OnboardingViews/Step2_BlockSettingsView/__tests__/BlockSettingsView.test.jsx +++ b/app/dawn-hub/Views/OnboardingViews/Step2_BlockSettingsView/__tests__/BlockSettingsView.test.jsx @@ -16,12 +16,22 @@ import renderer from 'react-test-renderer'; import { shallow } from 'enzyme'; import { MemoryRouter } from 'react-router'; import BlockSettingsView from '../BlockSettingsView'; +import { + BLOCKING_POLICY_RECOMMENDED, +} from '../../../../../shared-hub/constants/BlockingPolicyConstants'; const noop = () => {}; jest.mock('../../../../../shared-components/Tooltip'); describe('app/dawn-hub/Views/OnboardingViews/Step2_BlockSettingsView/BlockSettingsView.test.jsx', () => { const initialState = { + setupLifecycle: { + blockSetupSeen: false + }, + blockingPolicy: '', + enable_ad_block: false, + enable_anti_tracking: false, + enable_smart_block: false, actions: { logout: noop, setAntiTracking: noop, @@ -30,7 +40,8 @@ describe('app/dawn-hub/Views/OnboardingViews/Step2_BlockSettingsView/BlockSettin setBlockingPolicy: noop, setToast: noop, setSetupStep: noop, - } + setBlockSetupSeen: noop, + }, }; describe('Snapshot tests with react-test-renderer', () => { test('BlockSettings View is rendered correctly', () => { @@ -55,6 +66,7 @@ describe('app/dawn-hub/Views/OnboardingViews/Step2_BlockSettingsView/BlockSettin setBlockingPolicy: jest.fn(), setToast: noop, setSetupStep: jest.fn(), + setBlockSetupSeen: jest.fn(), }, history: { push: noop @@ -66,7 +78,7 @@ describe('app/dawn-hub/Views/OnboardingViews/Step2_BlockSettingsView/BlockSettin instance.toggleRecommendedChoices(true); expect(component.state('enable_ad_block')).toBe(true); - expect(component.state('kindsOfTrackers')).toBe(2); + expect(component.state('kindsOfTrackers')).toBe(BLOCKING_POLICY_RECOMMENDED); expect(component.state('enable_anti_tracking')).toBe(true); expect(component.state('enable_smart_block')).toBe(true); diff --git a/app/dawn-hub/Views/OnboardingViews/Step2_BlockSettingsView/index.js b/app/dawn-hub/Views/OnboardingViews/Step2_BlockSettingsView/index.js index ec60917d4..6392f43ed 100644 --- a/app/dawn-hub/Views/OnboardingViews/Step2_BlockSettingsView/index.js +++ b/app/dawn-hub/Views/OnboardingViews/Step2_BlockSettingsView/index.js @@ -18,7 +18,7 @@ import { logout } from '../../../../Account/AccountActions'; import { setAntiTracking, setAdBlock, setSmartBlocking } from '../../../../shared-hub/actions/AntiSuiteActions'; import setBlockingPolicy from '../../../../shared-hub/actions/BlockingPolicyActions'; import setToast from '../../../../shared-hub/actions/ToastActions'; -import { setSetupStep } from '../../../../shared-hub/actions/SetupLifecycleActions'; +import { setSetupStep, setBlockSetupSeen } from '../../../../shared-hub/actions/SetupLifecycleActions'; const actionCreators = { logout, @@ -26,8 +26,9 @@ const actionCreators = { setAdBlock, setSmartBlocking, setBlockingPolicy, + setBlockSetupSeen, setToast, setSetupStep, }; -export default withRouter(buildReduxHOC(null, actionCreators, BlockSettingsView)); +export default withRouter(buildReduxHOC(['setupLifecycle', 'antiSuite', 'blockingPolicy'], actionCreators, BlockSettingsView)); diff --git a/app/dawn-hub/Views/OnboardingViews/Step3_ChooseDefaultSearchView/ChooseDefaultSearchView.jsx b/app/dawn-hub/Views/OnboardingViews/Step3_ChooseDefaultSearchView/ChooseDefaultSearchView.jsx index 1b9cae45d..8e342ecad 100644 --- a/app/dawn-hub/Views/OnboardingViews/Step3_ChooseDefaultSearchView/ChooseDefaultSearchView.jsx +++ b/app/dawn-hub/Views/OnboardingViews/Step3_ChooseDefaultSearchView/ChooseDefaultSearchView.jsx @@ -76,6 +76,21 @@ class ChooseDefaultSearchView extends Component { document.addEventListener('click', this.handleClickAway); this.fetchSearchEnginesAsync(); + + const { setupLifecycle: { searchSetupSeen } } = this.props; + + if (searchSetupSeen) { + const { defaultSearch } = this.props; + const searchChoices = [ + SEARCH_GHOSTERY, + SEARCH_BING, + SEARCH_YAHOO, + SEARCH_STARTPAGE, + ]; + const isOther = !searchChoices.includes(defaultSearch); + const prevChosenSearch = isOther ? SEARCH_OTHER : defaultSearch; + this.setState({ chosenSearch: prevChosenSearch, otherSearchSelected: isOther ? defaultSearch : null }); + } } componentWillUnmount() { @@ -138,7 +153,7 @@ class ChooseDefaultSearchView extends Component { handleSubmit = () => { const { chosenSearch, otherSearchSelected } = this.state; const { actions, history } = this.props; - const { setSetupStep, setDefaultSearch } = actions; + const { setSetupStep, setDefaultSearch, setSearchSetupSeen } = actions; const chosenSearchName = chosenSearch === SEARCH_OTHER ? otherSearchSelected @@ -171,6 +186,7 @@ class ChooseDefaultSearchView extends Component { dawn_setup_number, origin: ONBOARDING }); + setSearchSetupSeen(true); history.push(`/${ONBOARDING}/${CHOOSE_PLAN}`); } diff --git a/app/dawn-hub/Views/OnboardingViews/Step3_ChooseDefaultSearchView/index.js b/app/dawn-hub/Views/OnboardingViews/Step3_ChooseDefaultSearchView/index.js index bd33072be..ec5f910ad 100644 --- a/app/dawn-hub/Views/OnboardingViews/Step3_ChooseDefaultSearchView/index.js +++ b/app/dawn-hub/Views/OnboardingViews/Step3_ChooseDefaultSearchView/index.js @@ -15,11 +15,12 @@ import { withRouter } from 'react-router-dom'; import ChooseDefaultSearchView from './ChooseDefaultSearchView'; import { buildReduxHOC } from '../../../../shared-hub/utils'; import setDefaultSearch from './ChooseDefaultSearchActions'; -import { setSetupStep } from '../../../../shared-hub/actions/SetupLifecycleActions'; +import { setSetupStep, setSearchSetupSeen } from '../../../../shared-hub/actions/SetupLifecycleActions'; const actionCreators = { setDefaultSearch, setSetupStep, + setSearchSetupSeen, }; -export default withRouter(buildReduxHOC(null, actionCreators, ChooseDefaultSearchView)); +export default withRouter(buildReduxHOC(['setupLifecycle', 'defaultSearch'], actionCreators, ChooseDefaultSearchView)); diff --git a/app/shared-hub/actions/SetupLifecycleActions.js b/app/shared-hub/actions/SetupLifecycleActions.js index 3f40698e9..bb93c9c9e 100644 --- a/app/shared-hub/actions/SetupLifecycleActions.js +++ b/app/shared-hub/actions/SetupLifecycleActions.js @@ -15,7 +15,9 @@ import { makeDeferredDispatcher } from '../utils'; import { INIT_SETUP_PROPS, SET_SETUP_STEP, - SET_SETUP_COMPLETE + SET_SETUP_COMPLETE, + SET_BLOCK_SETUP_SEEN, + SET_SEARCH_SETUP_SEEN } from '../constants/SetupLifecycleConstants'; export function initSetupProps(data) { @@ -25,6 +27,20 @@ export function initSetupProps(data) { }; } +export const setBlockSetupSeen = data => ( + { + type: SET_BLOCK_SETUP_SEEN, + data, + } +); + +export const setSearchSetupSeen = data => ( + { + type: SET_SEARCH_SETUP_SEEN, + data, + } +); + export const setSetupStep = actionData => makeDeferredDispatcher(SET_SETUP_STEP, actionData); diff --git a/app/shared-hub/constants/SetupLifecycleConstants.js b/app/shared-hub/constants/SetupLifecycleConstants.js index 97c968d3e..5fe3c3fb9 100644 --- a/app/shared-hub/constants/SetupLifecycleConstants.js +++ b/app/shared-hub/constants/SetupLifecycleConstants.js @@ -14,3 +14,5 @@ export const INIT_SETUP_PROPS = 'INIT_SETUP_PROPS'; export const SET_SETUP_STEP = 'SET_SETUP_STEP'; export const SET_SETUP_COMPLETE = 'SET_SETUP_COMPLETE'; +export const SET_BLOCK_SETUP_SEEN = 'SET_BLOCK_SETUP_SEEN'; +export const SET_SEARCH_SETUP_SEEN = 'SET_SEARCH_SETUP_SEEN'; diff --git a/app/shared-hub/reducers/AntiSuiteReducer.js b/app/shared-hub/reducers/AntiSuiteReducer.js index 458ce5558..eb184e603 100644 --- a/app/shared-hub/reducers/AntiSuiteReducer.js +++ b/app/shared-hub/reducers/AntiSuiteReducer.js @@ -17,21 +17,25 @@ import { SET_SMART_BLOCK } from '../constants/AntiSuiteConstants'; -const initialState = {}; +const initialState = { + enable_ad_block: false, + enable_anti_tracking: false, + enable_smart_block: false +}; function AntiSuiteReducer(state = initialState, action) { switch (action.type) { case SET_AD_BLOCK: { const { enable_ad_block } = action.data; - return { ...state, setup: { ...state.setup, enable_ad_block } }; + return { ...state, enable_ad_block }; } case SET_ANTI_TRACKING: { const { enable_anti_tracking } = action.data; - return { ...state, setup: { ...state.setup, enable_anti_tracking } }; + return { ...state, enable_anti_tracking }; } case SET_SMART_BLOCK: { const { enable_smart_block } = action.data; - return { ...state, setup: { ...state.setup, enable_smart_block } }; + return { ...state, enable_smart_block }; } default: return state; diff --git a/app/shared-hub/reducers/BlockingPolicyReducer.js b/app/shared-hub/reducers/BlockingPolicyReducer.js index 81e677584..8c2710bfa 100644 --- a/app/shared-hub/reducers/BlockingPolicyReducer.js +++ b/app/shared-hub/reducers/BlockingPolicyReducer.js @@ -13,13 +13,15 @@ import { SET_BLOCKING_POLICY } from '../constants/BlockingPolicyConstants'; -const initialState = {}; +const initialState = { + blockingPolicy: '' +}; function BlockingPolicyReducer(state = initialState, action) { switch (action.type) { case SET_BLOCKING_POLICY: { const { blockingPolicy } = action.data; - return { ...state, setup: { ...state.setup, blockingPolicy } }; + return { ...state, blockingPolicy }; } default: return state; diff --git a/app/shared-hub/reducers/SetupLifecycleReducer.js b/app/shared-hub/reducers/SetupLifecycleReducer.js index 3d30ac6c8..2e6dbc272 100644 --- a/app/shared-hub/reducers/SetupLifecycleReducer.js +++ b/app/shared-hub/reducers/SetupLifecycleReducer.js @@ -12,10 +12,19 @@ */ import { - INIT_SETUP_PROPS + INIT_SETUP_PROPS, SET_BLOCK_SETUP_SEEN, SET_SEARCH_SETUP_SEEN } from '../constants/SetupLifecycleConstants'; -const initialState = {}; +const initialState = { + setupLifecycle: { + blockingPolicy: '', + enable_anti_tracking: false, + enable_ad_block: false, + enable_smart_block: false, + blockSetupSeen: false, + searchSetupSeen: false + } +}; function SetupLifecycleReducer(state = initialState, action) { switch (action.type) { @@ -29,14 +38,22 @@ function SetupLifecycleReducer(state = initialState, action) { } = action.data; return { ...state, - setup: { + setupLifecycle: { blockingPolicy, enable_anti_tracking, enable_ad_block, enable_smart_block, + blockSetupSeen: false, + searchSetupSeen: false } }; } + case SET_BLOCK_SETUP_SEEN: { + return { ...state, setupLifecycle: { ...state.setupLifecycle, blockSetupSeen: action.data } }; + } + case SET_SEARCH_SETUP_SEEN: { + return { ...state, setupLifecycle: { ...state.setupLifecycle, searchSetupSeen: action.data } }; + } default: return state; } diff --git a/app/shared-hub/reducers/__tests__/AntiSuiteReducer.test.js b/app/shared-hub/reducers/__tests__/AntiSuiteReducer.test.js index 3bd25668f..869898144 100644 --- a/app/shared-hub/reducers/__tests__/AntiSuiteReducer.test.js +++ b/app/shared-hub/reducers/__tests__/AntiSuiteReducer.test.js @@ -16,16 +16,14 @@ 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 - } + 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({}); + expect(AntiSuiteReducer(undefined, {})).toEqual({...initialState}); }); test('reducer correctly handles SET_AD_BLOCK', () => { @@ -34,10 +32,10 @@ describe('app/shared-hub/reducers/AntiSuiteReducer', () => { }; const action = { data, type: SET_AD_BLOCK }; - const updatedAntiSuiteState = Immutable.merge(initialState.setup, data); + const updatedAntiSuiteState = Immutable.merge(initialState, data); expect(AntiSuiteReducer(initialState, action)).toEqual({ - setup: updatedAntiSuiteState + ...updatedAntiSuiteState }); }); @@ -47,10 +45,10 @@ describe('app/shared-hub/reducers/AntiSuiteReducer', () => { }; const action = { data, type: SET_ANTI_TRACKING }; - const updatedAntiSuiteState = Immutable.merge(initialState.setup, data); + const updatedAntiSuiteState = Immutable.merge(initialState, data); expect(AntiSuiteReducer(initialState, action)).toEqual({ - setup: updatedAntiSuiteState + ...updatedAntiSuiteState }); }); @@ -60,10 +58,10 @@ describe('app/shared-hub/reducers/AntiSuiteReducer', () => { }; const action = { data, type: SET_SMART_BLOCK }; - const updatedAntiSuiteState = Immutable.merge(initialState.setup, data); + const updatedAntiSuiteState = Immutable.merge(initialState, data); expect(AntiSuiteReducer(initialState, action)).toEqual({ - setup: updatedAntiSuiteState + ...updatedAntiSuiteState }); }); }); diff --git a/app/shared-hub/reducers/__tests__/BlockingPolicyReducer.test.js b/app/shared-hub/reducers/__tests__/BlockingPolicyReducer.test.js index b97efc8b1..9aa6d0f2c 100644 --- a/app/shared-hub/reducers/__tests__/BlockingPolicyReducer.test.js +++ b/app/shared-hub/reducers/__tests__/BlockingPolicyReducer.test.js @@ -16,26 +16,24 @@ import BlockingPolicyReducer from '../BlockingPolicyReducer'; import { SET_BLOCKING_POLICY } from '../../constants/BlockingPolicyConstants'; const initialState = Immutable({ - setup: { - blockingPolicy: true - } + blockingPolicy: '' }); describe('app/shared-hub/reducers/BlockingPolicy', () => { test('initial state is correct', () => { - expect(BlockingPolicyReducer(undefined, {})).toEqual({}); + expect(BlockingPolicyReducer(undefined, {})).toEqual({...initialState}); }); test('reducer correctly handles SET_BLOCKING_POLICY', () => { const data = { - blockingPolicy: true, + blockingPolicy: 'BLOCKING_POLICY_RECOMMENDED', }; const action = { data, type: SET_BLOCKING_POLICY }; - const updatedBlockingPolicyState = Immutable.merge(initialState.setup, data); + const updatedBlockingPolicyState = Immutable.merge(initialState, data); expect(BlockingPolicyReducer(initialState, action)).toEqual({ - setup: updatedBlockingPolicyState + ...updatedBlockingPolicyState }); }); }); diff --git a/app/shared-hub/reducers/__tests__/SetupLifeCycleReducer.test.js b/app/shared-hub/reducers/__tests__/SetupLifeCycleReducer.test.js index 49659a6c1..e1772d4b9 100644 --- a/app/shared-hub/reducers/__tests__/SetupLifeCycleReducer.test.js +++ b/app/shared-hub/reducers/__tests__/SetupLifeCycleReducer.test.js @@ -16,27 +16,36 @@ import SetupLifecycleReducer from '../SetupLifecycleReducer'; import { INIT_SETUP_PROPS } from '../../constants/SetupLifecycleConstants'; const initialState = Immutable({ - setup: {} + setupLifecycle: { + blockingPolicy: '', + enable_anti_tracking: false, + enable_ad_block: false, + enable_smart_block: false, + blockSetupSeen: false, + searchSetupSeen: false + } }); describe('app/shared-hub/reducers/SetupLifecycleReducer', () => { test('initial state is correct', () => { - expect(SetupLifecycleReducer(undefined, {})).toEqual({}); + expect(SetupLifecycleReducer(undefined, {})).toEqual({...initialState}); }); test('reducer correctly handles INIT_SETUP_PROPS', () => { const data = { - blockingPolicy: true, + blockingPolicy: 'BLOCKING_POLICY_RECOMMENDED', enable_anti_tracking: true, enable_ad_block: true, enable_smart_block: true, + blockSetupSeen: false, + searchSetupSeen: false }; const action = { data, type: INIT_SETUP_PROPS }; - const updatedSetupLifecycleState = Immutable.merge(initialState.setup, data); + const updatedSetupLifecycleState = Immutable.merge(initialState.setupLifecycle, data); expect(SetupLifecycleReducer(initialState, action)).toEqual({ - setup: updatedSetupLifecycleState + setupLifecycle: updatedSetupLifecycleState }); }); });