Skip to content
Snippets Groups Projects
Commit 77caaf74 authored by Bastien DUMONT's avatar Bastien DUMONT :angel:
Browse files

move error to ecogesture not found

parent 39f2a03b
No related branches found
No related tags found
1 merge request!999chore(logs): improve logs
......@@ -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')
})
......
......@@ -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
// 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>
`;
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)
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment