Skip to content

Commit

Permalink
save off filters reducer
Browse files Browse the repository at this point in the history
fix bug, shoudl be actions

refactoring a lot of stuff

adding new dependencies updates, and breaking a lot of tests

save off some work

save some work

fixed routes.js logic so it fires correctly on page load

renaming files to correct slice convention

renaming lintin broken references

make dates strings, fixing data lens action

rename query action

save off some more work

update tests

updating more unit tests, fixing missing logic

save off more work

fixing broken map trends chart, updating references, fixing modal

hide button in print mode

save work

fixing references

fixing more unit tests

filterSlice tests

cleanup fix zip typeahead querystring

save off work, fixing queryslice tests

fixing data export unit tests, adding filters to query string export

fixing trendsslicetest

format date fix, update configurestore

adding proxy middleware

make app.js like complaint explorer, migrating over to new react18 strict mode, fixing bug with tour asking to exit onExit handler

update app spec with realstore

clean up tests, fixing percapita

trends work

action bar test update

convert has narrative to s functional

Save work

trend depth toggle to functional

save work

update trend depth toggle

update tests for company receivd filter

save off product / agg branch work
  • Loading branch information
flacoman91 committed Apr 10, 2024
1 parent 15a73db commit 4429c20
Show file tree
Hide file tree
Showing 155 changed files with 4,962 additions and 5,977 deletions.
15 changes: 3 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
"@cfpb/cfpb-tables": "0.37.0",
"@cfpb/cfpb-typography": "0.37.2",
"@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": "14.2.1",
Expand All @@ -69,8 +69,6 @@
"d3": "^5.12.0",
"d3-selection": "^1.4.0",
"dayjs": "^1.11.10",
"enzyme": "^3.11.0",
"enzyme-adapter-react-16": "^1.15.7",
"eslint": "^8.56.0",
"eslint-config-prettier": "^9.1.0",
"eslint-config-react-app": "^7.0.1",
Expand All @@ -79,12 +77,11 @@
"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",
"intro.js-react": "1.0.0",
"jest": "29.7.0",
"jest-environment-jsdom": "29.7.0",
"jest-fetch-mock": "^3.0.3",
"less": "^4.2.0",
"less-loader": "^12.2.0",
Expand All @@ -105,16 +102,10 @@
"react-bootstrap-typeahead": "^6.3.2",
"react-dom": "^18.2.0",
"react-fast-compare": "^3.2.2",
"react-intl": "^6.6.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.0.3",
"string-replace-loader": "^3.1.0",
"stylelint": "^16.2.1",
Expand Down
80 changes: 18 additions & 62 deletions src/App.js
Original file line number Diff line number Diff line change
@@ -1,81 +1,37 @@
import './css/App.less';
import { Route, BrowserRouter as Router, Routes } from 'react-router-dom';
import { IntlProvider } from 'react-intl';
import { Provider } from 'react-redux';
import queryManager from './middleware/queryManager/queryManager';
import { ComplaintDetail } from './components/ComplaintDetail/ComplaintDetail';
import React from 'react';
import { SearchComponents } from './components/Search/SearchComponents';
import synchUrl from './middleware/synchUrl/synchUrl';
import { configureStore } from '@reduxjs/toolkit';
import aggReducer from './reducers/aggs/aggs';
import detailReducer from './reducers/detail/detail';
import mapReducer from './reducers/map/map';
import queryReducer from './reducers/query/query';
import resultsReducer from './reducers/results/results';
import routesReducer from './reducers/routes/routesSlice';
import trendsReducer from './reducers/trends/trends';
import viewReducer from './reducers/view/view';

// required format for redux-devtools-extension
const store = configureStore({
devTools: true,
reducer: {
aggs: aggReducer,
detail: detailReducer,
map: mapReducer,
query: queryReducer,
results: resultsReducer,
routes: routesReducer,
trends: trendsReducer,
view: viewReducer,
},
middleware: (getDefaultMiddleware) =>
getDefaultMiddleware().concat([queryManager, synchUrl]),
});

/* 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 { queryState } 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: queryState,
});

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
24 changes: 12 additions & 12 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
13 changes: 5 additions & 8 deletions src/actions/__tests__/complaints.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,27 @@ import {
complaintsApiCalled,
complaintsApiFailed,
complaintsReceived,
} from '../../reducers/results/results';
} from '../../reducers/results/resultsSlice';
import {
statesApiCalled,
statesApiFailed,
statesReceived,
} from '../../reducers/map/map';
} from '../../reducers/map/mapSlice';
import {
trendsApiCalled,
trendsApiFailed,
trendsReceived,
} from '../../reducers/trends/trends';
} from '../../reducers/trends/trendsSlice';
import {
aggregationsApiCalled,
aggregationsApiFailed,
aggregationsReceived,
} from '../../reducers/aggs/aggs';
} from '../../reducers/aggs/aggsSlice';
import {
complaintDetailCalled,
complaintDetailFailed,
complaintDetailReceived,
} from '../../reducers/detail/detail';
} from '../../reducers/detail/detailSlice';

const middlewares = [thunk];
const mockStore = configureMockStore(middlewares);
Expand All @@ -40,7 +40,6 @@ function setupStore(tab) {
aggs: { activeCall: '' },
map: { activeCall: '' },
query: {
queryString: '?foobar',
tab,
},
trends: {
Expand Down Expand Up @@ -115,7 +114,6 @@ describe('action::complaints', () => {
date_received_min: new Date(2013, 1, 3),
from: 0,
has_narrative: true,
queryString: '?foo',
searchText: '',
size: 10,
},
Expand Down Expand Up @@ -191,7 +189,6 @@ describe('action::complaints', () => {
date_received_min: new Date(2013, 1, 3),
from: 0,
has_narrative: true,
queryString: '?foo',
searchText: '',
size: 10,
},
Expand Down

0 comments on commit 4429c20

Please sign in to comment.