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

Merge branch 'deps/redux-2.0' into 'dev'

chore(deps): bump redux to 2.0

See merge request !1201
parents fa9e8f33 72ba1b03
No related branches found
No related tags found
2 merge requests!12413.1 Release,!1201chore(deps): bump redux to 2.0
Showing
with 84 additions and 29 deletions
......@@ -3,13 +3,17 @@ import { userEvent } from '@testing-library/user-event'
import React from 'react'
import { Provider } from 'react-redux'
import { defaultEcogestureData } from 'tests/__mocks__/actionData.mock'
import { createMockEcolyoStore } from 'tests/__mocks__/store'
import {
createMockEcolyoStore,
mockChallengeState,
} from 'tests/__mocks__/store'
import { userChallengeData } from 'tests/__mocks__/userChallengeData.mock'
import ActionCard from './ActionCard'
describe('ActionCard component', () => {
const store = createMockEcolyoStore({
challenge: {
...mockChallengeState,
currentChallenge: userChallengeData[1],
},
})
......
......@@ -5,6 +5,7 @@ import { defaultEcogestureData } from 'tests/__mocks__/actionData.mock'
import {
createMockEcolyoStore,
mockChallengeState,
mockGlobalState,
mockProfileState,
} from 'tests/__mocks__/store'
import ActionList from './ActionList'
......@@ -22,7 +23,7 @@ describe('ActionList component', () => {
mockGetDefaultActions.mockResolvedValueOnce(defaultEcogestureData)
const store = createMockEcolyoStore({
challenge: { ...mockChallengeState },
global: { fluidTypes: [0, 1, 2] },
global: { ...mockGlobalState, fluidTypes: [0, 1, 2] },
profile: mockProfileState,
})
const { container } = render(
......
......@@ -3,7 +3,10 @@ import ActionView from 'components/Action/ActionView'
import { UserActionState } from 'enums'
import React from 'react'
import { Provider } from 'react-redux'
import { createMockEcolyoStore } from 'tests/__mocks__/store'
import {
createMockEcolyoStore,
mockChallengeState,
} from 'tests/__mocks__/store'
import { userChallengeData } from 'tests/__mocks__/userChallengeData.mock'
jest.mock('components/Header/CozyBar', () => 'mock-cozybar')
......@@ -26,6 +29,7 @@ describe('ActionView component', () => {
it('should render match snapshot with "Unstarted" state', async () => {
const store = createMockEcolyoStore({
challenge: {
...mockChallengeState,
currentChallenge: {
...userChallengeData[1],
action: {
......@@ -45,6 +49,7 @@ describe('ActionView component', () => {
it('should render match snapshot with "onGoing" state', async () => {
const store = createMockEcolyoStore({
challenge: {
...mockChallengeState,
currentChallenge: {
...userChallengeData[1],
action: {
......@@ -64,6 +69,7 @@ describe('ActionView component', () => {
it('should render match snapshot with "Notification" state', async () => {
const store = createMockEcolyoStore({
challenge: {
...mockChallengeState,
currentChallenge: {
...userChallengeData[1],
action: {
......@@ -83,6 +89,7 @@ describe('ActionView component', () => {
it('should render match snapshot with default case', async () => {
const store = createMockEcolyoStore({
challenge: {
...mockChallengeState,
currentChallenge: {
...userChallengeData[1],
action: {
......
......@@ -9,6 +9,7 @@ import {
createMockEcolyoStore,
mockAnalysisState,
mockChartState,
mockGlobalState,
mockProfileState,
} from 'tests/__mocks__/store'
......@@ -52,7 +53,7 @@ describe('AnalysisView component', () => {
const store = createMockEcolyoStore({
analysis: mockAnalysisState,
chart: mockChartState,
global: { analysisNotification: true },
global: { ...mockGlobalState, analysisNotification: true },
profile: { ...mockProfileState, haveSeenLastAnalysis: true },
})
mockAppDispatch.mockReturnValue(jest.fn())
......
......@@ -5,7 +5,11 @@ import { PerformanceIndicator } from 'models'
import React from 'react'
import { Provider } from 'react-redux'
import { setPeriod } from 'store/analysis/analysis.slice'
import { createMockEcolyoStore, mockAnalysisState } from 'tests/__mocks__/store'
import {
createMockEcolyoStore,
mockAnalysisState,
mockGlobalState,
} from 'tests/__mocks__/store'
import Comparison from './Comparison'
jest.mock(
......@@ -61,6 +65,7 @@ describe('Comparison component', () => {
const store = createMockEcolyoStore({
analysis: { ...mockAnalysisState, period: 'month' },
global: {
...mockGlobalState,
fluidTypes: mockFluidsWithData,
},
})
......@@ -99,6 +104,7 @@ describe('Comparison component', () => {
const store = createMockEcolyoStore({
analysis: { ...mockAnalysisState },
global: {
...mockGlobalState,
fluidTypes: mockFluidsWithData,
},
})
......
......@@ -6,11 +6,13 @@ import { DateTime } from 'luxon'
import { PerformanceIndicator } from 'models'
import React from 'react'
import { Provider } from 'react-redux'
import { createMockEcolyoStore } from 'tests/__mocks__/store'
import { createMockEcolyoStore, mockAnalysisState } from 'tests/__mocks__/store'
import FluidPerformanceIndicator from './FluidPerformanceIndicator'
const monthlyStore = createMockEcolyoStore()
const yearlyStore = createMockEcolyoStore({ analysis: { period: 'year' } })
const yearlyStore = createMockEcolyoStore({
analysis: { ...mockAnalysisState, period: 'year' },
})
const mockedNavigate = jest.fn()
jest.mock('react-router-dom', () => ({
...jest.requireActual('react-router-dom'),
......
......@@ -3,7 +3,11 @@ import { DateTime } from 'luxon'
import React from 'react'
import { Provider } from 'react-redux'
import { dataLoadArray } from 'tests/__mocks__/chartData.mock'
import { createMockEcolyoStore, mockGlobalState } from 'tests/__mocks__/store'
import {
createMockEcolyoStore,
mockChartState,
mockGlobalState,
} from 'tests/__mocks__/store'
import ElecHalfHourChart from './ElecHalfHourChart'
jest.mock('services/dateChart.service', () => {
......@@ -15,6 +19,7 @@ jest.mock('services/dateChart.service', () => {
describe('ElecHalfHourChart component', () => {
const store = createMockEcolyoStore({
chart: {
...mockChartState,
selectedDate: DateTime.fromISO('2021-07-01T00:00:00.000Z', {
zone: 'utc',
}),
......
......@@ -123,7 +123,7 @@ exports[`MaxConsumptionCard component should be rendered correctly 1`] = `
transform="translate(54.6875, -40)"
>
<rect
class="background-false"
class="background-true"
fill="#E0E0E0"
height="220"
width="218.75"
......@@ -154,7 +154,7 @@ exports[`MaxConsumptionCard component should be rendered correctly 1`] = `
</lineargradient>
</defs>
<path
class="bar-ELECTRICITY disabled bounce-1 delay--0"
class="bar-ELECTRICITY selected disabled bounce-1 delay--0"
d="
M0,4
a4,4 0 0 1 4,-4
......@@ -175,7 +175,7 @@ exports[`MaxConsumptionCard component should be rendered correctly 1`] = `
</title>
<defs>
<lineargradient
class="bar-ELECTRICITY disabled bounce-1 delay--0"
class="bar-ELECTRICITY selected disabled bounce-1 delay--0"
id="gradient"
x1="0"
x2="0"
......@@ -193,7 +193,7 @@ exports[`MaxConsumptionCard component should be rendered correctly 1`] = `
</lineargradient>
</defs>
<path
class="bar-ELECTRICITY disabled bounce-1 delay--0"
class="bar-ELECTRICITY selected disabled bounce-1 delay--0"
d="
M0,4
a4,4 0 0 1 4,-4
......
......@@ -48,8 +48,10 @@ describe('ChallengeCardUnlocked component', () => {
})
it('should not display ChallengeNoFluidModal and update userChallenge when launching challenge with configured fluid', async () => {
mockStartUserChallenge.mockResolvedValue(userChallengeData[0])
const store = createMockEcolyoStore({
global: {
...mockGlobalState,
fluidTypes: [FluidType.ELECTRICITY],
fluidStatus: [
{ ...mockGlobalState.fluidStatus[0], status: FluidState.DONE },
......@@ -72,6 +74,7 @@ describe('ChallengeCardUnlocked component', () => {
})
it('should not be able to launch challenge if another one is active', async () => {
mockStartUserChallenge.mockResolvedValue(userChallengeData[0])
const store = createMockEcolyoStore({
global: mockGlobalState,
challenge: {
......
......@@ -5,7 +5,7 @@ import { DateTime } from 'luxon'
import React from 'react'
import { Provider } from 'react-redux'
import { graphData } from 'tests/__mocks__/chartData.mock'
import { createMockEcolyoStore } from 'tests/__mocks__/store'
import { createMockEcolyoStore, mockChartState } from 'tests/__mocks__/store'
import AxisBottom from './AxisBottom'
const mockXScale: ScaleBand<string> = scaleBand()
......@@ -24,6 +24,7 @@ const mockProps = {
describe('AxisBottom component test', () => {
const store = createMockEcolyoStore({
chart: {
...mockChartState,
selectedDate: DateTime.fromISO('2020-10-01T00:00:00.000Z', {
zone: 'utc',
}),
......
......@@ -7,7 +7,11 @@ import React from 'react'
import { Provider } from 'react-redux'
import * as chartActions from 'store/chart/chart.slice'
import { graphData } from 'tests/__mocks__/chartData.mock'
import { createMockEcolyoStore, mockGlobalState } from 'tests/__mocks__/store'
import {
createMockEcolyoStore,
mockChartState,
mockGlobalState,
} from 'tests/__mocks__/store'
import { mockXScale } from 'tests/__mocks__/xScale.mock'
import Bar from './Bar'
......@@ -30,6 +34,7 @@ const setSelectedDateSpy = jest.spyOn(chartActions, 'setSelectedDate')
describe('Bar component test', () => {
const store = createMockEcolyoStore({
chart: {
...mockChartState,
selectedDate: DateTime.fromISO('2020-10-01T00:00:00.000Z', {
zone: 'utc',
}),
......
......@@ -4,12 +4,17 @@ import { DateTime } from 'luxon'
import React from 'react'
import { Provider } from 'react-redux'
import { graphData } from 'tests/__mocks__/chartData.mock'
import { createMockEcolyoStore, mockGlobalState } from 'tests/__mocks__/store'
import {
createMockEcolyoStore,
mockChartState,
mockGlobalState,
} from 'tests/__mocks__/store'
import BarChart from './BarChart'
describe('BarChart component', () => {
const store = createMockEcolyoStore({
chart: {
...mockChartState,
selectedDate: DateTime.fromISO('2020-10-01T00:00:00.000Z', {
zone: 'utc',
}),
......
......@@ -5,7 +5,7 @@ import React from 'react'
import { Provider } from 'react-redux'
import * as storeHooks from 'store/hooks'
import { fluidStatusConnectedData } from 'tests/__mocks__/fluidStatusData.mock'
import { createMockEcolyoStore } from 'tests/__mocks__/store'
import { createMockEcolyoStore, mockGlobalState } from 'tests/__mocks__/store'
import ExpiredConsentModal from './ExpiredConsentModal'
const mockedNavigate = jest.fn()
......@@ -53,7 +53,7 @@ describe('ExpiredConsentModal component', () => {
})
it('should launch the update consent process for Enedis', async () => {
const store = createMockEcolyoStore({
global: { fluidStatus: fluidStatusConnectedData },
global: { ...mockGlobalState, fluidStatus: fluidStatusConnectedData },
})
render(
<Provider store={store}>
......@@ -68,7 +68,7 @@ describe('ExpiredConsentModal component', () => {
await act(async () => {
await userEvent.click(screen.getByText('consent_outdated.yes'))
})
expect(mockAppDispatch).toHaveBeenCalledTimes(1)
expect(mockAppDispatch).toHaveBeenCalledTimes(2)
expect(mockedNavigate).toHaveBeenCalledTimes(1)
})
it('should click on close modal', async () => {
......
......@@ -12,6 +12,7 @@ import { mockTestProfile1 } from 'tests/__mocks__/profileType.mock'
import {
createMockEcolyoStore,
mockChartState,
mockGlobalState,
mockInitialEcolyoState,
mockModalState,
} from 'tests/__mocks__/store'
......@@ -62,6 +63,7 @@ describe('ConsumptionView component', () => {
showOfflineData: true,
},
global: {
...mockGlobalState,
fluidStatus: mockFluidStatus,
releaseNotes: mockInitialEcolyoState.global.releaseNotes,
},
......@@ -89,6 +91,7 @@ describe('ConsumptionView component', () => {
currentTimeStep: TimeStep.HALF_AN_HOUR,
},
global: {
...mockGlobalState,
fluidStatus: mockInitialEcolyoState.global.fluidStatus,
releaseNotes: mockInitialEcolyoState.global.releaseNotes,
},
......@@ -107,6 +110,7 @@ describe('ConsumptionView component', () => {
const store = createMockEcolyoStore({
chart: mockChartStateShowOffline,
global: {
...mockGlobalState,
fluidStatus: [],
releaseNotes: mockInitialEcolyoState.global.releaseNotes,
},
......@@ -126,6 +130,7 @@ describe('ConsumptionView component', () => {
const store = createMockEcolyoStore({
chart: mockChartStateShowOffline,
global: {
...mockGlobalState,
fluidStatus: mockFluidStatus,
releaseNotes: mockInitialEcolyoState.global.releaseNotes,
},
......@@ -149,6 +154,7 @@ describe('ConsumptionView component', () => {
const store = createMockEcolyoStore({
chart: mockChartStateShowOffline,
global: {
...mockGlobalState,
fluidStatus: mockFluidStatus,
releaseNotes: mockInitialEcolyoState.global.releaseNotes,
},
......@@ -175,6 +181,7 @@ describe('ConsumptionView component', () => {
const store = createMockEcolyoStore({
chart: mockChartStateShowOffline,
global: {
...mockGlobalState,
fluidStatus: updatedStatus,
releaseNotes: mockInitialEcolyoState.global.releaseNotes,
},
......@@ -203,6 +210,7 @@ describe('ConsumptionView component', () => {
const store = createMockEcolyoStore({
chart: mockChartStateShowOffline,
global: {
...mockGlobalState,
fluidStatus: updatedStatus,
releaseNotes: mockInitialEcolyoState.global.releaseNotes,
},
......@@ -231,6 +239,7 @@ describe('ConsumptionView component', () => {
const store = createMockEcolyoStore({
chart: mockChartStateShowOffline,
global: {
...mockGlobalState,
fluidStatus: updatedStatus,
releaseNotes: mockInitialEcolyoState.global.releaseNotes,
},
......@@ -249,6 +258,7 @@ describe('ConsumptionView component', () => {
const store = createMockEcolyoStore({
chart: mockChartStateShowOffline,
global: {
...mockGlobalState,
fluidStatus: updatedStatus,
releaseNotes: mockInitialEcolyoState.global.releaseNotes,
},
......@@ -265,6 +275,7 @@ describe('ConsumptionView component', () => {
const store = createMockEcolyoStore({
chart: mockChartStateShowOffline,
global: {
...mockGlobalState,
fluidStatus: mockFluidStatus,
releaseNotes: mockInitialEcolyoState.global.releaseNotes,
},
......@@ -285,6 +296,7 @@ describe('ConsumptionView component', () => {
const store = createMockEcolyoStore({
chart: mockChartStateShowOffline,
global: {
...mockGlobalState,
fluidStatus: mockFluidStatus,
releaseNotes: {
show: true,
......
......@@ -5,6 +5,7 @@ import {
createMockEcolyoStore,
mockChallengeState,
mockGlobalState,
mockModalState,
} from 'tests/__mocks__/store'
import Content from './Content'
......@@ -26,7 +27,7 @@ describe('Content component', () => {
const store = createMockEcolyoStore({
global: mockGlobalState,
challenge: mockChallengeState,
modal: { isFeedbacksOpen: true },
modal: { ...mockModalState, isFeedbacksOpen: true },
})
const { container } = render(
<Provider store={store}>
......
......@@ -9,11 +9,10 @@ import { formatNumberValues } from 'utils/utils'
import DuelUnlocked from './DuelUnlocked'
const mockUserChallengeUpdateFlag = jest.fn()
const mockGetUserChallengeDataload = jest.fn()
jest.mock('services/challenge.service', () => {
return jest.fn(() => ({
updateUserChallenge: mockUserChallengeUpdateFlag,
getUserChallengeDataload: mockGetUserChallengeDataload,
getUserChallengeDataload: jest.fn(),
}))
})
......@@ -42,6 +41,7 @@ describe('DuelUnlocked component', () => {
})
it('should update userChallenge when launching duel with configured fluid', async () => {
mockUserChallengeUpdateFlag.mockResolvedValueOnce(userChallengeData[0])
const store = createMockEcolyoStore({
global: {
...mockGlobalState,
......
......@@ -31,6 +31,7 @@ const DuelUnlocked = ({ userChallenge }: { userChallenge: UserChallenge }) => {
userChallenge,
UserChallengeUpdateFlag.DUEL_START
)
const dataloads =
await challengeService.getUserChallengeDataload(updatedChallenge)
dispatch(
......
......@@ -4,7 +4,7 @@ import React from 'react'
import { Provider } from 'react-redux'
import * as storeHooks from 'store/hooks'
import { mockProfileEcogesture } from 'tests/__mocks__/profileEcogesture.mock'
import { createMockEcolyoStore } from 'tests/__mocks__/store'
import { createMockEcolyoStore, mockProfileState } from 'tests/__mocks__/store'
import EcogestureFormView from './EcogestureFormView'
jest.mock('components/Header/CozyBar', () => 'mock-cozybar')
......@@ -51,7 +51,7 @@ describe('EcogestureFormView component', () => {
})
it('should render profiletype form step because profiletype is completed', async () => {
const store = createMockEcolyoStore({
profile: { isProfileTypeCompleted: true },
profile: { ...mockProfileState, isProfileTypeCompleted: true },
profileEcogesture: mockProfileEcogesture,
})
const { container } = render(
......
......@@ -3,7 +3,7 @@ import userEvent from '@testing-library/user-event'
import FeedbackModal from 'components/Feedback/FeedbackModal'
import React from 'react'
import { Provider } from 'react-redux'
import { createMockEcolyoStore } from 'tests/__mocks__/store'
import { createMockEcolyoStore, mockModalState } from 'tests/__mocks__/store'
// Value coming from jest.config
declare let __SAU_LINK__: string
......@@ -17,7 +17,9 @@ jest.mock('services/environment.service', () => {
jest.mock('components/Hooks/useExploration', () => () => ['', jest.fn()])
describe('FeedbackModal component', () => {
const store = createMockEcolyoStore({ modal: { isFeedbacksOpen: true } })
const store = createMockEcolyoStore({
modal: { ...mockModalState, isFeedbacksOpen: true },
})
beforeEach(() => {
jest.clearAllMocks()
})
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment