Skip to content

Commit

Permalink
fixed e2e tests failing when running on production build
Browse files Browse the repository at this point in the history
  • Loading branch information
daneryl committed Aug 24, 2017
1 parent 9da098c commit 6d7f345
Show file tree
Hide file tree
Showing 10 changed files with 115 additions and 68 deletions.
1 change: 1 addition & 0 deletions app/react/App/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import 'bootstrap/dist/css/bootstrap.css';
//import 'font-awesome/css/font-awesome.css';
import 'react-widgets/lib/scss/react-widgets.scss';
import './scss/styles.scss';
import 'nprogress/nprogress.css';

import Notifications from 'app/Notifications';
import Menu from './Menu';
Expand Down
2 changes: 0 additions & 2 deletions app/react/App/LoadingProgressBar.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import {isClient} from 'app/utils';
import Nprogress from 'nprogress';

import 'nprogress/nprogress.css';

if (isClient) {
window.NProgress = Nprogress;
}
Expand Down
15 changes: 8 additions & 7 deletions app/react/App/Root.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class Root extends Component {
}

render() {
const isDeveloping = process.env.NODE_ENV !== 'production';
//const isDeveloping = process.env.NODE_ENV !== 'production';
const head = this.props.head;

return (
Expand All @@ -33,7 +33,7 @@ class Root extends Component {
{head.link.toComponent()}
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link
href={isDeveloping ? '/style.css' : '/style.css'}
href={this.props.assets.main.css}
rel="stylesheet"
type="text/css"
/>
Expand All @@ -47,10 +47,10 @@ class Root extends Component {
{this.renderInitialData()}
{head.script.toComponent()}
<link rel='stylesheet' href='https://opensource.keycdn.com/fontawesome/4.7.0/font-awesome.min.css'/>
<link rel='stylesheet' href='/nprogress.css'/>
<script defer src={isDeveloping ? '/manifest.bundle.js' : '/manifest.bundle.js'}></script>
<script defer src={isDeveloping ? '/vendor.bundle.js' : '/vendor.bundle.js'}></script>
<script defer src={isDeveloping ? '/main.bundle.js' : '/main.bundle.js'}></script>
<script defer src={this.props.assets.manifest.js}></script>
<script defer src={this.props.assets.nprogress.js}></script>
<script defer src={this.props.assets.vendor.js}></script>
<script defer src={this.props.assets.main.js}></script>
</body>
</html>
);
Expand All @@ -63,7 +63,8 @@ Root.propTypes = {
initialData: PropTypes.object,
reduxData: PropTypes.object,
head: PropTypes.object,
content: PropTypes.string
content: PropTypes.string,
assets: PropTypes.object
};

export default Root;
3 changes: 2 additions & 1 deletion app/react/ServerRouter.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {I18NUtils} from 'app/I18N';
import JSONUtils from 'shared/JSONUtils';
import {fromJS as Immutable} from 'immutable';
import {getPropsFromRoute} from './utils';
import assets from '../../dist/webpack-assets.json';

function renderComponentWithRoot(Component, componentProps, initialData, user, isRedux = false) {
let componentHtml;
Expand Down Expand Up @@ -50,7 +51,7 @@ function renderComponentWithRoot(Component, componentProps, initialData, user, i
}

return '<!doctype html>\n' + renderToString(
<Root content={componentHtml} initialData={data} head={head} user={user} reduxData={reduxData}/>
<Root content={componentHtml} initialData={data} head={head} user={user} reduxData={reduxData} assets={assets}/>
);
}

Expand Down
39 changes: 0 additions & 39 deletions app/react/Viewer/actions/referencesActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,45 +6,6 @@ import {actions} from 'app/BasicReducer';
import * as uiActions from './uiActions';
import {actions as connectionsActions} from 'app/Connections';

import {isClient} from 'app/utils';

import {store} from '../../store.js';
if (isClient) {
window.uwazi = {};
window.uwazi.moveConnection = (id, leftOffset, right) => {
const rightOffset = right || leftOffset;
let reference = store.getState().documentViewer.references.toJS().find((r) => r._id === id);
let pdfInfo = store.getState().documentViewer.doc.get('pdfInfo').toJS();
let movedRef = {
_rev: reference._rev,
_id: reference._id,
sourceRange: reference.sourceRange,
targetDocument: reference.targetDocument,
targetRange: reference.targetRange,
sourceDocument: reference.sourceDocument,
relationType: reference.relationType,
language: reference.language,
type: reference.type
};

movedRef.sourceRange.start += leftOffset;
movedRef.sourceRange.end += rightOffset;

store.dispatch({
type: types.REMOVE_REFERENCE,
reference: movedRef
});
return connectionsActions.saveConnection(movedRef, (updatedReference) => {
store.dispatch({
type: types.ADD_REFERENCE,
reference: updatedReference
});
store.dispatch(uiActions.activateReference(updatedReference, pdfInfo, 'references'));
})(store.dispatch, store.getState);
};
}


export function setReferences(references) {
return {
type: types.SET_REFERENCES,
Expand Down
3 changes: 2 additions & 1 deletion nightmare/paths/references.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,9 @@ describe('references path', () => {
.catch(catchErrors(done));
});

it('delete the created connection', (done) => {
it('should delete the created connection', (done) => {
nightmare
.wait('a.reference')
.mouseover(selectors.documentView.activeConnection)
.waitToClick(selectors.documentView.unlinkIcon)
.waitToClick('.modal-footer .btn-danger')
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@
"wrap-range-text": "^1.0.1"
},
"devDependencies": {
"assets-webpack-plugin": "^3.5.1",
"babel-istanbul-loader": "^0.1.0",
"babel-plugin-react-transform": "^2.0.0",
"babel-polyfill": "^6.23.0",
Expand Down
3 changes: 2 additions & 1 deletion server.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ var error_handling_middleware = require('./app/api/utils/error_handling_middlewa

app.use(error_handling_middleware);
app.use(compression());
app.use(express.static(path.resolve(__dirname, 'dist')));
var oneYear = 31557600;
app.use(express.static(path.resolve(__dirname, 'dist'), {maxage: oneYear}));
app.use('/uploaded_documents', express.static(path.resolve(__dirname, 'uploaded_documents')));
app.use('/public', express.static(path.resolve(__dirname, 'public')));
app.use('/flag-images', express.static(path.resolve(__dirname, 'node_modules/react-flags/vendor/flags')));
Expand Down
23 changes: 7 additions & 16 deletions webpack/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ var CleanPlugin = require('./CleanPlugin');

var rootPath = __dirname + '/../';

const extractNprogressCSS = new ExtractTextPlugin('nprogress.css');
const CoreCss = new ExtractTextPlugin('style.css');
const CoreCss = new ExtractTextPlugin('styles.[contenthash].css');
var AssetsPlugin = require('assets-webpack-plugin')
var assetsPluginInstance = new AssetsPlugin({path: path.join(rootPath + '/dist/')})

module.exports = {
context: rootPath,
Expand All @@ -22,7 +23,7 @@ module.exports = {
output: {
path: path.join(rootPath, '/dist/'),
publicPath: '/',
filename: '[name].bundle.js'
filename: '[name].[chunkhash].js'
},
resolveLoader: {
modules: ['node_modules', __dirname + '/webpackLoaders'],
Expand Down Expand Up @@ -52,17 +53,6 @@ module.exports = {
path.join(rootPath, 'node_modules/react-widgets/lib/scss/')
]
},
{
test: /nprogress\.css$/,
loader: extractNprogressCSS.extract({
fallback: 'style-loader',
use: 'css-loader?sourceMap'
}),
include: [
path.join(rootPath, 'app'),
path.join(rootPath, 'node_modules/nprogress/')
]
},
{
test: /\.css$/,
loader: CoreCss.extract({
Expand All @@ -73,6 +63,7 @@ module.exports = {
path.join(rootPath, 'app'),
path.join(rootPath, 'node_modules/react-datepicker/dist/'),
path.join(rootPath, 'node_modules/bootstrap/dist/'),
path.join(rootPath, 'node_modules/nprogress/'),
path.join(rootPath, 'node_modules/font-awesome/css/'),
path.join(rootPath, 'node_modules/pdfjs-dist/web'),
]
Expand Down Expand Up @@ -121,7 +112,7 @@ module.exports = {
minChunks: Infinity
}),
CoreCss,
extractNprogressCSS,
new webpack.optimize.ModuleConcatenationPlugin()
new webpack.optimize.ModuleConcatenationPlugin(),
assetsPluginInstance
]
};
93 changes: 92 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,16 @@ assertion-error@1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/assertion-error/-/assertion-error-1.0.0.tgz#c7f85438fdd466bc7ca16ab90c81513797a5d23b"

assets-webpack-plugin@^3.5.1:
version "3.5.1"
resolved "https://registry.yarnpkg.com/assets-webpack-plugin/-/assets-webpack-plugin-3.5.1.tgz#931ce0d66d42e88ed5e7f18d65522943c57a387d"
dependencies:
camelcase "^1.2.1"
escape-string-regexp "^1.0.3"
lodash.assign "^3.2.0"
lodash.merge "^3.3.2"
mkdirp "^0.5.1"

async-each-series@^1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/async-each-series/-/async-each-series-1.1.0.tgz#f42fd8155d38f21a5b8ea07c28e063ed1700b138"
Expand Down Expand Up @@ -1194,7 +1204,7 @@ camelcase-keys@^2.0.0:
camelcase "^2.0.0"
map-obj "^1.0.0"

camelcase@^1.0.2:
camelcase@^1.0.2, camelcase@^1.2.1:
version "1.2.1"
resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-1.2.1.tgz#9bb5304d2e0b56698b2c758b08a3eaa9daa58a39"

Expand Down Expand Up @@ -4585,10 +4595,29 @@ lodash-es@^4.2.0, lodash-es@^4.2.1:
version "4.17.4"
resolved "https://registry.yarnpkg.com/lodash-es/-/lodash-es-4.17.4.tgz#dcc1d7552e150a0640073ba9cb31d70f032950e7"

lodash._arraycopy@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/lodash._arraycopy/-/lodash._arraycopy-3.0.0.tgz#76e7b7c1f1fb92547374878a562ed06a3e50f6e1"

lodash._arrayeach@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/lodash._arrayeach/-/lodash._arrayeach-3.0.0.tgz#bab156b2a90d3f1bbd5c653403349e5e5933ef9e"

lodash._baseassign@^3.0.0:
version "3.2.0"
resolved "https://registry.yarnpkg.com/lodash._baseassign/-/lodash._baseassign-3.2.0.tgz#8c38a099500f215ad09e59f1722fd0c52bfe0a4e"
dependencies:
lodash._basecopy "^3.0.0"
lodash.keys "^3.0.0"

lodash._basecopy@^3.0.0:
version "3.0.1"
resolved "https://registry.yarnpkg.com/lodash._basecopy/-/lodash._basecopy-3.0.1.tgz#8da0e6a876cf344c0ad8a54882111dd3c5c7ca36"

lodash._basefor@^3.0.0:
version "3.0.3"
resolved "https://registry.yarnpkg.com/lodash._basefor/-/lodash._basefor-3.0.3.tgz#7550b4e9218ef09fad24343b612021c79b4c20c2"

lodash._basetostring@^3.0.0:
version "3.0.1"
resolved "https://registry.yarnpkg.com/lodash._basetostring/-/lodash._basetostring-3.0.1.tgz#d1861d877f824a52f669832dcaf3ee15566a07d5"
Expand All @@ -4597,6 +4626,18 @@ lodash._basevalues@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/lodash._basevalues/-/lodash._basevalues-3.0.0.tgz#5b775762802bde3d3297503e26300820fdf661b7"

lodash._bindcallback@^3.0.0:
version "3.0.1"
resolved "https://registry.yarnpkg.com/lodash._bindcallback/-/lodash._bindcallback-3.0.1.tgz#e531c27644cf8b57a99e17ed95b35c748789392e"

lodash._createassigner@^3.0.0:
version "3.1.1"
resolved "https://registry.yarnpkg.com/lodash._createassigner/-/lodash._createassigner-3.1.1.tgz#838a5bae2fdaca63ac22dee8e19fa4e6d6970b11"
dependencies:
lodash._bindcallback "^3.0.0"
lodash._isiterateecall "^3.0.0"
lodash.restparam "^3.0.0"

lodash._createcompounder@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/lodash._createcompounder/-/lodash._createcompounder-3.0.0.tgz#5dd2cb55372d6e70e0e2392fb2304d6631091075"
Expand Down Expand Up @@ -4628,6 +4669,14 @@ lodash._root@^3.0.0:
version "3.0.1"
resolved "https://registry.yarnpkg.com/lodash._root/-/lodash._root-3.0.1.tgz#fba1c4524c19ee9a5f8136b4609f017cf4ded692"

lodash.assign@^3.2.0:
version "3.2.0"
resolved "https://registry.yarnpkg.com/lodash.assign/-/lodash.assign-3.2.0.tgz#3ce9f0234b4b2223e296b8fa0ac1fee8ebca64fa"
dependencies:
lodash._baseassign "^3.0.0"
lodash._createassigner "^3.0.0"
lodash.keys "^3.0.0"

lodash.assign@^4.0.3, lodash.assign@^4.0.6, lodash.assign@^4.0.9, lodash.assign@^4.2.0:
version "4.2.0"
resolved "https://registry.yarnpkg.com/lodash.assign/-/lodash.assign-4.2.0.tgz#0d99f3ccd7a6d261d19bdaeb9245005d285808e7"
Expand Down Expand Up @@ -4698,6 +4747,18 @@ lodash.isequal@^4.0.0, lodash.isequal@^4.4.0:
version "4.5.0"
resolved "https://registry.yarnpkg.com/lodash.isequal/-/lodash.isequal-4.5.0.tgz#415c4478f2bcc30120c22ce10ed3226f7d3e18e0"

lodash.isplainobject@^3.0.0:
version "3.2.0"
resolved "https://registry.yarnpkg.com/lodash.isplainobject/-/lodash.isplainobject-3.2.0.tgz#9a8238ae16b200432960cd7346512d0123fbf4c5"
dependencies:
lodash._basefor "^3.0.0"
lodash.isarguments "^3.0.0"
lodash.keysin "^3.0.0"

lodash.istypedarray@^3.0.0:
version "3.0.6"
resolved "https://registry.yarnpkg.com/lodash.istypedarray/-/lodash.istypedarray-3.0.6.tgz#c9a477498607501d8e8494d283b87c39281cef62"

lodash.keys@^3.0.0, lodash.keys@^3.1.2:
version "3.1.2"
resolved "https://registry.yarnpkg.com/lodash.keys/-/lodash.keys-3.1.2.tgz#4dbc0472b156be50a0b286855d1bd0b0c656098a"
Expand All @@ -4706,6 +4767,13 @@ lodash.keys@^3.0.0, lodash.keys@^3.1.2:
lodash.isarguments "^3.0.0"
lodash.isarray "^3.0.0"

lodash.keysin@^3.0.0:
version "3.0.8"
resolved "https://registry.yarnpkg.com/lodash.keysin/-/lodash.keysin-3.0.8.tgz#22c4493ebbedb1427962a54b445b2c8a767fb47f"
dependencies:
lodash.isarguments "^3.0.0"
lodash.isarray "^3.0.0"

lodash.map@^4.4.0:
version "4.6.0"
resolved "https://registry.yarnpkg.com/lodash.map/-/lodash.map-4.6.0.tgz#771ec7839e3473d9c4cde28b19394c3562f4f6d3"
Expand All @@ -4714,6 +4782,22 @@ lodash.memoize@^4.1.2:
version "4.1.2"
resolved "https://registry.yarnpkg.com/lodash.memoize/-/lodash.memoize-4.1.2.tgz#bcc6c49a42a2840ed997f323eada5ecd182e0bfe"

lodash.merge@^3.3.2:
version "3.3.2"
resolved "https://registry.yarnpkg.com/lodash.merge/-/lodash.merge-3.3.2.tgz#0d90d93ed637b1878437bb3e21601260d7afe994"
dependencies:
lodash._arraycopy "^3.0.0"
lodash._arrayeach "^3.0.0"
lodash._createassigner "^3.0.0"
lodash._getnative "^3.0.0"
lodash.isarguments "^3.0.0"
lodash.isarray "^3.0.0"
lodash.isplainobject "^3.0.0"
lodash.istypedarray "^3.0.0"
lodash.keys "^3.0.0"
lodash.keysin "^3.0.0"
lodash.toplainobject "^3.0.0"

lodash.merge@^4.4.0:
version "4.6.0"
resolved "https://registry.yarnpkg.com/lodash.merge/-/lodash.merge-4.6.0.tgz#69884ba144ac33fe699737a6086deffadd0f89c5"
Expand Down Expand Up @@ -4763,6 +4847,13 @@ lodash.topath@~4.5.2:
version "4.5.2"
resolved "https://registry.yarnpkg.com/lodash.topath/-/lodash.topath-4.5.2.tgz#3616351f3bba61994a0931989660bd03254fd009"

lodash.toplainobject@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/lodash.toplainobject/-/lodash.toplainobject-3.0.0.tgz#28790ad942d293d78aa663a07ecf7f52ca04198d"
dependencies:
lodash._basecopy "^3.0.0"
lodash.keysin "^3.0.0"

lodash.trimend@^4.5.1:
version "4.5.1"
resolved "https://registry.yarnpkg.com/lodash.trimend/-/lodash.trimend-4.5.1.tgz#12804437286b98cad8996b79414e11300114082f"
Expand Down

0 comments on commit 6d7f345

Please sign in to comment.