From 51aae20e9a9895e1a785772ce2511fd1befc08d0 Mon Sep 17 00:00:00 2001 From: ftoromanoff Date: Thu, 31 Aug 2023 11:55:53 +0200 Subject: [PATCH] chore(functional-test): reorganization --- examples/config.json | 2 +- package.json | 2 +- test/functional/{ => 3dTiles}/3dtiles_25d.js | 0 .../functional/{ => 3dTiles}/3dtiles_basic.js | 0 .../{ => 3dTiles}/3dtiles_batch_table.js | 0 test/functional/{ => 3dTiles}/3dtiles_ion.js | 0 .../{ => 3dTiles}/3dtiles_pointcloud.js | 0 .../{ => effect}/effects_postprocessing.js | 0 test/functional/{ => effect}/effects_split.js | 0 .../functional/{ => effect}/effects_stereo.js | 0 test/functional/examples.js | 87 +++++++++++++++++++ .../source_file_geojson_raster.js | 0 .../{ => fileSource}/source_file_gpx_3d.js | 0 .../source_file_kml_raster.js | 0 .../source_file_kml_raster_usgs.js | 0 test/{ => functional}/hooks_functional.js | 46 +++++----- .../{ => misc}/misc_clamp_ground.js | 0 test/functional/{ => misc}/misc_collada.js | 0 .../{ => misc}/misc_colorlayer_visibility.js | 0 .../misc_georeferenced_images.js} | 0 test/functional/{ => misc}/misc_instancing.js | 0 test/functional/others.js | 2 + test/functional/{ => others}/CameraUtils.js | 0 test/functional/{ => others}/GlobeControls.js | 0 .../{ => pointCloud}/potree_25d_map.js | 0 .../{ => pointCloud}/potree_3d_map.js | 0 .../vector_tile_3d_mesh_mapbox.js | 0 .../vector_tile_raster_2d.js | 0 .../vector_tile_raster_3d.js | 0 test/functional/{ => view}/view_25d_map.js | 0 test/functional/{ => view}/view_2d_map.js | 0 test/functional/{ => view}/view_3d_map.js | 0 test/functional/{ => view}/view_multi_25d.js | 0 test/functional/{ => view}/view_multiglobe.js | 0 .../{ => wfsSource}/source_stream_wfs_25d.js | 0 .../{ => wfsSource}/source_stream_wfs_3d.js | 0 .../source_stream_wfs_raster.js | 0 .../{ => widget}/widgets_3dtiles_style.js | 0 38 files changed, 114 insertions(+), 25 deletions(-) rename test/functional/{ => 3dTiles}/3dtiles_25d.js (100%) rename test/functional/{ => 3dTiles}/3dtiles_basic.js (100%) rename test/functional/{ => 3dTiles}/3dtiles_batch_table.js (100%) rename test/functional/{ => 3dTiles}/3dtiles_ion.js (100%) rename test/functional/{ => 3dTiles}/3dtiles_pointcloud.js (100%) rename test/functional/{ => effect}/effects_postprocessing.js (100%) rename test/functional/{ => effect}/effects_split.js (100%) rename test/functional/{ => effect}/effects_stereo.js (100%) create mode 100644 test/functional/examples.js rename test/functional/{ => fileSource}/source_file_geojson_raster.js (100%) rename test/functional/{ => fileSource}/source_file_gpx_3d.js (100%) rename test/functional/{ => fileSource}/source_file_kml_raster.js (100%) rename test/functional/{ => fileSource}/source_file_kml_raster_usgs.js (100%) rename test/{ => functional}/hooks_functional.js (92%) rename test/functional/{ => misc}/misc_clamp_ground.js (100%) rename test/functional/{ => misc}/misc_collada.js (100%) rename test/functional/{ => misc}/misc_colorlayer_visibility.js (100%) rename test/functional/{oriented_images.js => misc/misc_georeferenced_images.js} (100%) rename test/functional/{ => misc}/misc_instancing.js (100%) create mode 100644 test/functional/others.js rename test/functional/{ => others}/CameraUtils.js (100%) rename test/functional/{ => others}/GlobeControls.js (100%) rename test/functional/{ => pointCloud}/potree_25d_map.js (100%) rename test/functional/{ => pointCloud}/potree_3d_map.js (100%) rename test/functional/{ => vectorTiles}/vector_tile_3d_mesh_mapbox.js (100%) rename test/functional/{ => vectorTiles}/vector_tile_raster_2d.js (100%) rename test/functional/{ => vectorTiles}/vector_tile_raster_3d.js (100%) rename test/functional/{ => view}/view_25d_map.js (100%) rename test/functional/{ => view}/view_2d_map.js (100%) rename test/functional/{ => view}/view_3d_map.js (100%) rename test/functional/{ => view}/view_multi_25d.js (100%) rename test/functional/{ => view}/view_multiglobe.js (100%) rename test/functional/{ => wfsSource}/source_stream_wfs_25d.js (100%) rename test/functional/{ => wfsSource}/source_stream_wfs_3d.js (100%) rename test/functional/{ => wfsSource}/source_stream_wfs_raster.js (100%) rename test/functional/{ => widget}/widgets_3dtiles_style.js (100%) diff --git a/examples/config.json b/examples/config.json index d1014d01dd..358d9d7306 100644 --- a/examples/config.json +++ b/examples/config.json @@ -51,7 +51,7 @@ "FileSource": { "source_file_geojson_raster": "GeoJSON to raster", - "source_file_geojson_raster_2": "USGS GeoJSON flux to raster (planar view)", + "source_file_geojson_raster_usgs": "USGS GeoJSON flux to raster (planar view)", "source_file_geojson_3d": "GeoJSON to 3D objects", "source_file_kml_raster": "KML to raster", "source_file_kml_raster_usgs": "USGS KML flux to raster", diff --git a/package.json b/package.json index 98721094d6..c19275bae6 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,7 @@ "test": "npm run lint -- --max-warnings=0 && npm run build && npm run test-with-coverage && npm run test-functional", "test-dev": "npm run lint -- --max-warnings=0 && npm run build-dev && npm run test-with-coverage && npm run test-functional", "test-unit": "npm run base-test-unit test/unit", - "test-functional": "mocha -t 100000 --require test/hooks_functional.js --recursive test/functional", + "test-functional": "mocha -t 100000 --require test/functional/hooks_functional.js test/functional", "test-with-coverage": "nyc -n src -r html cross-env npm run test-unit", "test-with-coverage_lcov": "nyc -n src --reporter=lcov cross-env npm run test-unit", "base-test-unit": "cross-env BABEL_DISABLE_CACHE=1 mocha --require @babel/register --file test/unit/bootstrap.js", diff --git a/test/functional/3dtiles_25d.js b/test/functional/3dTiles/3dtiles_25d.js similarity index 100% rename from test/functional/3dtiles_25d.js rename to test/functional/3dTiles/3dtiles_25d.js diff --git a/test/functional/3dtiles_basic.js b/test/functional/3dTiles/3dtiles_basic.js similarity index 100% rename from test/functional/3dtiles_basic.js rename to test/functional/3dTiles/3dtiles_basic.js diff --git a/test/functional/3dtiles_batch_table.js b/test/functional/3dTiles/3dtiles_batch_table.js similarity index 100% rename from test/functional/3dtiles_batch_table.js rename to test/functional/3dTiles/3dtiles_batch_table.js diff --git a/test/functional/3dtiles_ion.js b/test/functional/3dTiles/3dtiles_ion.js similarity index 100% rename from test/functional/3dtiles_ion.js rename to test/functional/3dTiles/3dtiles_ion.js diff --git a/test/functional/3dtiles_pointcloud.js b/test/functional/3dTiles/3dtiles_pointcloud.js similarity index 100% rename from test/functional/3dtiles_pointcloud.js rename to test/functional/3dTiles/3dtiles_pointcloud.js diff --git a/test/functional/effects_postprocessing.js b/test/functional/effect/effects_postprocessing.js similarity index 100% rename from test/functional/effects_postprocessing.js rename to test/functional/effect/effects_postprocessing.js diff --git a/test/functional/effects_split.js b/test/functional/effect/effects_split.js similarity index 100% rename from test/functional/effects_split.js rename to test/functional/effect/effects_split.js diff --git a/test/functional/effects_stereo.js b/test/functional/effect/effects_stereo.js similarity index 100% rename from test/functional/effects_stereo.js rename to test/functional/effect/effects_stereo.js diff --git a/test/functional/examples.js b/test/functional/examples.js new file mode 100644 index 0000000000..fc6fe317b9 --- /dev/null +++ b/test/functional/examples.js @@ -0,0 +1,87 @@ +/* View */ +require('./view/view_2d_map'); +require('./view/view_25d_map'); +require('./view/view_3d_map'); +require('./view/view_multiglobe'); +require('./view/view_multi_25d'); +// require('./view/view_immersive'); +// require('./view/view_3d_mns_map'); + +/* Geoid */ +// require('./geoid/geoid_geoidLayer'); + +/* 3d Tiles */ +require('./3dTiles/3dtiles_basic'); +require('./3dTiles/3dtiles_25d'); +require('./3dTiles/3dtiles_batch_table'); +require('./3dTiles/3dtiles_ion'); +require('./3dTiles/3dtiles_pointcloud'); + +/* Pointcloud */ +require('./pointCloud/potree_25d_map'); +require('./pointCloud/potree_3d_map'); +// require('./pointCloud/laz_dragndrop'); +// require('./pointCloud/entwine_simple_loader'); +// require('./pointCloud/entwine_3d_loader'); + +/* Vector tiles */ +require('./vectorTiles/vector_tile_raster_3d'); +require('./vectorTiles/vector_tile_raster_2d'); +// require('./vectorTiles/vector_tile_3d_mesh'); +require('./vectorTiles/vector_tile_3d_mesh_mapbox'); +// require('./vectorTiles/vector_tile_dragndrop'); + +/* WFS source */ +require('./wfsSource/source_stream_wfs_25d'); +require('./wfsSource/source_stream_wfs_3d'); +require('./wfsSource/source_stream_wfs_raster'); + +/* Specific source options */ +// require('./speSourceOptions/source_file_from_format'); +// require('./speSourceOptions/source_file_from_methods'); + +/* FileSource */ +require('./fileSource/source_file_geojson_raster'); +// require('./fileSource/source_file_geojson_raster_usgs'); +// require('./fileSource/source_file_geojson_3d'); +require('./fileSource/source_file_kml_raster'); +require('./fileSource/source_file_kml_raster_usgs'); +// require('./fileSource/source_file_gpx_raster'); +require('./fileSource/source_file_gpx_3d'); + +/* Customize FileSource */ +// require('./customFileSource/source_file_from_fetched_data'); +// require('./customFileSource/source_file_from_parsed_data'); +// require('./customFileSource/source_file_shapefile'); + +/* Effects */ +require('./effect/effects_postprocessing'); +require('./effect/effects_split'); +require('./effect/effects_stereo'); +// require('./effect/mars'); +// require('./effect/customColorLayerEffect'); + +/* Miscellaneous */ +require('./misc/misc_colorlayer_visibility'); +require('./misc/misc_collada'); +require('./misc/misc_clamp_ground'); +// require('./misc/misc_camera_animation'); +// require('./misc/misc_compare_25d_3d'); +require('./misc/misc_georeferenced_images'); +// require('./misc/misc_orthographic_camera'); +// require('./misc/misc_custom_controls'); +// require('./misc/misc_custom_label'); +// require('./misc/misc_camera_traveling'); +require('./misc/misc_instancing'); + +/* Widgets */ +// require('./widget/widgets_navigation'); +// require('./widget/widgets_minimap'); +// require('./widget/widgets_scale'); +// require('./widget/widgets_searchbar'); +require('./widget/widgets_3dtiles_style'); + +/* Plugins */ +// require('./plugin/plugins_drag_n_drop'); +// require('./plugin/plugins_pyramidal_tiff'); +// require('./plugin/plugins_vrt'); diff --git a/test/functional/source_file_geojson_raster.js b/test/functional/fileSource/source_file_geojson_raster.js similarity index 100% rename from test/functional/source_file_geojson_raster.js rename to test/functional/fileSource/source_file_geojson_raster.js diff --git a/test/functional/source_file_gpx_3d.js b/test/functional/fileSource/source_file_gpx_3d.js similarity index 100% rename from test/functional/source_file_gpx_3d.js rename to test/functional/fileSource/source_file_gpx_3d.js diff --git a/test/functional/source_file_kml_raster.js b/test/functional/fileSource/source_file_kml_raster.js similarity index 100% rename from test/functional/source_file_kml_raster.js rename to test/functional/fileSource/source_file_kml_raster.js diff --git a/test/functional/source_file_kml_raster_usgs.js b/test/functional/fileSource/source_file_kml_raster_usgs.js similarity index 100% rename from test/functional/source_file_kml_raster_usgs.js rename to test/functional/fileSource/source_file_kml_raster_usgs.js diff --git a/test/hooks_functional.js b/test/functional/hooks_functional.js similarity index 92% rename from test/hooks_functional.js rename to test/functional/hooks_functional.js index 9f144c5b8d..e55f8b830a 100644 --- a/test/hooks_functional.js +++ b/test/functional/hooks_functional.js @@ -79,10 +79,10 @@ function waitServerReady(port) { } const layersInitialization = async (forceTimeOut = false) => { - await page.waitForFunction(forceTimeOut => (view.mainLoop.scheduler.commandsWaitingExecutionCount() === 0 + await page.waitForFunction(timingOut => (view.mainLoop.scheduler.commandsWaitingExecutionCount() === 0 && view.mainLoop.renderingState === 0 && view.getLayers().every(layer => layer.ready) - && !forceTimeOut), { timeout: 50000 }, forceTimeOut); + && !timingOut), { timeout: 50000 }, forceTimeOut); }; const waitNextRender = async page => page.evaluate(() => new Promise((resolve) => { @@ -105,18 +105,32 @@ const waitNextRender = async page => page.evaluate(() => new Promise((resolve) = view.notifyChange(); })); +async function saveInitialPosition() { + global.initialPosition = await page.evaluate(() => { + let promise; + if (view.isGlobeView && view.controls) { + promise = Promise.resolve(itowns.CameraUtils.getTransformCameraLookingAtTarget(view, view.controls.camera)); + } else if (view.isPlanarView) { + // TODO: make the controls accessible from PlanarView before doing + // anything more here + promise = Promise.resolve(); + } + return promise; + }); +} + // Helper function: returns true if there are no errors on the page // and when all layers are ready and rendering has been done const loadExample = async (url, screenshotName) => { - url = `http://localhost:${itownsPort}/${url}`; + localUrl = `http://localhost:${itownsPort}/${url}`; const pageErrors = []; page.on('pageerror', (e) => { pageErrors.push(e); }); try { - await page.goto(url); + await page.goto(localUrl); } catch (e) { - throw new Error(`page ${url} couldn't load`, { cause: e }); + throw new Error(`page ${localUrl} couldn't load`, { cause: e }); } if (pageErrors.length > 0) { @@ -132,8 +146,8 @@ const loadExample = async (url, screenshotName) => { try { await layersInitialization(); - } catch (e) { - if (e instanceof Error && e.name === 'TimeoutError') { + } catch (err) { + if (err instanceof Error && err.name === 'TimeoutError') { console.warn(' *** Warning: layersInitialization timed out -> it got stopped ***'); await page.evaluate(() => { itowns.CameraUtils.stop(view, view.camera3D); @@ -160,18 +174,6 @@ const loadExample = async (url, screenshotName) => { return true; }; -async function saveInitialPosition() { - global.initialPosition = await page.evaluate(() => { - if (view.isGlobeView && view.controls) { - return Promise.resolve(itowns.CameraUtils.getTransformCameraLookingAtTarget(view, view.controls.camera)); - } else if (view.isPlanarView) { - // TODO: make the controls accessible from PlanarView before doing - // anything more here - return Promise.resolve(); - } - }); -} - // Use waitUntilItownsIsIdle to wait until itowns has finished all its work (= layer updates) const waitUntilItownsIsIdle = async (screenshotName) => { const result = await page.evaluate(() => new Promise((resolve) => { @@ -251,7 +253,7 @@ exports.mochaHooks = { // reset browser state instead of closing it afterEach: async () => { await page.evaluate((init) => { - if (view?.isGlobeView && view.controls) { + if (view && view.isGlobeView && view.controls) { // eslint-disable-next-line no-param-reassign init.coord = new itowns.Coordinates( init.coord.crs, @@ -261,7 +263,7 @@ exports.mochaHooks = { ); view.controls.lookAtCoordinate(init, false); view.notifyChange(); - } else if (view?.isPlanarView) { + } else if (view && view.isPlanarView) { // TODO: make the controls accessible from PlanarView before doing // anything more here } @@ -273,5 +275,3 @@ exports.mochaHooks = { global.loadExample = loadExample; global.waitUntilItownsIsIdle = waitUntilItownsIsIdle; - - diff --git a/test/functional/misc_clamp_ground.js b/test/functional/misc/misc_clamp_ground.js similarity index 100% rename from test/functional/misc_clamp_ground.js rename to test/functional/misc/misc_clamp_ground.js diff --git a/test/functional/misc_collada.js b/test/functional/misc/misc_collada.js similarity index 100% rename from test/functional/misc_collada.js rename to test/functional/misc/misc_collada.js diff --git a/test/functional/misc_colorlayer_visibility.js b/test/functional/misc/misc_colorlayer_visibility.js similarity index 100% rename from test/functional/misc_colorlayer_visibility.js rename to test/functional/misc/misc_colorlayer_visibility.js diff --git a/test/functional/oriented_images.js b/test/functional/misc/misc_georeferenced_images.js similarity index 100% rename from test/functional/oriented_images.js rename to test/functional/misc/misc_georeferenced_images.js diff --git a/test/functional/misc_instancing.js b/test/functional/misc/misc_instancing.js similarity index 100% rename from test/functional/misc_instancing.js rename to test/functional/misc/misc_instancing.js diff --git a/test/functional/others.js b/test/functional/others.js new file mode 100644 index 0000000000..3bcab3bdcd --- /dev/null +++ b/test/functional/others.js @@ -0,0 +1,2 @@ +require('./others/CameraUtils'); +require('./others/GlobeControls'); diff --git a/test/functional/CameraUtils.js b/test/functional/others/CameraUtils.js similarity index 100% rename from test/functional/CameraUtils.js rename to test/functional/others/CameraUtils.js diff --git a/test/functional/GlobeControls.js b/test/functional/others/GlobeControls.js similarity index 100% rename from test/functional/GlobeControls.js rename to test/functional/others/GlobeControls.js diff --git a/test/functional/potree_25d_map.js b/test/functional/pointCloud/potree_25d_map.js similarity index 100% rename from test/functional/potree_25d_map.js rename to test/functional/pointCloud/potree_25d_map.js diff --git a/test/functional/potree_3d_map.js b/test/functional/pointCloud/potree_3d_map.js similarity index 100% rename from test/functional/potree_3d_map.js rename to test/functional/pointCloud/potree_3d_map.js diff --git a/test/functional/vector_tile_3d_mesh_mapbox.js b/test/functional/vectorTiles/vector_tile_3d_mesh_mapbox.js similarity index 100% rename from test/functional/vector_tile_3d_mesh_mapbox.js rename to test/functional/vectorTiles/vector_tile_3d_mesh_mapbox.js diff --git a/test/functional/vector_tile_raster_2d.js b/test/functional/vectorTiles/vector_tile_raster_2d.js similarity index 100% rename from test/functional/vector_tile_raster_2d.js rename to test/functional/vectorTiles/vector_tile_raster_2d.js diff --git a/test/functional/vector_tile_raster_3d.js b/test/functional/vectorTiles/vector_tile_raster_3d.js similarity index 100% rename from test/functional/vector_tile_raster_3d.js rename to test/functional/vectorTiles/vector_tile_raster_3d.js diff --git a/test/functional/view_25d_map.js b/test/functional/view/view_25d_map.js similarity index 100% rename from test/functional/view_25d_map.js rename to test/functional/view/view_25d_map.js diff --git a/test/functional/view_2d_map.js b/test/functional/view/view_2d_map.js similarity index 100% rename from test/functional/view_2d_map.js rename to test/functional/view/view_2d_map.js diff --git a/test/functional/view_3d_map.js b/test/functional/view/view_3d_map.js similarity index 100% rename from test/functional/view_3d_map.js rename to test/functional/view/view_3d_map.js diff --git a/test/functional/view_multi_25d.js b/test/functional/view/view_multi_25d.js similarity index 100% rename from test/functional/view_multi_25d.js rename to test/functional/view/view_multi_25d.js diff --git a/test/functional/view_multiglobe.js b/test/functional/view/view_multiglobe.js similarity index 100% rename from test/functional/view_multiglobe.js rename to test/functional/view/view_multiglobe.js diff --git a/test/functional/source_stream_wfs_25d.js b/test/functional/wfsSource/source_stream_wfs_25d.js similarity index 100% rename from test/functional/source_stream_wfs_25d.js rename to test/functional/wfsSource/source_stream_wfs_25d.js diff --git a/test/functional/source_stream_wfs_3d.js b/test/functional/wfsSource/source_stream_wfs_3d.js similarity index 100% rename from test/functional/source_stream_wfs_3d.js rename to test/functional/wfsSource/source_stream_wfs_3d.js diff --git a/test/functional/source_stream_wfs_raster.js b/test/functional/wfsSource/source_stream_wfs_raster.js similarity index 100% rename from test/functional/source_stream_wfs_raster.js rename to test/functional/wfsSource/source_stream_wfs_raster.js diff --git a/test/functional/widgets_3dtiles_style.js b/test/functional/widget/widgets_3dtiles_style.js similarity index 100% rename from test/functional/widgets_3dtiles_style.js rename to test/functional/widget/widgets_3dtiles_style.js