diff --git a/src/components/CommonKit/ErrorPage/ErrorPage.spec.tsx b/src/components/Ecogesture/EcogestureNotFound/EcogestureNotFound.spec.tsx similarity index 72% rename from src/components/CommonKit/ErrorPage/ErrorPage.spec.tsx rename to src/components/Ecogesture/EcogestureNotFound/EcogestureNotFound.spec.tsx index d47cc5c52f26a4903135858886fcf1a548f328cd..9be727a778cd04ebaf2e275cca80ad241fe8f4b4 100644 --- a/src/components/CommonKit/ErrorPage/ErrorPage.spec.tsx +++ b/src/components/Ecogesture/EcogestureNotFound/EcogestureNotFound.spec.tsx @@ -3,7 +3,7 @@ import { Button } from '@material-ui/core' import { mount } from 'enzyme' import toJson from 'enzyme-to-json' import React from 'react' -import ErrorPage from './ErrorPage' +import EcogestureNotFound from './EcogestureNotFound' const mockedNavigate = jest.fn() jest.mock('react-router-dom', () => ({ @@ -15,14 +15,18 @@ jest.mock('components/Header/Header', () => 'mock-header') jest.mock('components/Header/CozyBar', () => 'mock-cozybar') jest.mock('components/Content/Content', () => 'mock-content') -describe('ErrorPage component', () => { +describe('EcogestureNotFound component', () => { it('should be rendered correctly', async () => { - const wrapper = mount(<ErrorPage text="test" returnPage="ecogestures" />) + const wrapper = mount( + <EcogestureNotFound text="test" returnPage="ecogestures" /> + ) expect(toJson(wrapper)).toMatchSnapshot() }) it('should click on button and be redirected', () => { - const wrapper = mount(<ErrorPage text="test" returnPage="ecogestures" />) + const wrapper = mount( + <EcogestureNotFound text="test" returnPage="ecogestures" /> + ) wrapper.find(Button).simulate('click') expect(mockedNavigate).toHaveBeenCalledWith('/ecogestures') }) diff --git a/src/components/CommonKit/ErrorPage/ErrorPage.tsx b/src/components/Ecogesture/EcogestureNotFound/EcogestureNotFound.tsx similarity index 90% rename from src/components/CommonKit/ErrorPage/ErrorPage.tsx rename to src/components/Ecogesture/EcogestureNotFound/EcogestureNotFound.tsx index fcf61d99a24ded0be4f01b4bca42026a56aa2f86..3c1ac059eac4a6918cee3f152da6ee5628a524ec 100644 --- a/src/components/CommonKit/ErrorPage/ErrorPage.tsx +++ b/src/components/Ecogesture/EcogestureNotFound/EcogestureNotFound.tsx @@ -7,14 +7,15 @@ import Header from 'components/Header/Header' import { useI18n } from 'cozy-ui/transpiled/react/I18n' import React, { useState } from 'react' import { useNavigate } from 'react-router-dom' -import './errorPage.scss' +import './ecogestureNotFound.scss' -interface ErrorPageProps { +const EcogestureNotFound = ({ + text, + returnPage, +}: { text: string returnPage: string -} - -const ErrorPage = ({ text, returnPage }: ErrorPageProps) => { +}) => { const { t } = useI18n() const navigate = useNavigate() const [headerHeight, setHeaderHeight] = useState<number>(0) @@ -49,4 +50,4 @@ const ErrorPage = ({ text, returnPage }: ErrorPageProps) => { ) } -export default ErrorPage +export default EcogestureNotFound diff --git a/src/components/CommonKit/ErrorPage/__snapshots__/ErrorPage.spec.tsx.snap b/src/components/Ecogesture/EcogestureNotFound/__snapshots__/EcogestureNotFound.spec.tsx.snap similarity index 98% rename from src/components/CommonKit/ErrorPage/__snapshots__/ErrorPage.spec.tsx.snap rename to src/components/Ecogesture/EcogestureNotFound/__snapshots__/EcogestureNotFound.spec.tsx.snap index f49c1b48e180abeb6e48f244166bf46494b3f9ba..fe29324f57d34c47b991df4cbeb5524913c797b5 100644 --- a/src/components/CommonKit/ErrorPage/__snapshots__/ErrorPage.spec.tsx.snap +++ b/src/components/Ecogesture/EcogestureNotFound/__snapshots__/EcogestureNotFound.spec.tsx.snap @@ -1,7 +1,7 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`ErrorPage component should be rendered correctly 1`] = ` -<ErrorPage +exports[`EcogestureNotFound component should be rendered correctly 1`] = ` +<EcogestureNotFound returnPage="ecogestures" text="test" > @@ -193,5 +193,5 @@ exports[`ErrorPage component should be rendered correctly 1`] = ` </WithStyles(ForwardRef(Button))> </div> </mock-content> -</ErrorPage> +</EcogestureNotFound> `; diff --git a/src/components/CommonKit/ErrorPage/errorPage.scss b/src/components/Ecogesture/EcogestureNotFound/ecogestureNotFound.scss similarity index 100% rename from src/components/CommonKit/ErrorPage/errorPage.scss rename to src/components/Ecogesture/EcogestureNotFound/ecogestureNotFound.scss diff --git a/src/components/Ecogesture/SingleEcogestureView.tsx b/src/components/Ecogesture/SingleEcogestureView.tsx index 6db69d51859289513084d4c264962872821c0765..3f9b7cefb326293d6dc88a4ff15f014c28a7a903 100644 --- a/src/components/Ecogesture/SingleEcogestureView.tsx +++ b/src/components/Ecogesture/SingleEcogestureView.tsx @@ -1,13 +1,14 @@ import { Collapse } from '@material-ui/core' import IconButton from '@material-ui/core/IconButton' +import * as Sentry from '@sentry/react' import doingDisabledIcon from 'assets/icons/ico/doing-disabled.svg' import doingEnabledIcon from 'assets/icons/ico/doing-enabled.svg' import objectiveDisabledIcon from 'assets/icons/ico/objective-disabled.svg' import objectiveEnabledIcon from 'assets/icons/ico/objective-enabled.svg' import defaultIcon from 'assets/icons/visu/ecogesture/default.svg' -import ErrorPage from 'components/CommonKit/ErrorPage/ErrorPage' import StyledIcon from 'components/CommonKit/Icon/StyledIcon' import Content from 'components/Content/Content' +import ErrorPage from 'components/Ecogesture/EcogestureNotFound/EcogestureNotFound' import CozyBar from 'components/Header/CozyBar' import Header from 'components/Header/Header' import useExploration from 'components/Hooks/useExploration' @@ -20,6 +21,7 @@ import React, { useCallback, useEffect, useMemo, useState } from 'react' import { useParams } from 'react-router-dom' import EcogestureService from 'services/ecogesture.service' import { useAppSelector } from 'store/hooks' +import logApp from 'utils/logger' import { importIconById } from 'utils/utils' import EfficiencyRating from './EfficiencyRating/EfficiencyRating' import './singleEcogestureView.scss' @@ -89,6 +91,9 @@ const SingleEcogestureView = () => { setValidExploration(currentChallenge.exploration.id) } } + } else { + logApp.error(`Could not find ecogesture ${ecogestureID}`) + Sentry.captureException(new Error('Could not find ecogesture')) } setIsLoading(false) }