Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DATAP-1208 Convert reducers to RTK slices #482

Draft
wants to merge 96 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 91 commits
Commits
Show all changes
96 commits
Select commit Hold shift + click to select a range
99e4fef
Saving work
Oct 19, 2023
7d34f7c
Saving work
Oct 20, 2023
e439c62
Saving work
Oct 23, 2023
4ef727c
Initial conversion complete
Oct 24, 2023
562b4a5
Saving work
Oct 24, 2023
29c4ab1
Fixed silly misnaming error with aggs
Oct 26, 2023
aec3eb9
Saving work
Oct 27, 2023
f9dc97a
DATAP-1208
Nov 9, 2023
aadbd82
Making progress changing tabs, might make another branch and start ov…
Nov 9, 2023
41a327a
Starting to implement fixes from alt branch
Nov 16, 2023
4a1fbf5
View actions mainly renamed, filter working
Nov 16, 2023
59a92af
DATAP-1208 quick commit to see if Jira will pick this up
Nov 16, 2023
a09537c
Merge branch 'WW-DATAP-1208-reducers-use-slices' of https://github.co…
Nov 16, 2023
21584c1
Saving work
Nov 17, 2023
29ce692
All view actions relocated and refactored
Nov 17, 2023
87e5c4f
Working on query reducer actions
Nov 20, 2023
155e6e0
Date change updated
Nov 20, 2023
0f999f0
Change date range working
Nov 20, 2023
ef6b4df
Filter actions all converted to reducers in slices, filter action fil…
Nov 21, 2023
a986766
Map actions converted to reducers in slices and action file deleted
Nov 21, 2023
2a658e7
Paging actions converted, file deleted
Nov 21, 2023
289e71e
Trends actions converted and file deleted
Nov 22, 2023
a8a6d56
Updated ExportConfirmation spec
Nov 24, 2023
9001041
Detail spec (reducer) updated
Nov 24, 2023
5fa14c1
ListPanel spec updated
Nov 24, 2023
e118919
Pagination spec updated
Nov 24, 2023
88eb84a
DataExport spec updated
Nov 24, 2023
49b6eba
ActionBar spec updated
Nov 24, 2023
12367e9
PerCapita spec updated
Nov 24, 2023
4f223b1
ChartToggles, NarrativesButtons specs updated
Nov 24, 2023
a8afbe9
RootModal spec updated
Nov 24, 2023
debc572
Results reducer spec updated
Nov 24, 2023
2ebb191
Map reducer spec updated
Nov 24, 2023
82eaaf3
More work on trends spec, most of view spec
Nov 28, 2023
a3d50ab
FederalState spec fixed
Nov 28, 2023
3e3d79e
Filter component specs updated
Nov 28, 2023
3f49100
Hero and SearchBar specs updated
Nov 28, 2023
32f5760
Agg reducer spec fixed
Nov 28, 2023
eb2beab
View spec fixed
Nov 28, 2023
f269390
Pausing work briefly
Nov 29, 2023
427d60c
Saving work
Nov 30, 2023
60797d9
Trends portion of query tests updated
Dec 1, 2023
6f8acce
Map section of query spec updated
Dec 4, 2023
ac104dd
Saving work
Dec 5, 2023
c287f99
Dates tests fixed in query
Dec 6, 2023
c987192
Remove filters tests in query
Dec 8, 2023
30bda1b
Saving work
Dec 12, 2023
945307b
Saving work
Dec 18, 2023
8258757
Saving work
Dec 18, 2023
62550f1
Saving work
Dec 19, 2023
85b8e23
Saving
Dec 19, 2023
edf17ca
Agg spec fixed, removes 'stack' from error handling as it is non-stan…
Dec 20, 2023
fa97450
Saving work
Dec 20, 2023
09f1294
All tests passing
Dec 21, 2023
ae5cbbf
Fixed payload sections in query slice
Dec 26, 2023
42f498a
Fixed up some prepare functions
Dec 27, 2023
6656564
Saving work fixing tests
Jan 2, 2024
8474059
Saving work
Jan 4, 2024
806acfb
Tests finished, updates made
Jan 9, 2024
a3cdd6a
Built dist
Feb 7, 2024
e7c8a64
Merge fixes
Feb 8, 2024
7e65718
Fixed list
Feb 8, 2024
04d3c01
Saving work
Feb 9, 2024
df5b2cc
Fixed requery meta value for Trends
Feb 13, 2024
abdb447
Fixed error with TileMap
Feb 14, 2024
ec87026
Checks if tooltip value has property before trying to assign a fallba…
Feb 14, 2024
ba1e364
Fix to detail reducer
Feb 14, 2024
7500fed
Merge fix, still needs lint fixes
Mar 1, 2024
ca41450
Lints fixed
Mar 4, 2024
a2e4fb9
Merge branch 'main' into WW-DATAP-1208-reducers-use-slices
Mar 4, 2024
63803af
Merge branch 'main' into WW-DATAP-1208-reducers-use-slices
flacoman91 Mar 5, 2024
c74ea0d
linting fixes,
flacoman91 Mar 8, 2024
17e8f07
fixing row chart on trends page
flacoman91 Mar 8, 2024
93052f2
adding debounce to stacked area and line chart onMove
flacoman91 Mar 11, 2024
922d86d
fixing results tests
flacoman91 Mar 12, 2024
9f64169
painful date manipulation
flacoman91 Mar 12, 2024
2439984
fix map test
flacoman91 Mar 12, 2024
226d490
fixing date converions
flacoman91 Mar 12, 2024
debbfd1
fixing broken test
flacoman91 Mar 12, 2024
ad9938b
restoring some uncommented tests
flacoman91 Mar 12, 2024
74bb136
adding action logger, fixing a test, refactor action calls, rename so…
flacoman91 Mar 12, 2024
46e1cbb
fixing up tests and fix broken references
flacoman91 Mar 12, 2024
df854e4
trends reducer test updates
flacoman91 Mar 12, 2024
44e5f70
query reducer tests
flacoman91 Mar 12, 2024
e4c0507
convert company, filterPanel to functional components, remove snapsho…
flacoman91 Mar 13, 2024
3f9fa61
fixing test references
flacoman91 Mar 13, 2024
b7b429f
fixing problems with reducers
flacoman91 Mar 13, 2024
15a73db
Merge commit '7cadd7339f83218cbbca4b557e61b07961e397c2' into WW-DATAP…
flacoman91 Mar 13, 2024
4429c20
save off filters reducer
flacoman91 Mar 13, 2024
5df9acd
Merge commit '4bd243453c3cfedc5e60c4611d6b706478194924' into WW-DATAP…
flacoman91 Apr 12, 2024
545d9ee
Merge branch 'main' into WW-DATAP-1208-reducers-use-slices
flacoman91 Apr 17, 2024
6c4543e
merged
flacoman91 May 1, 2024
ff4aabf
Merge branch 'main' into WW-DATAP-1208-reducers-use-slices
flacoman91 May 1, 2024
187b51b
Merge branch 'main' into WW-DATAP-1208-reducers-use-slices
flacoman91 May 3, 2024
7b48940
Merge branch 'main' into WW-DATAP-1208-reducers-use-slices
flacoman91 May 3, 2024
12b992d
Merge commit 'fddf2b6b16aa110a8da19cbc1243721f7138f438' into WW-DATAP…
flacoman91 May 20, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 6 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
"@cfpb/cfpb-tables": "0.43.1",
"@cfpb/cfpb-typography": "0.43.0",
"@craco/craco": "^7.1.0",
"@reduxjs/toolkit": "^2.1.0",
"@reduxjs/toolkit": "^2.2.1",
"@testing-library/cypress": "^10.0.1",
"@testing-library/jest-dom": "^6.4.2",
"@testing-library/react": "15.0.2",
Expand All @@ -69,8 +69,6 @@
"d3": "^7.9.0",
"d3-selection": "^3.0.0",
"dayjs": "^1.11.10",
"enzyme": "^3.11.0",
"enzyme-adapter-react-16": "^1.15.7",
"eslint": "^8.57.0",
"eslint-config-prettier": "^9.1.0",
"eslint-config-react-app": "^7.0.1",
Expand All @@ -79,6 +77,7 @@
"eslint-plugin-react-redux": "^4.1.0",
"highcharts": "9.2.2",
"history": "^5.3.0",
"http-proxy-middleware": "^2.0.6",
"husky": "^9.0.11",
"identity-obj-proxy": "3.0.0",
"intro.js": "^7.2.0",
Expand All @@ -102,17 +101,12 @@
"react-bootstrap": "^2.6.0",
"react-bootstrap-typeahead": "^6.3.2",
"react-dom": "^18.2.0",
"react-intl": "^6.6.2",
"react-fast-compare": "^3.2.2",
"react-modal": "^3.16.1",
"react-redux": "^7.2.0",
"react-redux": "^9.1.0",
"react-router-dom": "^6.22.0",
"react-scripts": "^5.0.1",
"react-test-renderer": "^18.2.0",
"redux": "^4.0.5",
"redux-devtools-extension": "^2.13.2",
"redux-mock-store": "^1.5.4",
"redux-thunk": "^2.2.0",
"release-it": "^17.2.0",
"release-it": "^17.0.3",
"string-replace-loader": "^3.1.0",
"stylelint": "^16.3.1",
"stylelint-config-standard": "^36.0.0",
Expand Down Expand Up @@ -164,6 +158,5 @@
"access": "public",
"registry": "https://registry.npmjs.org/"
},
"proxy": "https://www.consumerfinance.gov",
"dependencies": {}
"proxy": "https://www.consumerfinance.gov"
}
75 changes: 18 additions & 57 deletions src/App.js
Original file line number Diff line number Diff line change
@@ -1,76 +1,37 @@
import './css/App.less';
import { applyMiddleware, createStore } from 'redux';
import { Route, BrowserRouter as Router, Routes } from 'react-router-dom';
import { composeWithDevTools } from 'redux-devtools-extension';
import { IntlProvider } from 'react-intl';
import { Provider } from 'react-redux';
import queryManager from './middleware/queryManager';
import { ComplaintDetail } from './components/ComplaintDetail/ComplaintDetail';
import React from 'react';
import reducers from './reducers';
import { SearchComponents } from './components/Search/SearchComponents';
import thunkMiddleware from 'redux-thunk';
import synchUrl from './middleware/synchUrl/synchUrl';

