From bf669857ed48defa45e29360ae76877cdc9c10ca Mon Sep 17 00:00:00 2001 From: Piero Toffanin Date: Mon, 2 Dec 2019 17:23:26 -0500 Subject: [PATCH] Fixed jest tests --- app/plugins/templates/webpack.config.js.tmpl | 4 ++-- app/static/app/js/components/LayersControl.jsx | 2 +- app/static/app/js/components/Map.jsx | 4 +--- .../app/js/components/tests/Histogram.test.jsx | 10 ++++++++++ app/static/app/js/components/tests/Map.test.jsx | 2 +- app/tests/test_api_task.py | 9 +++++++++ package.json | 2 +- plugins/contours/public/Contours.jsx | 2 +- plugins/elevationmap/public/ElevationMap.jsx | 2 +- plugins/measure/public/app.jsx | 2 +- webpack-server.js | 15 --------------- webpack.config.js | 4 ++-- 12 files changed, 30 insertions(+), 28 deletions(-) create mode 100644 app/static/app/js/components/tests/Histogram.test.jsx delete mode 100644 webpack-server.js diff --git a/app/plugins/templates/webpack.config.js.tmpl b/app/plugins/templates/webpack.config.js.tmpl index 0817dc92..0ea8d9ae 100644 --- a/app/plugins/templates/webpack.config.js.tmpl +++ b/app/plugins/templates/webpack.config.js.tmpl @@ -80,8 +80,8 @@ module.exports = { "SystemJS": "SystemJS", "PluginsAPI": "PluginsAPI", "leaflet": "leaflet", - "ReactDOM": "ReactDOM", - "React": "React" + "react-dom": "ReactDOM", + "react": "React" }, watchOptions: { diff --git a/app/static/app/js/components/LayersControl.jsx b/app/static/app/js/components/LayersControl.jsx index 92c7e436..c2a1d497 100644 --- a/app/static/app/js/components/LayersControl.jsx +++ b/app/static/app/js/components/LayersControl.jsx @@ -1,5 +1,5 @@ import L from 'leaflet'; -import ReactDOM from 'ReactDOM'; +import ReactDOM from 'react-dom'; import React from 'react'; import PropTypes from 'prop-types'; import '../css/LayersControl.scss'; diff --git a/app/static/app/js/components/Map.jsx b/app/static/app/js/components/Map.jsx index 137e0312..0e935800 100644 --- a/app/static/app/js/components/Map.jsx +++ b/app/static/app/js/components/Map.jsx @@ -441,9 +441,7 @@ https://a.tile.openstreetmap.org/{z}/{x}/{y}.png style={{height: "100%"}} ref={(domNode) => (this.container = domNode)} onMouseDown={this.handleMapMouseDown} - > - - + />
{this.state.pluginActionButtons.map((button, i) =>
{button}
)} diff --git a/app/static/app/js/components/tests/Histogram.test.jsx b/app/static/app/js/components/tests/Histogram.test.jsx new file mode 100644 index 00000000..0d30bd78 --- /dev/null +++ b/app/static/app/js/components/tests/Histogram.test.jsx @@ -0,0 +1,10 @@ +import React from 'react'; +import { mount } from 'enzyme'; +import Histogram from '../Histogram'; + +describe('', () => { + it('renders without exploding', () => { + const wrapper = mount(); + expect(wrapper.exists()).toBe(true); + }) +}); \ No newline at end of file diff --git a/app/static/app/js/components/tests/Map.test.jsx b/app/static/app/js/components/tests/Map.test.jsx index fe0b8c50..02dd02c8 100644 --- a/app/static/app/js/components/tests/Map.test.jsx +++ b/app/static/app/js/components/tests/Map.test.jsx @@ -8,7 +8,7 @@ sinon.useFakeXMLHttpRequest(); describe('', () => { it('renders without exploding', () => { const wrapper = mount(); + tiles={[]} />); expect(wrapper.exists()).toBe(true); }) diff --git a/app/tests/test_api_task.py b/app/tests/test_api_task.py index f67560dc..05e8798c 100644 --- a/app/tests/test_api_task.py +++ b/app/tests/test_api_task.py @@ -413,6 +413,12 @@ class TestApiTask(BootTransactionTestCase): self.assertTrue(len(metadata['algorithms']) > 0) self.assertTrue(len(metadata['color_maps']) > 0) + # Algorithms have valid keys + for k in ['id', 'filters', 'expr', 'help']: + for a in metadata['algorithms']: + self.assertTrue(k in a) + self.assertTrue(len(a['filters']) > 0) + # Colormap is for algorithms self.assertEqual(len([x for x in metadata['color_maps'] if x['key'] == 'rdylgn']), 1) self.assertEqual(len([x for x in metadata['color_maps'] if x['key'] == 'jet_r']), 0) @@ -472,6 +478,9 @@ class TestApiTask(BootTransactionTestCase): self.assertEqual(i.width, 512) self.assertEqual(i.height, 512) + # TODO: Test hillshade + + # Another user does not have access to the resources other_client = APIClient() other_client.login(username="testuser2", password="test1234") diff --git a/package.json b/package.json index 4ce3228f..8ce29194 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,7 @@ "css-loader": "^0.25.0", "d3": "^3.5.5", "enzyme": "^3.3.0", - "enzyme-adapter-react-16": "^1.1.1", + "enzyme-adapter-react-16": "^1.15.1", "extract-text-webpack-plugin": "^4.0.0-beta.0", "fbemitter": "^2.1.1", "file-loader": "^0.9.0", diff --git a/plugins/contours/public/Contours.jsx b/plugins/contours/public/Contours.jsx index b0094751..3e64e422 100644 --- a/plugins/contours/public/Contours.jsx +++ b/plugins/contours/public/Contours.jsx @@ -1,5 +1,5 @@ import L from 'leaflet'; -import ReactDOM from 'ReactDOM'; +import ReactDOM from 'react-dom'; import React from 'react'; import PropTypes from 'prop-types'; import './Contours.scss'; diff --git a/plugins/elevationmap/public/ElevationMap.jsx b/plugins/elevationmap/public/ElevationMap.jsx index fd3b2414..501f24c7 100644 --- a/plugins/elevationmap/public/ElevationMap.jsx +++ b/plugins/elevationmap/public/ElevationMap.jsx @@ -1,5 +1,5 @@ import L from 'leaflet'; -import ReactDOM from 'ReactDOM'; +import ReactDOM from 'react-dom'; import React from 'react'; import PropTypes from 'prop-types'; import './ElevationMap.scss'; diff --git a/plugins/measure/public/app.jsx b/plugins/measure/public/app.jsx index d9ffbfd4..50c82ab3 100644 --- a/plugins/measure/public/app.jsx +++ b/plugins/measure/public/app.jsx @@ -4,7 +4,7 @@ import 'leaflet-measure-ex/dist/leaflet-measure'; import 'leaflet-measure-ex/dist/leaflet-measure.css'; import MeasurePopup from './MeasurePopup'; import Utils from 'webodm/classes/Utils'; -import ReactDOM from 'ReactDOM'; +import ReactDOM from 'react-dom'; import React from 'react'; import $ from 'jquery'; diff --git a/webpack-server.js b/webpack-server.js deleted file mode 100644 index 9283b726..00000000 --- a/webpack-server.js +++ /dev/null @@ -1,15 +0,0 @@ -let webpack = require('webpack'); -let WebpackDevServer = require('webpack-dev-server'); -let config = require('./webpack.config'); -//ajax code -new WebpackDevServer(webpack(config), { - publicPath: config.output.publicPath, - hot: true, - inline: true -}).listen(3000, '0.0.0.0', (err, result) => { - if (err) { - console.log(err); - } - - console.log('Listening at 0.0.0.0:3000'); -}) diff --git a/webpack.config.js b/webpack.config.js index c6403bc2..e7d44c7d 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -89,8 +89,8 @@ module.exports = { // on the global let jQuery "jquery": "jQuery", "SystemJS": "SystemJS", - "React": "React", - "ReactDOM": "ReactDOM" + "react": "React", + "react-dom": "ReactDOM" }, watchOptions: {