Skip to content

Commit 4227e93

Browse files
Set up for standalone dev
1 parent b673d82 commit 4227e93

File tree

13 files changed

+61
-41
lines changed

13 files changed

+61
-41
lines changed

.github/workflows/ci.yml

+10-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
- name: Set up Node
1414
uses: actions/[email protected]
1515
with:
16-
node-version: 14.x
16+
node-version: 16.x
1717

1818
- name: Install Node dependencies
1919
run: |
@@ -30,6 +30,14 @@ jobs:
3030
with:
3131
github-token: ${{ secrets.GITHUB_TOKEN }}
3232

33+
- name: Start local website server
34+
run: |
35+
yarn start &
36+
sleep 5
37+
38+
- name: Run browser tests
39+
run: yarn run cypress run
40+
3341
backend:
3442
runs-on: ubuntu-latest
3543

@@ -49,7 +57,7 @@ jobs:
4957
- name: Set up Node
5058
uses: actions/[email protected]
5159
with:
52-
node-version: 14.x
60+
node-version: 16.x
5361

5462
- name: Install Node dependencies
5563
run: |

.github/workflows/release.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
- name: Set up Node
1414
uses: actions/[email protected]
1515
with:
16-
node-version: 14.x
16+
node-version: 16.x
1717

1818
- name: Install Node dependencies
1919
run: |

config/env.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -98,4 +98,9 @@ function getClientEnvironment(publicUrl) {
9898
return { raw, stringified };
9999
}
100100

101-
module.exports = getClientEnvironment;
101+
module.exports = {
102+
getClientEnvironment,
103+
/* If testing from within consumerfinance.gov,
104+
set `ccdbApiUrl` to '/data-research/consumer-complaints/search/api/v1/' */
105+
ccdbApiUrl: 'http://localhost:8000/'
106+
};

config/webpack.config.dev.js

+7-5
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ const InterpolateHtmlPlugin = require('react-dev-utils/InterpolateHtmlPlugin');
99
const WatchMissingNodeModulesPlugin = require('react-dev-utils/WatchMissingNodeModulesPlugin');
1010
const eslintFormatter = require('react-dev-utils/eslintFormatter');
1111
const ModuleScopePlugin = require('react-dev-utils/ModuleScopePlugin');
12-
const getClientEnvironment = require('./env');
12+
const env = require('./env');
13+
const getClientEnvironment = env.getClientEnvironment;
14+
const ccdbApiUrl = env.ccdbApiUrl;
1315
const paths = require('./paths');
1416

1517
// Webpack uses `publicPath` to determine where the app is being served from.
@@ -20,7 +22,7 @@ const publicPath = '/';
2022
// Omit trailing slash as %PUBLIC_PATH%/xyz looks better than %PUBLIC_PATH%xyz.
2123
const publicUrl = '';
2224
// Get environment variables to inject into our app.
23-
const env = getClientEnvironment(publicUrl);
25+
const envConfig = getClientEnvironment(publicUrl);
2426

2527
// This is the development configuration.
2628
// It is focused on developer experience and fast rebuilds.
@@ -159,7 +161,7 @@ module.exports = {
159161
loader: require.resolve('string-replace-loader'),
160162
options: {
161163
search: '@@API',
162-
replace: 'http://localhost:8000/data-research/consumer-complaints/search/api/v1/',
164+
replace: ccdbApiUrl,
163165
flags: 'g'
164166
}
165167
}
@@ -231,12 +233,12 @@ module.exports = {
231233
template: paths.appHtml,
232234
}),
233235
// In development, this will be an empty string.
234-
new InterpolateHtmlPlugin(HtmlWebpackPlugin, env.raw),
236+
new InterpolateHtmlPlugin(HtmlWebpackPlugin, envConfig.raw),
235237
// Add module names to factory functions so they appear in browser profiler.
236238
new webpack.NamedModulesPlugin(),
237239
// Makes some environment variables available to the JS code, for example:
238240
// if (process.env.NODE_ENV === 'development') { ... }. See `./env.js`.
239-
new webpack.DefinePlugin(env.stringified),
241+
new webpack.DefinePlugin(envConfig.stringified),
240242
// This is necessary to emit hot updates (currently CSS only):
241243
new webpack.HotModuleReplacementPlugin(),
242244
// Watcher doesn't work well if you mistype casing in a path so we use

