From 306d4e94be81e6b58fd816f66657725d98f9f985 Mon Sep 17 00:00:00 2001 From: Angelika Kinas Date: Mon, 20 Nov 2023 13:20:44 +0100 Subject: [PATCH 1/9] Fix(DH): Center bbox extent with different projection --- .../geo-table-view.component.ts | 6 +- .../lib/map-context/map-context.service.ts | 4 +- .../lib/utils/map-utils-wms.service.spec.ts | 34 ++- .../src/lib/utils/map-utils-wms.service.ts | 28 ++- .../map/src/lib/utils/map-utils.service.ts | 4 +- package-lock.json | 207 +++++++----------- package.json | 3 +- 7 files changed, 142 insertions(+), 144 deletions(-) diff --git a/libs/feature/dataviz/src/lib/geo-table-view/geo-table-view.component.ts b/libs/feature/dataviz/src/lib/geo-table-view/geo-table-view.component.ts index 03784eec33..77665bfd89 100644 --- a/libs/feature/dataviz/src/lib/geo-table-view/geo-table-view.component.ts +++ b/libs/feature/dataviz/src/lib/geo-table-view/geo-table-view.component.ts @@ -44,8 +44,8 @@ export class GeoTableViewComponent implements OnInit, AfterViewInit, OnDestroy { private map: Map private view: View - private vectorLayer: VectorLayer> - private vectorSource: VectorSource + private vectorLayer: VectorLayer>> + private vectorSource: VectorSource> private features: Feature[] tableData: TableItemModel[] @@ -76,7 +76,7 @@ export class GeoTableViewComponent implements OnInit, AfterViewInit, OnDestroy { const map = (this.map = this.manager.map) this.view = map.getView() this.vectorLayer = this.manager.map.getLayers().item(1) as VectorLayer< - VectorSource + VectorSource> > this.vectorLayer.setStyle(this.styleFn.bind(this)) this.vectorSource = this.vectorLayer.getSource() diff --git a/libs/feature/map/src/lib/map-context/map-context.service.ts b/libs/feature/map/src/lib/map-context/map-context.service.ts index 57cc12c6e6..b717585757 100644 --- a/libs/feature/map/src/lib/map-context/map-context.service.ts +++ b/libs/feature/map/src/lib/map-context/map-context.service.ts @@ -23,6 +23,8 @@ import { FeatureCollection } from 'geojson' import { fromLonLat } from 'ol/proj' import WMTS from 'ol/source/WMTS' import { removeSearchParams } from '@geonetwork-ui/util/shared' +import { Geometry } from 'ol/geom' +import Feature from 'ol/Feature' export const DEFAULT_BASELAYER_CONTEXT: MapContextLayerXyzModel = { type: MapContextLayerTypeEnum.XYZ, @@ -136,7 +138,7 @@ export class MapContextService { } const features = this.mapUtils.readFeatureCollection( geojson as FeatureCollection - ) + ) as Feature[] return new VectorLayer({ source: new VectorSource({ features, diff --git a/libs/feature/map/src/lib/utils/map-utils-wms.service.spec.ts b/libs/feature/map/src/lib/utils/map-utils-wms.service.spec.ts index 335b42880c..7ab53a94a2 100644 --- a/libs/feature/map/src/lib/utils/map-utils-wms.service.spec.ts +++ b/libs/feature/map/src/lib/utils/map-utils-wms.service.spec.ts @@ -2,6 +2,7 @@ import { TestBed } from '@angular/core/testing' import { readFirst } from '@nx/angular/testing' import { MapUtilsWMSService } from './map-utils-wms.service' +import { fromEPSGCode } from 'ol/proj/proj4' jest.mock('@camptocamp/ogc-client', () => ({ WmsEndpoint: class { @@ -22,6 +23,24 @@ jest.mock('@camptocamp/ogc-client', () => ({ }, })) +jest.mock('ol/proj/proj4', () => { + const fromEPSGCodeMock = jest.fn() + const registerMock = jest.fn() + return { + fromEPSGCode: fromEPSGCodeMock, + register: registerMock, + } +}) + +jest.mock('ol/proj', () => { + const extent = [1, 2, 3, 4] + const transformExtentMock = jest.fn().mockReturnValue(extent) + + return { + transformExtent: transformExtentMock, + } +}) + describe('MapUtilsWMSService', () => { let service: MapUtilsWMSService @@ -80,8 +99,8 @@ describe('MapUtilsWMSService', () => { } }) it('returns CRS:84 bbox', async () => { - const extent = service.getLonLatBBox(wmsLayerFull) - expect(extent).toEqual(['2.3', '50.6', '2.8', '50.9']) + const extent = await service.getLonLatBBox(wmsLayerFull) + expect(extent).toStrictEqual(['2.3', '50.6', '2.8', '50.9']) }) }) describe('bbox in EPSG:4326', () => { @@ -94,8 +113,8 @@ describe('MapUtilsWMSService', () => { } }) it('returns EPSG:4326 bbox', async () => { - const extent = service.getLonLatBBox(wmsLayerFull) - expect(extent).toEqual(['1', '2.6', '3.3', '4.2']) + const extent = await service.getLonLatBBox(wmsLayerFull) + expect(extent).toStrictEqual(['1', '2.6', '3.3', '4.2']) }) }) describe('no lon lat bbox', () => { @@ -106,9 +125,10 @@ describe('MapUtilsWMSService', () => { }, } }) - it('returns EPSG:4326 bbox', async () => { - const extent = service.getLonLatBBox(wmsLayerFull) - expect(extent).toBeUndefined() + it('transforms to EPSG:4326 bbox', async () => { + const extent = await service.getLonLatBBox(wmsLayerFull) + expect(fromEPSGCode).toHaveBeenCalled() + expect(extent).toStrictEqual([1, 2, 3, 4]) }) }) }) diff --git a/libs/feature/map/src/lib/utils/map-utils-wms.service.ts b/libs/feature/map/src/lib/utils/map-utils-wms.service.ts index 8b6d11d4d1..3f2782ee7b 100644 --- a/libs/feature/map/src/lib/utils/map-utils-wms.service.ts +++ b/libs/feature/map/src/lib/utils/map-utils-wms.service.ts @@ -3,8 +3,12 @@ import { WmsEndpoint, WmsLayerFull } from '@camptocamp/ogc-client' import { MapContextLayerWmsModel } from '../map-context/map-context.model' import { ProxyService } from '@geonetwork-ui/util/shared' import { from, Observable } from 'rxjs' -import { map } from 'rxjs/operators' +import { map, switchMap } from 'rxjs/operators' import { LONLAT_CRS_CODES } from './projections' +import { fromEPSGCode, register } from 'ol/proj/proj4' +import { Extent } from 'ol/extent' +import proj4 from 'proj4/dist/proj4' +import { transformExtent } from 'ol/proj' @Injectable({ providedIn: 'root', @@ -24,17 +28,35 @@ export class MapUtilsWMSService { getLayerLonLatBBox(layer: MapContextLayerWmsModel) { return this.getLayerFull(layer).pipe( - map((wmsLayerFull) => this.getLonLatBBox(wmsLayerFull)) + switchMap((wmsLayerFull) => from(this.getLonLatBBox(wmsLayerFull))) ) } - getLonLatBBox(wmsLayerFull: WmsLayerFull) { + async getProjFromEPSG(EPSGCode) { + return fromEPSGCode(EPSGCode) + } + + async getLonLatBBox(wmsLayerFull: WmsLayerFull): Promise { const { boundingBoxes } = wmsLayerFull const lonLatCRS = Object.keys(boundingBoxes)?.find((crs) => LONLAT_CRS_CODES.includes(crs) ) if (lonLatCRS) { return boundingBoxes[lonLatCRS] + } else { + const availableEPSGCode = Object.keys(boundingBoxes)[0] + register(proj4) + const proj = await this.getProjFromEPSG(availableEPSGCode) + proj4.defs(availableEPSGCode, proj) + + const bboxWithFiniteNumbers = [ + parseFloat(boundingBoxes[availableEPSGCode][0]), + parseFloat(boundingBoxes[availableEPSGCode][1]), + parseFloat(boundingBoxes[availableEPSGCode][2]), + parseFloat(boundingBoxes[availableEPSGCode][3]), + ] + const extent = transformExtent(bboxWithFiniteNumbers, proj, 'EPSG:4326') + return extent } } } diff --git a/libs/feature/map/src/lib/utils/map-utils.service.ts b/libs/feature/map/src/lib/utils/map-utils.service.ts index c90e6be388..03871ce085 100644 --- a/libs/feature/map/src/lib/utils/map-utils.service.ts +++ b/libs/feature/map/src/lib/utils/map-utils.service.ts @@ -2,7 +2,7 @@ import { HttpClient } from '@angular/common/http' import { Injectable } from '@angular/core' import type { FeatureCollection } from 'geojson' import { extend, Extent, isEmpty } from 'ol/extent' -import OlFeature from 'ol/Feature' +import OlFeature, { FeatureLike } from 'ol/Feature' import GeoJSON from 'ol/format/GeoJSON' import { Geometry } from 'ol/geom' import Layer from 'ol/layer/Layer' @@ -50,7 +50,7 @@ export class MapUtilsService { featureCollection: FeatureCollection, featureProjection = FEATURE_PROJECTION, dataProjection = DATA_PROJECTION - ): OlFeature[] => { + ): FeatureLike[] => { const olFeatures = new GeoJSON().readFeatures(featureCollection, { featureProjection, dataProjection, diff --git a/package-lock.json b/package-lock.json index 159b377f88..3e61a6ff14 100644 --- a/package-lock.json +++ b/package-lock.json @@ -55,9 +55,10 @@ "ngx-chips": "3.0.0", "ngx-dropzone": "^3.0.0", "ngx-translate-messageformat-compiler": "~6.5.0", - "ol": "^6.6.1", + "ol": "^8.2.0", "papaparse": "^5.3.1", "pg": "^8.9.0", + "proj4": "^2.9.2", "reflect-metadata": "^0.1.13", "rxjs": "^7.0.0", "tippy.js": "^6.3.7", @@ -5082,45 +5083,6 @@ "node": ">=8" } }, - "node_modules/@mapbox/jsonlint-lines-primitives": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/@mapbox/jsonlint-lines-primitives/-/jsonlint-lines-primitives-2.0.2.tgz", - "integrity": "sha512-rY0o9A5ECsTQRVhv7tL/OyDpGAoUB4tTvLiW1DSzQGq4bvTPhNw1VpSNjDJc5GFZ2XuyOtSWSVN05qOtcD71qQ==", - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/@mapbox/mapbox-gl-style-spec": { - "version": "13.28.0", - "resolved": "https://registry.npmjs.org/@mapbox/mapbox-gl-style-spec/-/mapbox-gl-style-spec-13.28.0.tgz", - "integrity": "sha512-B8xM7Fp1nh5kejfIl4SWeY0gtIeewbuRencqO3cJDrCHZpaPg7uY+V8abuR+esMeuOjRl5cLhVTP40v+1ywxbg==", - "dependencies": { - "@mapbox/jsonlint-lines-primitives": "~2.0.2", - "@mapbox/point-geometry": "^0.1.0", - "@mapbox/unitbezier": "^0.0.0", - "csscolorparser": "~1.0.2", - "json-stringify-pretty-compact": "^2.0.0", - "minimist": "^1.2.6", - "rw": "^1.3.3", - "sort-object": "^0.3.2" - }, - "bin": { - "gl-style-composite": "bin/gl-style-composite.js", - "gl-style-format": "bin/gl-style-format.js", - "gl-style-migrate": "bin/gl-style-migrate.js", - "gl-style-validate": "bin/gl-style-validate.js" - } - }, - "node_modules/@mapbox/point-geometry": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/@mapbox/point-geometry/-/point-geometry-0.1.0.tgz", - "integrity": "sha512-6j56HdLTwWGO0fJPlrZtdU/B13q8Uwmo18Ck2GnGgN9PCFyKTZ3UbXeEdRFh18i9XQ92eH2VdtpJHpBD3aripQ==" - }, - "node_modules/@mapbox/unitbezier": { - "version": "0.0.0", - "resolved": "https://registry.npmjs.org/@mapbox/unitbezier/-/unitbezier-0.0.0.tgz", - "integrity": "sha512-HPnRdYO0WjFjRTSwO3frz1wKaU649OBFPX3Zo/2WZvuRi6zMiRGui8SnPQiQABgqCf8YikDe5t3HViTVw1WUzA==" - }, "node_modules/@material/animation": { "version": "15.0.0-canary.90291f2e2.0", "resolved": "https://registry.npmjs.org/@material/animation/-/animation-15.0.0-canary.90291f2e2.0.tgz", @@ -8255,9 +8217,9 @@ } }, "node_modules/@petamoriken/float16": { - "version": "3.8.2", - "resolved": "https://registry.npmjs.org/@petamoriken/float16/-/float16-3.8.2.tgz", - "integrity": "sha512-TrVOB6T9kIrmGCp+mUIej7VJgQbB5MRWEj1ZksfR7hPSyc338xHxLO50spgpGBlbmk8D3kWOGnCHDfnaPV+Sng==" + "version": "3.8.4", + "resolved": "https://registry.npmjs.org/@petamoriken/float16/-/float16-3.8.4.tgz", + "integrity": "sha512-kB+NJ5Br56ZhElKsf0pM7/PQfrDdDVMRz8f0JM6eVOGE+L89z9hwcst9QvWBBnazzuqGTGtPsJNZoQ1JdNiGSQ==" }, "node_modules/@phenomnomnominal/tsquery": { "version": "5.0.1", @@ -15619,6 +15581,28 @@ "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" }, + "node_modules/color-parse": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/color-parse/-/color-parse-2.0.0.tgz", + "integrity": "sha512-g2Z+QnWsdHLppAbrpcFWo629kLOnOPtpxYV69GCqm92gqSgyXbzlfyN3MXs0412fPBkFmiuS+rXposgBgBa6Kg==", + "dependencies": { + "color-name": "^1.0.0" + } + }, + "node_modules/color-rgba": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/color-rgba/-/color-rgba-3.0.0.tgz", + "integrity": "sha512-PPwZYkEY3M2THEHHV6Y95sGUie77S7X8v+h1r6LSAPF3/LL2xJ8duUXSrkic31Nzc4odPwHgUbiX/XuTYzQHQg==", + "dependencies": { + "color-parse": "^2.0.0", + "color-space": "^2.0.0" + } + }, + "node_modules/color-space": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-space/-/color-space-2.0.1.tgz", + "integrity": "sha512-nKqUYlo0vZATVOFHY810BSYjmCARrG7e5R3UE3CQlyjJTvv5kSSmPG1kzm/oDyyqjehM+lW1RnEt9It9GNa5JA==" + }, "node_modules/color-support": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/color-support/-/color-support-1.1.3.tgz", @@ -16410,11 +16394,6 @@ "url": "https://github.com/sponsors/fb55" } }, - "node_modules/csscolorparser": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/csscolorparser/-/csscolorparser-1.0.3.tgz", - "integrity": "sha512-umPSgYwZkdFoUrH5hIq5kf0wPSXiro51nPw0j2K/c83KflkPSTBGMz6NJvMB+07VlL0y7VPo6QJcDjcgKTTm3w==" - }, "node_modules/cssesc": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/cssesc/-/cssesc-3.0.0.tgz", @@ -17367,6 +17346,11 @@ "resolved": "https://registry.npmjs.org/duration-relativetimeformat/-/duration-relativetimeformat-2.0.4.tgz", "integrity": "sha512-EW2eKxRm0IhOmJiBDx50PV5MKVhHGGLqQ4fLbinItdYmoZcVDFRqomCbYfZFEbBXiQdvaRUU+/E2CMlvz5/u5A==" }, + "node_modules/earcut": { + "version": "2.2.4", + "resolved": "https://registry.npmjs.org/earcut/-/earcut-2.2.4.tgz", + "integrity": "sha512-/pjZsA1b4RPHbeWZQn66SWS8nZZWLQQ23oE3Eam7aroEFGEvwKAsJfZ9ytiEMycfzXWpca4FA9QIOehf7PocBQ==" + }, "node_modules/eastasianwidth": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/eastasianwidth/-/eastasianwidth-0.2.0.tgz", @@ -19208,44 +19192,28 @@ } }, "node_modules/geotiff": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/geotiff/-/geotiff-2.0.4.tgz", - "integrity": "sha512-aG8h9bJccGusioPsEWsEqx8qdXpZN71A20WCvRKGxcnHSOWLKmC5ZmsAmodfxb9TRQvs+89KikGuPzxchhA+Uw==", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/geotiff/-/geotiff-2.1.0.tgz", + "integrity": "sha512-B/iFJuFfRpmPHXf8aIRPRgUWwfaNb6dlsynkM8SWeHAPu7CpyvfqEa43KlBt7xxq5OTVysQacFHxhCn3SZhRKQ==", "dependencies": { "@petamoriken/float16": "^3.4.7", "lerc": "^3.0.0", - "lru-cache": "^6.0.0", "pako": "^2.0.4", "parse-headers": "^2.0.2", + "quick-lru": "^6.1.1", "web-worker": "^1.2.0", - "xml-utils": "^1.0.2" + "xml-utils": "^1.0.2", + "zstddec": "^0.1.0" }, "engines": { - "browsers": "defaults", "node": ">=10.19" } }, - "node_modules/geotiff/node_modules/lru-cache": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", - "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", - "dependencies": { - "yallist": "^4.0.0" - }, - "engines": { - "node": ">=10" - } - }, "node_modules/geotiff/node_modules/pako": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/pako/-/pako-2.1.0.tgz", "integrity": "sha512-w+eufiZ1WuJYgPXbV/PO3NCMEc3xqylkKHzp8bxp1uW4qaSNQUkwmLLEc3kKsfz8lpV1F8Ht3U1Cm+9Srog2ug==" }, - "node_modules/geotiff/node_modules/yallist": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", - "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" - }, "node_modules/get-caller-file": { "version": "2.0.5", "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", @@ -23066,11 +23034,6 @@ "resolved": "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz", "integrity": "sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw==" }, - "node_modules/json-stringify-pretty-compact": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/json-stringify-pretty-compact/-/json-stringify-pretty-compact-2.0.0.tgz", - "integrity": "sha512-WRitRfs6BGq4q8gTgOy4ek7iPFXjbra0H3PmDLKm2xnZ+Gh1HUhiKGgCZkSPNULlP7mvfu6FV/mOLhCarspADQ==" - }, "node_modules/json-stringify-safe": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", @@ -23785,11 +23748,6 @@ "integrity": "sha512-0aF7ZmVon1igznGI4VS30yugpduQW3y3GkcgGJOp7d8x8QrizhigUxjI/m2UojsXXto+jLAH3KSz+xOJTiORjg==", "dev": true }, - "node_modules/mapbox-to-css-font": { - "version": "2.4.2", - "resolved": "https://registry.npmjs.org/mapbox-to-css-font/-/mapbox-to-css-font-2.4.2.tgz", - "integrity": "sha512-f+NBjJJY4T3dHtlEz1wCG7YFlkODEjFIYlxDdLIDMNpkSksqTt+l/d4rjuwItxuzkuMFvPyrjzV2lxRM4ePcIA==" - }, "node_modules/mark.js": { "version": "8.11.1", "resolved": "https://registry.npmjs.org/mark.js/-/mark.js-8.11.1.tgz", @@ -23890,6 +23848,11 @@ "node": ">= 0.6" } }, + "node_modules/mgrs": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/mgrs/-/mgrs-1.0.0.tgz", + "integrity": "sha512-awNbTOqCxK1DBGjalK3xqWIstBZgN6fxsMSiXLs9/spqWkF2pAhb2rrYCFSsr1/tT7PhcDGjZndG8SWYn0byYA==" + }, "node_modules/micromatch": { "version": "4.0.5", "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.5.tgz", @@ -25768,12 +25731,14 @@ "integrity": "sha512-PX1wu0AmAdPqOL1mWhqmlOd8kOIZQwGZw6rh7uby9fTc5lhaOWFLX3I6R1hrF9k3zUY40e6igsLGkDXK92LJNg==" }, "node_modules/ol": { - "version": "6.15.1", - "resolved": "https://registry.npmjs.org/ol/-/ol-6.15.1.tgz", - "integrity": "sha512-ZG2CKTpJ8Q+tPywYysVwPk+yevwJzlbwjRKhoCvd7kLVWMbfBl1O/+Kg/yrZZrhG9FNXbFH4GeOZ5yVRqo3P4w==", + "version": "8.2.0", + "resolved": "https://registry.npmjs.org/ol/-/ol-8.2.0.tgz", + "integrity": "sha512-/m1ddd7Jsp4Kbg+l7+ozR5aKHAZNQOBAoNZ5pM9Jvh4Etkf0WGkXr9qXd7PnhmwiC1Hnc2Toz9XjCzBBvexfXw==", "dependencies": { - "geotiff": "2.0.4", - "ol-mapbox-style": "^8.0.5", + "color-rgba": "^3.0.0", + "color-space": "^2.0.1", + "earcut": "^2.2.3", + "geotiff": "^2.0.7", "pbf": "3.2.1", "rbush": "^3.0.1" }, @@ -25782,15 +25747,6 @@ "url": "https://opencollective.com/openlayers" } }, - "node_modules/ol-mapbox-style": { - "version": "8.2.1", - "resolved": "https://registry.npmjs.org/ol-mapbox-style/-/ol-mapbox-style-8.2.1.tgz", - "integrity": "sha512-3kBBuZC627vDL8vnUdfVbCbfkhkcZj2kXPHQcuLhC4JJEA+XkEVEtEde8x8+AZctRbHwBkSiubTPaRukgLxIRw==", - "dependencies": { - "@mapbox/mapbox-gl-style-spec": "^13.23.1", - "mapbox-to-css-font": "^2.4.1" - } - }, "node_modules/on-finished": { "version": "2.4.1", "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.1.tgz", @@ -27352,6 +27308,15 @@ "node": ">=0.4.0" } }, + "node_modules/proj4": { + "version": "2.9.2", + "resolved": "https://registry.npmjs.org/proj4/-/proj4-2.9.2.tgz", + "integrity": "sha512-bdyfNmtlWjQN/rHEHEiqFvpTUHhuzDaeQ6Uu1G4sPGqk+Xkxae6ahh865fClJokSGPBmlDOQWWaO6465TCfv5Q==", + "dependencies": { + "mgrs": "1.0.0", + "wkt-parser": "^1.3.3" + } + }, "node_modules/promise-inflight": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/promise-inflight/-/promise-inflight-1.0.1.tgz", @@ -27643,6 +27608,17 @@ } ] }, + "node_modules/quick-lru": { + "version": "6.1.2", + "resolved": "https://registry.npmjs.org/quick-lru/-/quick-lru-6.1.2.tgz", + "integrity": "sha512-AAFUA5O1d83pIHEhJwWCq/RQcRukCkn/NSm2QsTEMle5f2hP0ChI2+3Xb051PZCkLryI/Ir1MVKviT2FIloaTQ==", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/quickselect": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/quickselect/-/quickselect-2.0.0.tgz", @@ -28572,11 +28548,6 @@ "queue-microtask": "^1.2.2" } }, - "node_modules/rw": { - "version": "1.3.3", - "resolved": "https://registry.npmjs.org/rw/-/rw-1.3.3.tgz", - "integrity": "sha512-PdhdWy89SiZogBLaw42zdeqtRJ//zFd2PgQavcICDUgJT5oW10QCRKbJ6bg4r0/UY2M6BWd5tkxuGFRvCkgfHQ==" - }, "node_modules/rxjs": { "version": "7.8.1", "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-7.8.1.tgz", @@ -29143,34 +29114,6 @@ "node": ">= 10" } }, - "node_modules/sort-asc": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/sort-asc/-/sort-asc-0.1.0.tgz", - "integrity": "sha512-jBgdDd+rQ+HkZF2/OHCmace5dvpos/aWQpcxuyRs9QUbPRnkEJmYVo81PIGpjIdpOcsnJ4rGjStfDHsbn+UVyw==", - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/sort-desc": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/sort-desc/-/sort-desc-0.1.1.tgz", - "integrity": "sha512-jfZacW5SKOP97BF5rX5kQfJmRVZP5/adDUTY8fCSPvNcXDVpUEe2pr/iKGlcyZzchRJZrswnp68fgk3qBXgkJw==", - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/sort-object": { - "version": "0.3.2", - "resolved": "https://registry.npmjs.org/sort-object/-/sort-object-0.3.2.tgz", - "integrity": "sha512-aAQiEdqFTTdsvUFxXm3umdo04J7MRljoVGbBlkH7BgNsMvVNAJyGj7C/wV1A8wHWAJj/YikeZbfuCKqhggNWGA==", - "dependencies": { - "sort-asc": "^0.1.0", - "sort-desc": "^0.1.1" - }, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/source-map": { "version": "0.7.4", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.7.4.tgz", @@ -32989,6 +32932,11 @@ "resolved": "https://registry.npmjs.org/wildcard/-/wildcard-2.0.1.tgz", "integrity": "sha512-CC1bOL87PIWSBhDcTrdeLo6eGT7mCFtrg0uIJtqJUFyK+eJnzl8A1niH56uu7KMa5XFrtiV+AQuHO3n7DsHnLQ==" }, + "node_modules/wkt-parser": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/wkt-parser/-/wkt-parser-1.3.3.tgz", + "integrity": "sha512-ZnV3yH8/k58ZPACOXeiHaMuXIiaTk1t0hSUVisbO0t4RjA5wPpUytcxeyiN2h+LZRrmuHIh/1UlrR9e7DHDvTw==" + }, "node_modules/wmf": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/wmf/-/wmf-1.0.2.tgz", @@ -33359,6 +33307,11 @@ "dependencies": { "tslib": "^2.3.0" } + }, + "node_modules/zstddec": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/zstddec/-/zstddec-0.1.0.tgz", + "integrity": "sha512-w2NTI8+3l3eeltKAdK8QpiLo/flRAr2p8AGeakfMZOXBxOg9HIu4LVDxBi81sYgVhFhdJjv1OrB5ssI8uFPoLg==" } } } diff --git a/package.json b/package.json index 72a8dc2c56..64f6854ad9 100644 --- a/package.json +++ b/package.json @@ -90,9 +90,10 @@ "ngx-chips": "3.0.0", "ngx-dropzone": "^3.0.0", "ngx-translate-messageformat-compiler": "~6.5.0", - "ol": "^6.6.1", + "ol": "^8.2.0", "papaparse": "^5.3.1", "pg": "^8.9.0", + "proj4": "^2.9.2", "reflect-metadata": "^0.1.13", "rxjs": "^7.0.0", "tippy.js": "^6.3.7", From 9ce41a9de05baf9dbfc642d1fd5a19906937445b Mon Sep 17 00:00:00 2001 From: Angelika Kinas Date: Tue, 21 Nov 2023 14:35:21 +0100 Subject: [PATCH 2/9] feat(DH): Fix failing tests related to ol update --- jest.preset.js | 2 +- .../geo-table-view.component.spec.ts | 12 ++++++++++-- .../lib/map-context/map-context.service.spec.ts | 12 +++++++++++- .../map/src/lib/utils/map-utils.service.spec.ts | 17 ++++++++++++++++- 4 files changed, 38 insertions(+), 5 deletions(-) diff --git a/jest.preset.js b/jest.preset.js index 197970e0f1..a7b8a3c70c 100644 --- a/jest.preset.js +++ b/jest.preset.js @@ -4,7 +4,7 @@ module.exports = { ...nxPreset, coverageReporters: ['text'], setupFiles: ['jest-canvas-mock'], - transformIgnorePatterns: ['node_modules/(?!(ol|@mapbox|.*.mjs$))'], + transformIgnorePatterns: ['node_modules/(?!(color-*|ol|@mapbox|.*.mjs$))'], transform: { '^.+\\.(ts|mjs|js|html)$': [ 'jest-preset-angular', diff --git a/libs/feature/dataviz/src/lib/geo-table-view/geo-table-view.component.spec.ts b/libs/feature/dataviz/src/lib/geo-table-view/geo-table-view.component.spec.ts index 43b07dfb0d..21686a2ff1 100644 --- a/libs/feature/dataviz/src/lib/geo-table-view/geo-table-view.component.spec.ts +++ b/libs/feature/dataviz/src/lib/geo-table-view/geo-table-view.component.spec.ts @@ -12,7 +12,7 @@ import { MapManagerService, } from '@geonetwork-ui/feature/map' import { FEATURE_COLLECTION_POINT_FIXTURE_4326 } from '@geonetwork-ui/common/fixtures' -import { Map } from 'ol' +import { Feature, Map } from 'ol' import GeoJSON from 'ol/format/GeoJSON' import TileLayer from 'ol/layer/Tile' import VectorLayer from 'ol/layer/Vector' @@ -21,6 +21,14 @@ import XYZ from 'ol/source/XYZ' import { Subject } from 'rxjs' import { GeoTableViewComponent } from './geo-table-view.component' +import { Geometry } from 'ol/geom' + +class ResizeObserverMock { + observe = jest.fn() + unobserve = jest.fn() +} + +;(window as any).ResizeObserver = ResizeObserverMock const vectorLayer = new VectorLayer({ source: new VectorSource({ @@ -31,7 +39,7 @@ const vectorLayer = new VectorLayer({ dataProjection: 'EPSG:4326', } ), - }), + }) as VectorSource>, }) const mapMock = new Map({ diff --git a/libs/feature/map/src/lib/map-context/map-context.service.spec.ts b/libs/feature/map/src/lib/map-context/map-context.service.spec.ts index 6923ed4f86..d0efddef4b 100644 --- a/libs/feature/map/src/lib/map-context/map-context.service.spec.ts +++ b/libs/feature/map/src/lib/map-context/map-context.service.spec.ts @@ -32,6 +32,14 @@ import { DEFAULT_VIEW, MapContextService, } from './map-context.service' +import Feature from 'ol/Feature' + +class ResizeObserverMock { + observe = jest.fn() + unobserve = jest.fn() +} + +;(window as any).ResizeObserver = ResizeObserverMock const mapStyleServiceMock = { createDefaultStyle: jest.fn(() => new Style()), @@ -319,7 +327,9 @@ describe('MapContextService', () => { }) it('add one WFS layer from config on top of baselayer', () => { const layerWFSSource = ( - map.getLayers().item(2) as VectorLayer> + map.getLayers().item(2) as VectorLayer< + VectorSource> + > ).getSource() expect(layerWFSSource).toBeInstanceOf(VectorSource) }) diff --git a/libs/feature/map/src/lib/utils/map-utils.service.spec.ts b/libs/feature/map/src/lib/utils/map-utils.service.spec.ts index 14b1014b0c..aa90637537 100644 --- a/libs/feature/map/src/lib/utils/map-utils.service.spec.ts +++ b/libs/feature/map/src/lib/utils/map-utils.service.spec.ts @@ -28,6 +28,21 @@ import { import { DatasetServiceDistribution } from '@geonetwork-ui/common/domain/model/record' import MapBrowserEvent from 'ol/MapBrowserEvent' +jest.mock('ol/proj/proj4', () => { + const fromEPSGCodeMock = jest.fn() + const registerMock = jest.fn() + return { + fromEPSGCode: fromEPSGCodeMock, + register: registerMock, + } +}) +class ResizeObserverMock { + observe = jest.fn() + unobserve = jest.fn() +} + +;(window as any).ResizeObserver = ResizeObserverMock + const wmsUtilsMock = { getLayerLonLatBBox: jest.fn(() => of([1.33, 48.81, 4.3, 51.1])), } @@ -146,7 +161,7 @@ describe('MapUtilsService', () => { }) it('returns true', () => { expect(url).toEqual( - 'url?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetFeatureInfo&FORMAT=image%2Fpng&TRANSPARENT=true&QUERY_LAYERS=layerName&LAYERS=layerName&INFO_FORMAT=application%2Fjson&I=50&J=50&CRS=EPSG%3A3857&STYLES=&WIDTH=101&HEIGHT=101&BBOX=-1697932.4932933417%2C4610319.813853541%2C1332067.5067066583%2C7640319.813853541' + 'url?QUERY_LAYERS=layerName&INFO_FORMAT=application%2Fjson&REQUEST=GetFeatureInfo&SERVICE=WMS&VERSION=1.3.0&FORMAT=image%2Fpng&STYLES=&TRANSPARENT=true&LAYERS=layerName&I=50&J=50&WIDTH=101&HEIGHT=101&CRS=EPSG%3A3857&BBOX=-1697932.4932933417%2C4610319.813853541%2C1332067.5067066583%2C7640319.813853541' ) }) }) From fd410ad6b54b3e3caaadd7956588a3c1a60a2684 Mon Sep 17 00:00:00 2001 From: Angelika Kinas Date: Tue, 21 Nov 2023 15:09:17 +0100 Subject: [PATCH 3/9] feat(DH): Typefix for ol update --- ...ata-import-validation-map-panel.component.ts | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/apps/datafeeder/src/app/presentation/components/data-import-validation-map-panel/data-import-validation-map-panel.component.ts b/apps/datafeeder/src/app/presentation/components/data-import-validation-map-panel/data-import-validation-map-panel.component.ts index bbda583a1d..b8be903946 100644 --- a/apps/datafeeder/src/app/presentation/components/data-import-validation-map-panel/data-import-validation-map-panel.component.ts +++ b/apps/datafeeder/src/app/presentation/components/data-import-validation-map-panel/data-import-validation-map-panel.component.ts @@ -10,19 +10,20 @@ import { ViewChild, } from '@angular/core' import { ThemeService } from '@geonetwork-ui/util/shared' -import type { Feature } from 'geojson' +import type { Feature as FeatureType } from 'geojson' import { asArray, asString } from 'ol/color' import { isEmpty } from 'ol/extent' import GeoJSON from 'ol/format/GeoJSON' import { Geometry } from 'ol/geom' import TileLayer from 'ol/layer/Tile' import VectorLayer from 'ol/layer/Vector' -import Map from 'ol/Map' +import { Map, Feature } from 'ol' import OSM from 'ol/source/OSM' import VectorSource from 'ol/source/Vector' import { Fill, RegularShape, Stroke, Style } from 'ol/style' import { StyleLike } from 'ol/style/Style' import View from 'ol/View' +import { FeatureLike } from 'ol/Feature' const DEFAULT_PRIMARY_COLOR = '#9a9a9a' const PADDING = 50 @@ -41,7 +42,7 @@ export class DataImportValidationMapPanelComponent @Input() headerLabel = '' @Input() footerLabel = '' @Input() footerList = [] - @Input() geoJson?: Feature + @Input() geoJson?: FeatureType @Input() footerValue = '' @Input() padding = [] @@ -50,8 +51,8 @@ export class DataImportValidationMapPanelComponent selectedValue: any private map: Map - private source: VectorSource - private vectorLayer: VectorLayer> + private source: VectorSource + private vectorLayer: VectorLayer>> private format: any = new GeoJSON({}) ngOnInit(): void { @@ -158,8 +159,8 @@ export class DataImportValidationMapPanelComponent ] } - private buildVectorLayer(): VectorLayer> { - this.source = new VectorSource({}) + private buildVectorLayer(): VectorLayer>> { + this.source = new VectorSource>({}) if (this.geoJson) { this.source.addFeatures( this.format.readFeatures(this.geoJson, { @@ -168,7 +169,7 @@ export class DataImportValidationMapPanelComponent ) } return new VectorLayer({ - source: this.source, + source: this.source as VectorSource>, style: this.getDefaultStyle(), }) } From 293815508548f62f168c330246296918f5606bc7 Mon Sep 17 00:00:00 2001 From: Angelika Kinas Date: Wed, 22 Nov 2023 08:41:27 +0100 Subject: [PATCH 4/9] feat(DH): Fix failing test --- .../lib/map-view/map-view.component.spec.ts | 39 ++++++++++--------- 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/libs/feature/record/src/lib/map-view/map-view.component.spec.ts b/libs/feature/record/src/lib/map-view/map-view.component.spec.ts index a056787d47..d8a495eda7 100644 --- a/libs/feature/record/src/lib/map-view/map-view.component.spec.ts +++ b/libs/feature/record/src/lib/map-view/map-view.component.spec.ts @@ -745,25 +745,28 @@ describe('MapViewComponent', () => { }) }) - const vectorLayer = new VectorLayer({ - source: new VectorSource({ - features: new GeoJSON().readFeatures( - FEATURE_COLLECTION_POINT_FIXTURE_4326, - { - featureProjection: 'EPSG:3857', - dataProjection: 'EPSG:4326', - } - ), - }), - }) - const selectionFeatures = [ - vectorLayer - .getSource() - .getFeatures() - .find((feature) => feature.getId() === 2), - ] - describe('feature info', () => { + let selectionFeatures + beforeEach(() => { + const vectorLayer = new VectorLayer({ + source: new VectorSource({ + features: new GeoJSON().readFeatures( + FEATURE_COLLECTION_POINT_FIXTURE_4326, + { + featureProjection: 'EPSG:3857', + dataProjection: 'EPSG:4326', + } + ), + }), + }) + selectionFeatures = [ + vectorLayer + .getSource() + .getFeatures() + .find((feature) => feature.getId() === 2), + ] + }) + it('creates selection style', () => { expect(component['selectionStyle']).toBeTruthy() }) From efa9686a2c8edd95588244674106f784c5d46627 Mon Sep 17 00:00:00 2001 From: Angelika Kinas Date: Tue, 28 Nov 2023 11:20:25 +0100 Subject: [PATCH 5/9] Fix(DH): Enhance test setup and imrove imports --- .../data-import-validation-map-panel.component.ts | 3 ++- .../geo-table-view/geo-table-view.component.spec.ts | 10 ++-------- libs/feature/dataviz/src/test-setup.ts | 7 +++++++ .../src/lib/map-context/map-context.service.spec.ts | 7 ------- .../feature/map/src/lib/utils/map-utils-wms.service.ts | 6 +----- .../map/src/lib/utils/map-utils.service.spec.ts | 6 ------ libs/feature/map/src/test-setup.ts | 7 +++++++ 7 files changed, 19 insertions(+), 27 deletions(-) diff --git a/apps/datafeeder/src/app/presentation/components/data-import-validation-map-panel/data-import-validation-map-panel.component.ts b/apps/datafeeder/src/app/presentation/components/data-import-validation-map-panel/data-import-validation-map-panel.component.ts index b8be903946..4dd3f60b7d 100644 --- a/apps/datafeeder/src/app/presentation/components/data-import-validation-map-panel/data-import-validation-map-panel.component.ts +++ b/apps/datafeeder/src/app/presentation/components/data-import-validation-map-panel/data-import-validation-map-panel.component.ts @@ -17,7 +17,8 @@ import GeoJSON from 'ol/format/GeoJSON' import { Geometry } from 'ol/geom' import TileLayer from 'ol/layer/Tile' import VectorLayer from 'ol/layer/Vector' -import { Map, Feature } from 'ol' +import Map from 'ol/Map' +import Feature from 'ol/Feature' import OSM from 'ol/source/OSM' import VectorSource from 'ol/source/Vector' import { Fill, RegularShape, Stroke, Style } from 'ol/style' diff --git a/libs/feature/dataviz/src/lib/geo-table-view/geo-table-view.component.spec.ts b/libs/feature/dataviz/src/lib/geo-table-view/geo-table-view.component.spec.ts index 21686a2ff1..ea5334ff02 100644 --- a/libs/feature/dataviz/src/lib/geo-table-view/geo-table-view.component.spec.ts +++ b/libs/feature/dataviz/src/lib/geo-table-view/geo-table-view.component.spec.ts @@ -12,7 +12,8 @@ import { MapManagerService, } from '@geonetwork-ui/feature/map' import { FEATURE_COLLECTION_POINT_FIXTURE_4326 } from '@geonetwork-ui/common/fixtures' -import { Feature, Map } from 'ol' +import Map from 'ol/Map' +import Feature from 'ol/Feature' import GeoJSON from 'ol/format/GeoJSON' import TileLayer from 'ol/layer/Tile' import VectorLayer from 'ol/layer/Vector' @@ -23,13 +24,6 @@ import { Subject } from 'rxjs' import { GeoTableViewComponent } from './geo-table-view.component' import { Geometry } from 'ol/geom' -class ResizeObserverMock { - observe = jest.fn() - unobserve = jest.fn() -} - -;(window as any).ResizeObserver = ResizeObserverMock - const vectorLayer = new VectorLayer({ source: new VectorSource({ features: new GeoJSON().readFeatures( diff --git a/libs/feature/dataviz/src/test-setup.ts b/libs/feature/dataviz/src/test-setup.ts index 70e41af1c8..19b403b6c7 100644 --- a/libs/feature/dataviz/src/test-setup.ts +++ b/libs/feature/dataviz/src/test-setup.ts @@ -13,3 +13,10 @@ getTestBed().initTestEnvironment( platformBrowserDynamicTesting(), { teardown: { destroyAfterEach: false } } ) + +class ResizeObserverMock { + observe = jest.fn() + unobserve = jest.fn() +} + +;(window as any).ResizeObserver = ResizeObserverMock diff --git a/libs/feature/map/src/lib/map-context/map-context.service.spec.ts b/libs/feature/map/src/lib/map-context/map-context.service.spec.ts index d0efddef4b..0bc5494d30 100644 --- a/libs/feature/map/src/lib/map-context/map-context.service.spec.ts +++ b/libs/feature/map/src/lib/map-context/map-context.service.spec.ts @@ -34,13 +34,6 @@ import { } from './map-context.service' import Feature from 'ol/Feature' -class ResizeObserverMock { - observe = jest.fn() - unobserve = jest.fn() -} - -;(window as any).ResizeObserver = ResizeObserverMock - const mapStyleServiceMock = { createDefaultStyle: jest.fn(() => new Style()), styles: { diff --git a/libs/feature/map/src/lib/utils/map-utils-wms.service.ts b/libs/feature/map/src/lib/utils/map-utils-wms.service.ts index 3f2782ee7b..1b03dc36e7 100644 --- a/libs/feature/map/src/lib/utils/map-utils-wms.service.ts +++ b/libs/feature/map/src/lib/utils/map-utils-wms.service.ts @@ -32,10 +32,6 @@ export class MapUtilsWMSService { ) } - async getProjFromEPSG(EPSGCode) { - return fromEPSGCode(EPSGCode) - } - async getLonLatBBox(wmsLayerFull: WmsLayerFull): Promise { const { boundingBoxes } = wmsLayerFull const lonLatCRS = Object.keys(boundingBoxes)?.find((crs) => @@ -46,7 +42,7 @@ export class MapUtilsWMSService { } else { const availableEPSGCode = Object.keys(boundingBoxes)[0] register(proj4) - const proj = await this.getProjFromEPSG(availableEPSGCode) + const proj = await fromEPSGCode(availableEPSGCode) proj4.defs(availableEPSGCode, proj) const bboxWithFiniteNumbers = [ diff --git a/libs/feature/map/src/lib/utils/map-utils.service.spec.ts b/libs/feature/map/src/lib/utils/map-utils.service.spec.ts index aa90637537..2dc0bf257a 100644 --- a/libs/feature/map/src/lib/utils/map-utils.service.spec.ts +++ b/libs/feature/map/src/lib/utils/map-utils.service.spec.ts @@ -36,12 +36,6 @@ jest.mock('ol/proj/proj4', () => { register: registerMock, } }) -class ResizeObserverMock { - observe = jest.fn() - unobserve = jest.fn() -} - -;(window as any).ResizeObserver = ResizeObserverMock const wmsUtilsMock = { getLayerLonLatBBox: jest.fn(() => of([1.33, 48.81, 4.3, 51.1])), diff --git a/libs/feature/map/src/test-setup.ts b/libs/feature/map/src/test-setup.ts index 70e41af1c8..19b403b6c7 100644 --- a/libs/feature/map/src/test-setup.ts +++ b/libs/feature/map/src/test-setup.ts @@ -13,3 +13,10 @@ getTestBed().initTestEnvironment( platformBrowserDynamicTesting(), { teardown: { destroyAfterEach: false } } ) + +class ResizeObserverMock { + observe = jest.fn() + unobserve = jest.fn() +} + +;(window as any).ResizeObserver = ResizeObserverMock From 5cccf8605c93a7fb7e1cac4f85e25e16e80d070b Mon Sep 17 00:00:00 2001 From: Angelika Kinas Date: Tue, 5 Dec 2023 15:50:23 +0100 Subject: [PATCH 6/9] fix(DH): Try to fix path in e2e test --- apps/datahub-e2e/src/e2e/datasetDetailPage.cy.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/datahub-e2e/src/e2e/datasetDetailPage.cy.ts b/apps/datahub-e2e/src/e2e/datasetDetailPage.cy.ts index 0a0c695e94..63bae40479 100644 --- a/apps/datahub-e2e/src/e2e/datasetDetailPage.cy.ts +++ b/apps/datahub-e2e/src/e2e/datasetDetailPage.cy.ts @@ -377,7 +377,7 @@ describe('dataset pages', () => { .find('gn-ui-download-item') .first() .click() - cy.exec('ls cypress/downloads').then((result) => { + cy.exec('ls cypress/downloads/').then((result) => { const fileList = result.stdout.split('\n') const isFileDownloaded = fileList[0] From ef678570e90c243d9e2548fd304ce67210a0fcbf Mon Sep 17 00:00:00 2001 From: Angelika Kinas Date: Tue, 5 Dec 2023 15:58:43 +0100 Subject: [PATCH 7/9] WIP: print path in ci --- apps/datahub-e2e/src/e2e/datasetDetailPage.cy.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/datahub-e2e/src/e2e/datasetDetailPage.cy.ts b/apps/datahub-e2e/src/e2e/datasetDetailPage.cy.ts index 63bae40479..e467b038f6 100644 --- a/apps/datahub-e2e/src/e2e/datasetDetailPage.cy.ts +++ b/apps/datahub-e2e/src/e2e/datasetDetailPage.cy.ts @@ -377,7 +377,7 @@ describe('dataset pages', () => { .find('gn-ui-download-item') .first() .click() - cy.exec('ls cypress/downloads/').then((result) => { + cy.exec('pwd').then((result) => { const fileList = result.stdout.split('\n') const isFileDownloaded = fileList[0] From 81444e4be0a0ccc7144b04d4796400d50708e7f7 Mon Sep 17 00:00:00 2001 From: Angelika Kinas Date: Wed, 6 Dec 2023 09:45:05 +0100 Subject: [PATCH 8/9] WIP: Undo changes to e2e test --- apps/datahub-e2e/src/e2e/datasetDetailPage.cy.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/datahub-e2e/src/e2e/datasetDetailPage.cy.ts b/apps/datahub-e2e/src/e2e/datasetDetailPage.cy.ts index e467b038f6..0a0c695e94 100644 --- a/apps/datahub-e2e/src/e2e/datasetDetailPage.cy.ts +++ b/apps/datahub-e2e/src/e2e/datasetDetailPage.cy.ts @@ -377,7 +377,7 @@ describe('dataset pages', () => { .find('gn-ui-download-item') .first() .click() - cy.exec('pwd').then((result) => { + cy.exec('ls cypress/downloads').then((result) => { const fileList = result.stdout.split('\n') const isFileDownloaded = fileList[0] From 320c8b0c3470b24380e7a0cbde3f08d7836f6d0e Mon Sep 17 00:00:00 2001 From: Camille Moinier Date: Thu, 7 Dec 2023 16:53:48 +0100 Subject: [PATCH 9/9] fix(e2e): fix e2e test --- apps/datahub-e2e/src/e2e/datasetDetailPage.cy.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/apps/datahub-e2e/src/e2e/datasetDetailPage.cy.ts b/apps/datahub-e2e/src/e2e/datasetDetailPage.cy.ts index 0a0c695e94..a2d823b853 100644 --- a/apps/datahub-e2e/src/e2e/datasetDetailPage.cy.ts +++ b/apps/datahub-e2e/src/e2e/datasetDetailPage.cy.ts @@ -373,15 +373,18 @@ describe('dataset pages', () => { }) }) it('downloads a file on click', () => { + cy.intercept( + 'GET', + 'https://www.geo2france.fr/geoserver/insee/ows?SERVICE=WFS&REQUEST=GetFeature&VERSION=2.0.0&TYPENAMES=insee%3Arectangles_200m_menage_erbm&OUTPUTFORMAT=csv' + ).as('downloadRequest') + cy.get('datahub-record-downloads') .find('gn-ui-download-item') .first() .click() - cy.exec('ls cypress/downloads').then((result) => { - const fileList = result.stdout.split('\n') - const isFileDownloaded = fileList[0] - expect(/\S/.test(isFileDownloaded)).to.be.true + cy.wait('@downloadRequest').then((interception) => { + expect(interception.response.statusCode).to.equal(200) }) }) it('displays the full list after clicking two times on one filter', () => {