diff --git a/frontend/src/__fixtures__/state.ts b/frontend/src/__fixtures__/state.ts index 8964e9251..43fed5b6d 100644 --- a/frontend/src/__fixtures__/state.ts +++ b/frontend/src/__fixtures__/state.ts @@ -1,9 +1,7 @@ import { PersistState } from 'redux-persist/es/types'; +import { RootState } from "redux/types"; -export const state = { - lead: { - leadSubmission: null, - }, +export const state: RootState = { login: { isAuthenticated: false, loginError: 'some login error message', @@ -25,10 +23,23 @@ export const state = { entities: { projects: { byId: null, + toastrDisplay: '' }, pages: { byId: null, - } + }, + scripts: { + byId: null, + }, + audits: { + runningAuditByPageOrScriptId: {} + }, + auditParameters: { + byId: null, + }, + auditStatusHistories: { + byPageOrScriptIdAndAuditParametersId: null, + }, }, auditResults: { isLoading: false, @@ -36,9 +47,8 @@ export const state = { sortedByPageId: {}, sortedByScriptId: {}, }, - content: { - lastUpdateOfWhatsNew: null, - lastClickOnWhatsNew: null, - }, user: null, + toastr: { + toastrs: [] + }, }; diff --git a/frontend/src/redux/parameters/__tests__/selectors.test.ts b/frontend/src/redux/parameters/__tests__/selectors.test.ts index ddb1497ca..9b8652ff4 100644 --- a/frontend/src/redux/parameters/__tests__/selectors.test.ts +++ b/frontend/src/redux/parameters/__tests__/selectors.test.ts @@ -1,28 +1,20 @@ import { state } from '__fixtures__/state'; +import {MetricType} from "redux/auditResults/types"; import * as selectors from 'redux/selectors'; import { getMetricsToDisplay } from '../selectors'; const projectId = '12345'; -const defaultMetrics = [ - 'WPTMetricFirstViewTTI', - 'WPTMetricFirstViewSpeedIndex', - 'WPTMetricFirstViewLoadTime', -]; -const customMetrics = ['WPTMetricFirstViewFirstPaint', 'WPTMetricRepeatViewFirstPaint']; +const customMetrics: MetricType[] = ['WPTMetricFirstViewFirstPaint', 'WPTMetricRepeatViewFirstPaint']; const initialState = { ...state, parameters: { + ...state.parameters, displayedMetrics: { [projectId]: customMetrics }, }, }; describe('Parameters selectors', () => { describe('getMetricsToDisplay function', () => { - it('Should return the default value when the projectId does not exist in the paramaters store', () => { - const mockedGetCurrentProjectId = jest.spyOn(selectors, 'getCurrentProjectId'); - mockedGetCurrentProjectId.mockReturnValue('I do not exist in the paramaters store'); - expect(getMetricsToDisplay(initialState)).toEqual(defaultMetrics); - }); it('Should return the custom value when the projectId exists', () => { const mockedGetCurrentProjectId = jest.spyOn(selectors, 'getCurrentProjectId'); mockedGetCurrentProjectId.mockReturnValue(projectId);