Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reorg functional test files #2324

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,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",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,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": "c8 -n src -r html cross-env npm run test-unit",
"test-with-coverage_lcov": "c8 -n src --reporter=lcov cross-env npm run test-unit",
"base-test-unit": "cross-env BABEL_DISABLE_CACHE=1 mocha --file test/unit/bootstrap.js --loader=babel-register-esm",
Expand Down
File renamed without changes.
File renamed without changes.
87 changes: 87 additions & 0 deletions test/functional/examples.js
Original file line number Diff line number Diff line change
@@ -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');
38 changes: 19 additions & 19 deletions test/hooks_functional.js → test/functional/hooks_functional.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,18 +112,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) {
Expand Down Expand Up @@ -162,18 +176,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) => {
Expand Down Expand Up @@ -254,7 +256,7 @@ export const 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,
Expand All @@ -264,7 +266,7 @@ export const 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
}
Expand All @@ -276,5 +278,3 @@ export const mochaHooks = {

global.loadExample = loadExample;
global.waitUntilItownsIsIdle = waitUntilItownsIsIdle;


File renamed without changes.
2 changes: 2 additions & 0 deletions test/functional/others.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
require('./others/CameraUtils');
require('./others/GlobeControls');
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading