-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DATAP-1335 deprecate redux mock store (#545)
* save refactor adding better middleware code, fixing references adding tests for queryManager middleware, handle date objects, fixing bugs from fromIsoString save work save work, updates update test adding tests for complaints compound actions remove deprecated dependencies * remove unnecessary refactor update stuff move queryManager to another dir, update store test util, removed unused selector file update test coverage * fix CI/headless test * undo relabel * test * fixin tests
- Loading branch information
1 parent
7cd827a
commit 17edcdd
Showing
41 changed files
with
835 additions
and
910 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,72 +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 { Provider } from 'react-redux'; | ||
import queryManager from './middleware/queryManager'; | ||
import { ComplaintDetail } from './components/ComplaintDetail/ComplaintDetail'; | ||
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 ( | ||
<main role="main"> | ||
<ComplaintDetail /> | ||
</main> | ||
); | ||
}; | ||
/* 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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
import App from './App'; | ||
import { Provider } from 'react-redux'; | ||
import 'regenerator-runtime/runtime'; | ||
import { render, screen, waitFor } from '@testing-library/react'; | ||
import * as useUpdateLocationHook from './hooks/useUpdateLocation'; | ||
import store from './app/store'; | ||
import { MemoryRouter, Route, Routes } from 'react-router-dom'; | ||
import { ComplaintDetail } from './components/ComplaintDetail/ComplaintDetail'; | ||
|
||
jest.mock('highcharts/modules/accessibility'); | ||
jest.mock('highcharts/highmaps'); | ||
|
||
describe('initial state', () => { | ||
it('renders search page', () => { | ||
const updateLocationHookSpy = jest.spyOn( | ||
useUpdateLocationHook, | ||
'useUpdateLocation', | ||
); | ||
|
||
render( | ||
<Provider store={store}> | ||
<App /> | ||
</Provider>, | ||
); | ||
|
||
expect(updateLocationHookSpy).toBeCalled(); | ||
|
||
expect(screen.getByText(/Consumer Complaint Database/)).toBeInTheDocument(); | ||
expect(screen.getByText(/Search within/)).toBeInTheDocument(); | ||
expect( | ||
screen.getByRole('button', { name: /Show advanced search tips/ }), | ||
).toBeInTheDocument(); | ||
}); | ||
|
||
it('renders tour button', async () => { | ||
const updateLocationHookSpy = jest | ||
.spyOn(useUpdateLocationHook, 'useUpdateLocation') | ||
.mockImplementation(() => jest.fn()); | ||
|
||
render( | ||
<Provider store={store}> | ||
<App /> | ||
</Provider>, | ||
); | ||
|
||
expect(updateLocationHookSpy).toBeCalled(); | ||
|
||
expect(screen.getByText(/Consumer Complaint Database/)).toBeInTheDocument(); | ||
expect(screen.getByText(/Search within/)).toBeInTheDocument(); | ||
expect( | ||
screen.getByRole('button', { name: /Show advanced search tips/ }), | ||
).toBeInTheDocument(); | ||
|
||
await waitFor(() => { | ||
expect( | ||
screen.getByRole('button', { name: /Take a tour/ }), | ||
).toBeInTheDocument(); | ||
}); | ||
}); | ||
|
||
it('renders the detail route', () => { | ||
render( | ||
<MemoryRouter initialEntries={['/detail/6026335']}> | ||
<Provider store={store}> | ||
<Routes> | ||
<Route path="/detail/:id" element={<ComplaintDetail />} /> | ||
</Routes> | ||
</Provider> | ||
</MemoryRouter>, | ||
); | ||
|
||
expect( | ||
screen.getByRole('link', { name: /Back to search results/ }), | ||
).toBeInTheDocument(); | ||
expect( | ||
screen.getByRole('link', { name: /Back to search results/ }), | ||
).toHaveAttribute( | ||
'href', | ||
'/?chartType=line&dateInterval=Month&dateRange=3y&date_received_max=2020-05-05&date_received_min=2017-05-05&lens=Product&searchField=all&subLens=sub_product&tab=Trends', | ||
); | ||
|
||
expect(screen.getByText('This page is loading')).toBeInTheDocument(); | ||
}); | ||
}); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { defaultAggs as aggs } from '../../reducers/aggs/aggs'; | ||
import { defaultDetail as detail } from '../../reducers/detail/detail'; | ||
import { defaultMap as map } from '../../reducers/map/map'; | ||
import { defaultQuery as query } from '../../reducers/query/query'; | ||
import { defaultTrends as trends } from '../../reducers/trends/trends'; | ||
import { defaultResults as results } from '../../reducers/results/results'; | ||
import { defaultView as view } from '../../reducers/view/view'; | ||
|
||
export default Object.freeze({ | ||
aggs, | ||
detail, | ||
map, | ||
query, | ||
results, | ||
trends, | ||
view, | ||
}); |
Oops, something went wrong.