diff --git a/__tests__/server/__snapshots__/renderer.jsx.snap b/__tests__/server/__snapshots__/renderer.jsx.snap index bc0a17ec..517ca07c 100644 --- a/__tests__/server/__snapshots__/renderer.jsx.snap +++ b/__tests__/server/__snapshots__/renderer.jsx.snap @@ -2,10 +2,12 @@ exports[`Base rendering of HTML template 1`] = ` " - + + + - + + + - + Test Page Title + + - + + + - + + + - + + + { + /* Modal uses ReactJS portals to ensure proper rendering. react-test-renderer, + * used by utils/jest under the hood, does not support it properly, thus this + * simple mock for the createPortal(..) function. */ + ReactDom.createPortal = jest.fn(element => ( +
+ {element} +
+ )); +}); + +test('Snapshot match', () => { + snapshot(CONTENT); +}); + +test('onCancel', () => { + const onCancel = jest.fn(); + const dom = renderDom(( + + )); + const overlay = findInDomByClass(dom, 'overlay'); + simulate.click(overlay); + expect(onCancel).toHaveBeenCalled(); +}); + +test('onWheel', () => { + const dom = renderDom(( + + )); + const container = findInDomByClass(dom, 'container'); + const stopPropagation = jest.fn(); + simulate.wheel(container, { stopPropagation }); + expect(stopPropagation).toHaveBeenCalled(); +}); diff --git a/__tests__/shared/components/__snapshots__/Modal.jsx.snap b/__tests__/shared/components/__snapshots__/Modal.jsx.snap new file mode 100644 index 00000000..9cbf3aa4 --- /dev/null +++ b/__tests__/shared/components/__snapshots__/Modal.jsx.snap @@ -0,0 +1,19 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Snapshot match 1`] = ` +
+
+ CONTENT +
+
+`; diff --git a/src/server/renderer.jsx b/src/server/renderer.jsx index 905cb8b6..91c7ad99 100644 --- a/src/server/renderer.jsx +++ b/src/server/renderer.jsx @@ -184,10 +184,12 @@ export default function factory(webpackConfig, options) { res.send(( ` - + ${helmet ? helmet.title.toString() : ''} ${helmet ? helmet.meta.toString() : ''} + + (req, res, next) => { + if (req.url.indexOf('/sw.js') > -1) { + next(); + return; + } + middleware(req, res, next); + }; + /* Setup of Hot Module Reloading for development environment. * These dependencies are not used, nor installed for production use, * hence we should violate some import-related lint rules. */ @@ -56,18 +64,19 @@ export default async function factory(webpackConfig, options) { const webpackHotMiddleware = require('webpack-hot-middleware'); const compiler = webpack(webpackConfig); compiler.apply(new webpack.ProgressPlugin()); - server.use(webpackDevMiddleware(compiler, { + server.use(exludeSW(webpackDevMiddleware(compiler, { name: 'main.js', publicPath, serverSideRender: true, - })); - server.use(webpackHotMiddleware(compiler)); + }))); + server.use(exludeSW(webpackHotMiddleware(compiler))); } /* eslint-enable global-require */ /* eslint-enable import/no-extraneous-dependencies */ /* eslint-enable import/no-unresolved */ - server.use(publicPath, express.static(webpackConfig.output.path)); + server.use(publicPath, exludeSW(express.static(webpackConfig.output.path))); + if (options.onExpressJsSetup) { await options.onExpressJsSetup(server); } diff --git a/src/shared/components/Button.jsx b/src/shared/components/Button.jsx index 4b20e230..93135868 100644 --- a/src/shared/components/Button.jsx +++ b/src/shared/components/Button.jsx @@ -71,6 +71,7 @@ export default function Button({ onClick={onClick} onMouseDown={onMouseDown} type={type} + tabIndex="0" > {children} diff --git a/src/shared/components/Modal/index.jsx b/src/shared/components/Modal/index.jsx index c0e86608..243cbcf4 100644 --- a/src/shared/components/Modal/index.jsx +++ b/src/shared/components/Modal/index.jsx @@ -19,7 +19,7 @@ import defaultStyle from './style.scss'; /* NOTE: Modal component is implemented as class, as it demands advanced * interaction with DOM upon mount and unmount. */ -class Modal extends React.Component { +class BaseModal extends React.Component { constructor(props) { super(props); this.portal = document.createElement('div'); @@ -62,19 +62,19 @@ class Modal extends React.Component { } } -Modal.defaultProps = { +BaseModal.defaultProps = { onCancel: _.noop, children: null, theme: {}, }; -Modal.propTypes = { +BaseModal.propTypes = { onCancel: PT.func, children: PT.node, theme: PT.shape(), }; /* Non-themed version of the Modal. */ -export const BaseModal = Modal; +export { BaseModal }; -export default themr('Modal', defaultStyle)(Modal); +export default themr('Modal', defaultStyle)(BaseModal);