config/webpack.config.prod.js

+7-5
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ const ModuleScopePlugin = require('react-dev-utils/ModuleScopePlugin');
1616
const getCSSModuleLocalIdent = require('react-dev-utils/getCSSModuleLocalIdent');
1717
const paths = require('./paths');
1818
const modules = require('./modules');
19-
const getClientEnvironment = require('./env');
19+
const env = require('./env');
20+
const getClientEnvironment = env.getClientEnvironment;
21+
const ccdbApiUrl = env.ccdbApiUrl;
2022
const ModuleNotFoundPlugin = require('react-dev-utils/ModuleNotFoundPlugin');
2123

2224
const postcssNormalize = require('postcss-normalize');
@@ -53,7 +55,7 @@ const shouldUseRelativeAssetPaths = publicPath === './';
5355
// Omit trailing slash as %PUBLIC_URL%/xyz looks better than %PUBLIC_URL%xyz.
5456
const publicUrl = paths.publicUrlOrPath;
5557
// Get environment variables to inject into our app.
56-
const env = getClientEnvironment(publicUrl);
58+
const envConfig = getClientEnvironment(publicUrl);
5759
// This is the production and development configuration.
5860
// It is focused on developer experience, fast rebuilds, and a minimal bundle.
5961

@@ -327,7 +329,7 @@ module.exports = {
327329
loader: require.resolve('string-replace-loader'),
328330
options: {
329331
search: '@@API',
330-
replace: '/data-research/consumer-complaints/search/api/v1/',
332+
replace: ccdbApiUrl,
331333
flags: 'g'
332334
}
333335
}
@@ -483,7 +485,7 @@ module.exports = {
483485
// In production, it will be an empty string unless you specify "homepage"
484486
// in `package.json`, in which case it will be the pathname of that URL.
485487
// In development, this will be an empty string.
486-
new InterpolateHtmlPlugin(HtmlWebpackPlugin, env.raw),
488+
new InterpolateHtmlPlugin(HtmlWebpackPlugin, envConfig.raw),
487489
// This gives some necessary context to module not found errors, such as
488490
// the requesting resource.
489491
new ModuleNotFoundPlugin(paths.appPath),
@@ -492,7 +494,7 @@ module.exports = {
492494
// It is absolutely essential that NODE_ENV is set to production
493495
// during a production build.
494496
// Otherwise React will be compiled in the very slow development mode.
495-
new webpack.DefinePlugin(env.stringified),
497+
new webpack.DefinePlugin(envConfig.stringified),
496498
new MiniCssExtractPlugin({
497499
// Options similar to the same options in webpackOptions.output
498500
// both options are optional

cypress.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,8 @@
66
"requestTimeout": 20000,
77
"screenshotOnRunFailure": false,
88
"video": false,
9-
"baseUrl": "http://localhost:8000/data-research/consumer-complaints/search/"
9+
"baseUrl": "http://localhost:3000/",
10+
"env": {
11+
"ccdbApiUrl": "http://localhost:8000/"
12+
}
1013
}

cypress/integration/common/filters-spec.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ import moment from 'moment';
55
describe( 'Filter Panel', () => {
66
beforeEach( () => {
77

8-
cy.intercept( 'GET', '**/api/v1/?**&size=0' )
8+
cy.intercept( 'GET', Cypress.env( 'ccdbApiUrl' ) + '?**&size=0' )
99
.as( 'getAggs' );
10-
cy.intercept( 'GET', '**/api/v1/?**&sort=created_date_desc' )
10+
cy.intercept( 'GET', Cypress.env( 'ccdbApiUrl' ) + '?**&sort=created_date_desc' )
1111
.as( 'getComplaints' );
12-
cy.visit( Cypress.env( 'HOST' ) + '?tab=List' );
12+
cy.visit( '?tab=List' );
1313
cy.wait( '@getAggs' );
1414
cy.wait( '@getComplaints' );
1515
} );
@@ -59,7 +59,7 @@ describe( 'Filter Panel', () => {
5959
} );
6060

6161
it( 'can trigger a pre-selected date range', () => {
62-
cy.intercept( 'GET', '**/api/v1/geo/states/?**' )
62+
cy.intercept( 'GET', Cypress.env( 'ccdbApiUrl' ) + 'geo/states/?**' )
6363
.as( 'getGeo' );
6464
cy.get( 'button.map' )
6565
.click();

cypress/integration/document/document-spec.js

+8-7
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
describe( 'Document View', () => {
44
describe( 'error handling', () => {
55
it( 'handles bogus id', () => {
6-
cy.visit( Cypress.env( 'HOST' ) + '/detail/ThisIsNotAValidId' )
6+
cy.visit( '/detail/ThisIsNotAValidId' )
77
cy.get( 'h1' )
88
.contains( 'There was a problem retrieving ThisIsNotAValidId' )
99
.should( 'be.visible' )
@@ -12,12 +12,12 @@ describe( 'Document View', () => {
1212

1313
describe( 'document detail view', () => {
1414
beforeEach( () => {
15-
cy.intercept( 'GET', '**/api/v1/?**&size=0' )
15+
cy.intercept( 'GET', Cypress.env( 'ccdbApiUrl' ) + '?**&size=0' )
1616
.as( 'getAggs' );
17-
cy.intercept( 'GET', '**/api/v1/?**&sort=created_date_desc' )
17+
cy.intercept( 'GET', Cypress.env( 'ccdbApiUrl' ) + '?**&sort=created_date_desc' )
1818
.as( 'getComplaints' );
1919

20-
cy.visit( Cypress.env( 'HOST' ) + '?tab=List' )
20+
cy.visit( '?tab=List' )
2121

2222
cy.wait( '@getAggs' );
2323
cy.wait( '@getComplaints' );
@@ -42,11 +42,12 @@ describe( 'Document View', () => {
4242

4343
describe( 'preserve page state', () => {
4444
it( 'restores filters after visiting document detail', () => {
45-
cy.intercept( 'GET', '**/api/v1/?**&field=all&has_narrative=true&search_term=pizza&size=10&sort=relevance_desc' )
45+
cy.intercept( 'GET', Cypress.env( 'ccdbApiUrl' ) + '?**&field=all&has_narrative=true&search_term=pizza&size=10&sort=relevance_desc' )
4646
.as( 'getResults' )
4747

48-
cy.visit( Cypress.env( 'HOST' ) +
49-
'?searchText=pizza&has_narrative=true&size=10&sort=relevance_desc&tab=List' )
48+
cy.visit(
49+
'?searchText=pizza&has_narrative=true&size=10&sort=relevance_desc&tab=List'
50+
)
5051

5152
cy.wait( '@getResults' )
5253

cypress/integration/list/list-spec.js

+9-7
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,18 @@ describe( 'List View', () => {
44
const nextButton = '.m-pagination .m-pagination_btn-next'
55
const prevButton = '.m-pagination .m-pagination_btn-prev'
66
beforeEach( () => {
7-
cy.intercept( '**/api/v1/**&field=all**sort=created_date_desc' )
7+
cy.intercept( Cypress.env( 'ccdbApiUrl' ) + '?**&field=all**sort=created_date_desc' )
88
.as( 'getComplaints' )
9-
cy.intercept( 'GET', '**/api/v1/?**&size=0' )
9+
cy.intercept( 'GET', Cypress.env( 'ccdbApiUrl' ) + '?**&size=0' )
1010
.as( 'getAggs' );
11-
cy.visit( Cypress.env( 'HOST' ) + '?size=10&searchText=debt%20recovery&tab=List' )
11+
cy.visit( '?size=10&searchText=debt%20recovery&tab=List' )
1212
cy.wait( '@getComplaints' );
1313
cy.wait( '@getAggs' );
1414
} )
1515

1616
describe( 'initial rendering', () => {
1717
it( 'contains a list view', () => {
18+
1819
cy.get( '.cards-panel' )
1920
.should( 'be.visible' )
2021
cy.get( cardContainers )
@@ -27,7 +28,8 @@ describe( 'List View', () => {
2728
cy.get( cardContainers ).should( 'have.length', 10 )
2829
cy.url().should( 'contain', 'size=10' )
2930

30-
cy.intercept( '**/api/v1/**search_after**' ).as( 'getNextComplaints' )
31+
cy.intercept( Cypress.env( 'ccdbApiUrl' ) + '?**search_after**' )
32+
.as( 'getNextComplaints' )
3133

3234
cy.get( nextButton ).click()
3335

@@ -37,7 +39,7 @@ describe( 'List View', () => {
3739

3840
cy.log( 'reset the pager after sort' )
3941

40-
cy.intercept( '**/api/v1/**size=10&sort=created_date_desc' )
42+
cy.intercept( Cypress.env( 'ccdbApiUrl' ) + '?**size=10&sort=created_date_desc' )
4143
.as( 'get10Complaints' )
4244

4345
cy.get( '#choose-size' ).select( '10 results' )
@@ -53,10 +55,10 @@ describe( 'List View', () => {
5355
it( 'changes the sort order', () => {
5456
cy.url().should( 'contain', 'sort=created_date_desc' )
5557

56-
cy.intercept( '**/api/v1/**&field=all**&size=10&sort=relevance_desc' )
58+
cy.intercept( Cypress.env( 'ccdbApiUrl' ) + '?**&field=all**&size=10&sort=relevance_desc' )
5759
.as( 'getRelevanceComplaints' )
5860

59-
cy.intercept( '**/api/v1/**search_after**' )
61+
cy.intercept( Cypress.env( 'ccdbApiUrl' ) + '?**search_after**' )
6062
.as( 'getNextComplaints' )
6163

6264
cy.get( nextButton ).click()

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
"eslint-plugin-react-hooks": "^1.6.1",
6161
"file-loader": "3.0.1",
6262
"fs-extra": "7.0.1",
63-
"highcharts": "^9.2.2",
63+
"highcharts": "9.2.2",
6464
"history": "^4.10.1",
6565
"html-webpack-plugin": "4.0.0-beta.5",
6666
"http-proxy-middleware": "^0.20.0",

public/index.html

+1-4
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,9 @@
66
<meta charset="utf-8">
77
<meta name="viewport" content="width=device-width, initial-scale=1">
88
<title>Development Harness</title>
9-
<link rel="stylesheet" href="https://cfpb.github.io/capital-framework/dist/static/css/main.min.css">
10-
11-
<script src="https://cfpb.github.io/capital-framework/dist/static/js/main.min.js"></script>
129
<script src="https://files.consumerfinance.gov/ccdb/metadata.js" type="text/javascript"></script>
1310
</head>
1411
<body>
15-
<div id="root"></div>
12+
<div id="ccdb-ui-root"></div>
1613
</body>
1714
</html>

src/components/Dialogs/RootModal.jsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export const RootModal = ( { modalType, modalProps, onClose } ) => {
2222
const SpecificModal = MODAL_COMPONENTS[modalType]
2323

2424
return (
25-
<ReactModal appElement={ document.querySelector( '#root' ) }
25+
<ReactModal appElement={ document.querySelector( '#ccdb-ui-root' ) }
2626
isOpen={true}
2727
contentLabel="CFPB Modal Dialog"
2828
className="modal-body"
@@ -33,7 +33,7 @@ export const RootModal = ( { modalType, modalProps, onClose } ) => {
3333
)
3434
}
3535

36-
return <ReactModal appElement={ document.querySelector( '#root' ) }
36+
return <ReactModal appElement={ document.querySelector( '#ccdb-ui-root' ) }
3737
isOpen={ false }>
3838
</ReactModal>
3939
}

src/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ function main( err ) {
4343
var ReactDOM = require( 'react-dom' )
4444
var React = require( 'react' )
4545

46-
ReactDOM.render( <App />, document.getElementById( 'root' ) )
46+
ReactDOM.render( <App />, document.getElementById( 'ccdb-ui-root' ) )
4747
}
4848
}
4949

0 commit comments

Comments
 (0)