From b6c8f7e3b2afcb283fb7b7fa80546c416228b374 Mon Sep 17 00:00:00 2001 From: Ben Warzeski Date: Fri, 2 Dec 2022 10:33:52 -0500 Subject: [PATCH] Fix: More tracking fixes (#82) --- src/__snapshots__/index.test.jsx.snap | 11 +++++++- .../EnterpriseDashboardModal/hooks.js | 6 ++--- .../EnterpriseDashboardModal/hooks.test.js | 26 ++++++++++++------- src/index.jsx | 15 ++++++++--- src/test/app.test.jsx | 4 +++ 5 files changed, 46 insertions(+), 16 deletions(-) diff --git a/src/__snapshots__/index.test.jsx.snap b/src/__snapshots__/index.test.jsx.snap index cf7b63d..fed133f 100644 --- a/src/__snapshots__/index.test.jsx.snap +++ b/src/__snapshots__/index.test.jsx.snap @@ -21,7 +21,16 @@ exports[`app registry subscribe: APP_READY. links App to root element 1`] = ` } } > - + + + + + + `; diff --git a/src/containers/EnterpriseDashboardModal/hooks.js b/src/containers/EnterpriseDashboardModal/hooks.js index 5c21dcf..0e03b61 100644 --- a/src/containers/EnterpriseDashboardModal/hooks.js +++ b/src/containers/EnterpriseDashboardModal/hooks.js @@ -16,9 +16,9 @@ export const useEnterpriseDashboardHook = () => { const [showModal, setShowModal] = module.state.showModal(true); const dashboard = appHooks.useEnterpriseDashboardData(); - const trackOpened = () => modalOpened(dashboard.enterpriseUUID); - const trackClose = () => modalClosed(dashboard.enterpriseUUID, 'Cancel button'); - const trackEscape = () => modalClosed(dashboard.enterpriseUUID, 'Escape'); + const trackOpened = modalOpened(dashboard.enterpriseUUID); + const trackClose = modalClosed(dashboard.enterpriseUUID, 'Cancel button'); + const trackEscape = modalClosed(dashboard.enterpriseUUID, 'Escape'); const handleCTAClick = () => { modalCTAClicked(dashboard.enterpriseUUID, dashboard.url); diff --git a/src/containers/EnterpriseDashboardModal/hooks.test.js b/src/containers/EnterpriseDashboardModal/hooks.test.js index 9d8b24d..a3fb6d4 100644 --- a/src/containers/EnterpriseDashboardModal/hooks.test.js +++ b/src/containers/EnterpriseDashboardModal/hooks.test.js @@ -9,16 +9,24 @@ jest.mock('data/redux', () => ({ useEnterpriseDashboardData: jest.fn(), }, })); -jest.mock('tracking', () => ({ - __esModule: true, - default: { - enterpriseDashboard: { - modalOpened: jest.fn(), - modalClosed: jest.fn(), - modalCTAClicked: jest.fn(), +jest.mock('tracking', () => { + const modalOpenedEvent = jest.fn(); + const modalClosedEvent = jest.fn(); + const modalCTAClickedEvent = jest.fn(); + return { + __esModule: true, + default: { + enterpriseDashboard: { + modalOpenedEvent, + modalClosedEvent, + modalCTAClickedEvent, + modalOpened: jest.fn(() => modalOpenedEvent), + modalClosed: jest.fn(() => modalClosedEvent), + modalCTAClicked: jest.fn(() => modalCTAClickedEvent), + }, }, - }, -})); + }; +}); const state = new MockUseState(hooks); diff --git a/src/index.jsx b/src/index.jsx index 3784b92..9f2984a 100755 --- a/src/index.jsx +++ b/src/index.jsx @@ -4,8 +4,13 @@ import 'regenerator-runtime/runtime'; import React from 'react'; import ReactDOM from 'react-dom'; -import { AppProvider, ErrorPage } from '@edx/frontend-platform/react'; +import { Switch, Redirect } from 'react-router-dom'; +import { + AppProvider, + ErrorPage, + PageRoute, +} from '@edx/frontend-platform/react'; import store from 'data/store'; import { APP_READY, @@ -16,7 +21,6 @@ import { } from '@edx/frontend-platform'; import { messages as footerMessages } from '@edx/frontend-component-footer'; - import { IntlProvider } from '@edx/frontend-platform/i18n'; import { configuration } from './config'; @@ -28,7 +32,12 @@ subscribe(APP_READY, () => { ReactDOM.render( - + + + + + + , document.getElementById('root'), diff --git a/src/test/app.test.jsx b/src/test/app.test.jsx index 16491e9..09663c4 100644 --- a/src/test/app.test.jsx +++ b/src/test/app.test.jsx @@ -71,6 +71,10 @@ jest.mock('@edx/frontend-platform/auth', () => ({ getLoginRedirectUrl: jest.fn(), })); +jest.mock('@edx/frontend-platform/analytics', () => ({ + sendTrackEvent: jest.fn(), +})); + const configureStore = () => redux.createStore( reducers, redux.compose(redux.applyMiddleware(thunk)),