const middleware = [thunkMiddleware, queryManager, synchUrl];

const composeEnhancers = composeWithDevTools({
// required for redux-devtools-extension
// Specify name here, actionsBlacklist, actionsCreators and other options
// if needed
});

// required format for redux-devtools-extension
const store = createStore(
reducers,
composeEnhancers(
applyMiddleware(...middleware),
// other store enhancers if any
),
);

/* eslint-disable camelcase */
export const DetailComponents = () => {
return (
<IntlProvider locale="en">
<main role="main">
<ComplaintDetail />
</main>
</IntlProvider>
);
};
/* eslint-enable camelcase */

// eslint-disable-next-line react/no-multi-comp
/**
* Main App Component
*
* @returns {JSX.Element} Main app
*/
export const App = () => {
const App = () => {
return (
<Provider store={store}>
<Router>
<Routes>
{/*
<Router>
<Routes>
{/*
we need these duplicate routes to match relative path
/data-research/consumer-complaints/search
from CF.gov
local
which is just the root at localhost:3000/
*/}
<Route index element={<SearchComponents />} />
<Route
path="/data-research/consumer-complaints/search"
element={<SearchComponents />}
/>
<Route
path="/data-research/consumer-complaints/search/detail/:id"
element={<DetailComponents />}
/>
<Route path="/detail/:id" element={<DetailComponents />} />
</Routes>
</Router>
</Provider>
<Route index element={<SearchComponents />} />
<Route
path="/data-research/consumer-complaints/search"
element={<SearchComponents />}
/>
<Route
path="/data-research/consumer-complaints/search/detail/:id"
element={<ComplaintDetail />}
/>
<Route path="/detail/:id" element={<ComplaintDetail />} />
</Routes>
</Router>
);
};

export default App;
32 changes: 7 additions & 25 deletions src/__tests__/App.spec.js → src/App.spec.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
import { App, DetailComponents } from '../App';
import configureMockStore from 'redux-mock-store';
import App from './App';
import { Provider } from 'react-redux';
import React from 'react';
import thunk from 'redux-thunk';
import 'regenerator-runtime/runtime';
import { MemoryRouter, Route, Routes } from 'react-router-dom';
import { render, screen } from '@testing-library/react';
import * as useUpdateLocationHook from '../hooks/useUpdateLocation';
import { defaultQuery } from '../reducers/query/query';

import * as useUpdateLocationHook from './hooks/useUpdateLocation';
import store from './app/store';
import { ComplaintDetail } from './components/ComplaintDetail/ComplaintDetail';
jest.mock('highcharts/modules/accessibility');
jest.mock('highcharts/highmaps');

Expand All @@ -17,11 +14,6 @@ describe('initial state', () => {
const updateLocationHookSpy = jest
.spyOn(useUpdateLocationHook, 'useUpdateLocation')
.mockImplementation(() => jest.fn());
const middlewares = [thunk];
const mockStore = configureMockStore(middlewares);
const store = mockStore({
query: defaultQuery,
});

render(
<Provider store={store}>
Expand All @@ -30,7 +22,6 @@ describe('initial state', () => {
);

expect(updateLocationHookSpy).toBeCalledTimes(1);

expect(screen.getByText(/Consumer Complaint Database/)).toBeDefined();
expect(screen.getByText(/Search within/)).toBeDefined();
expect(
Expand All @@ -41,21 +32,12 @@ describe('initial state', () => {
).toBeInTheDocument();
});

it('renders the detail route', () => {
const middlewares = [thunk];
const mockStore = configureMockStore(middlewares);
const store = mockStore({
detail: { data: {}, error: '' },
query: {
search: '?something',
},
});

test('renders the detail route', () => {
render(
<MemoryRouter initialEntries={['/detail/6026335']}>
<Provider store={store}>
<Routes>
<Route path="/detail/:id" element={<DetailComponents />} />
<Route path="/detail/:id" element={<ComplaintDetail />} />
</Routes>
</Provider>
</MemoryRouter>,
Expand All @@ -66,7 +48,7 @@ describe('initial state', () => {
).toBeInTheDocument();
expect(
screen.getByRole('link', { name: /Back to search results/ }),
).toHaveAttribute('href', '/?something');
).toHaveAttribute('href', '/');

expect(screen.getByText('This page is loading')).toBeInTheDocument();
});
Expand Down
38 changes: 14 additions & 24 deletions src/__tests__/utils.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,66 +181,66 @@ describe('module::utils', () => {

describe('enablePer1000', () => {
it('handles no filters', () => {
const query = {
const filters = {
date: {},
bogus: {},
product: [],
};

expect(enablePer1000(query)).toBeTruthy();
expect(enablePer1000(filters)).toBeTruthy();
});

it('handles some filters', () => {
const query = {
const filters = {
date: {},
bogus: {},
product: [{ name: 'foo', value: 123 }],
};

expect(enablePer1000(query)).toBeFalsy();
expect(enablePer1000(filters)).toBeFalsy();
});

it('handles flag filters', () => {
const query = {
const filters = {
date: {},
bogus: {},
has_narrative: true,
};

expect(enablePer1000(query)).toBeFalsy();
expect(enablePer1000(filters)).toBeFalsy();
});

it('handles company_received filters', () => {
const query = {
const filters = {
date: {},
bogus: {},
product: [],
company_received_max: 'foo',
};

expect(enablePer1000(query)).toBeFalsy();
expect(enablePer1000(filters)).toBeFalsy();
});

it('allows state filter', () => {
const query = {
const filters = {
date: {},
bogus: {},
product: [],
state: ['FL', 'OR'],
};

expect(enablePer1000(query)).toBeTruthy();
expect(enablePer1000(filters)).toBeTruthy();
});

it('disallows state filter when others valid', () => {
const query = {
const filters = {
date: {},
bogus: {},
product: ['BA'],
state: ['FL', 'OR'],
};

expect(enablePer1000(query)).toBeFalsy();
expect(enablePer1000(filters)).toBeFalsy();
});
});

Expand Down Expand Up @@ -274,22 +274,14 @@ describe('module::utils', () => {
};

const actual = startOfToday();
expect(actual.getFullYear()).toEqual(2020);
expect(actual.getMonth()).toEqual(4);
expect(actual.getDate()).toEqual(9);
expect(actual.getHours()).toEqual(0);
expect(actual.getMinutes()).toEqual(0);
expect(dayjs(actual).toISOString()).toEqual('2020-05-09T04:00:00.000Z');
});

it('defaults MAX_DATE if the metadata is missing', () => {
MockDate.set(dayjs('5/1/2020').utc());

const actual = startOfToday();
expect(actual.getFullYear()).toEqual(2020);
expect(actual.getMonth()).toEqual(4);
expect(actual.getDate()).toEqual(1);
expect(actual.getHours()).toEqual(0);
expect(actual.getMinutes()).toEqual(0);
expect(dayjs(actual).toISOString()).toEqual('2020-05-01T04:00:00.000Z');
});
});

Expand All @@ -298,12 +290,10 @@ describe('module::utils', () => {
const actual = processErrorMessage({
name: 'foo',
message: 'bar',
stack: 'some stack trace thing',
});
expect(actual).toEqual({
name: 'foo',
message: 'bar',
stack: 'some stack trace thing',
});
});
});
Expand Down