From 789c707c83214a3be06af3a58e47b0e910b9dc49 Mon Sep 17 00:00:00 2001 From: Riccardo Beltrami Date: Tue, 21 May 2024 18:23:36 +0200 Subject: [PATCH] refresh layer after editing --- assets/src/modules/map.js | 5 + tests/end2end/playwright/singleWMS.spec.ts | 40 + .../qgis-projects/tests/single_wms_image.qgs | 3785 +++++++++-------- .../tests/single_wms_image.qgs.cfg | 32 +- 4 files changed, 1966 insertions(+), 1896 deletions(-) diff --git a/assets/src/modules/map.js b/assets/src/modules/map.js index 8cfff73c3f..b29e791793 100644 --- a/assets/src/modules/map.js +++ b/assets/src/modules/map.js @@ -978,6 +978,11 @@ export default class map extends olMap { * @returns {ImageLayer|undefined} The OpenLayers layer or undefined */ getLayerByName(name){ + // if the layer is included in the singleWMSLayer, return the single ImageLayer instance + if(this._statesSingleWMSLayers.get(name)){ + return this._singleImageWmsGroup.getLayersArray()[0] + } + return this.overlayLayers.find( layer => layer.get('name') === name ); diff --git a/tests/end2end/playwright/singleWMS.spec.ts b/tests/end2end/playwright/singleWMS.spec.ts index 1bc50f533b..80adf748f6 100644 --- a/tests/end2end/playwright/singleWMS.spec.ts +++ b/tests/end2end/playwright/singleWMS.spec.ts @@ -411,4 +411,44 @@ test.describe('Single WMS layer', () => { expect(switchBaseLayersReqPromiseresp?.status()).toBe(200) }) + + test('Edit a layer', async ({ page }) => { + const url = '/index.php/view/map/?repository=testsrepository&project=single_wms_image'; + await page.goto(url,{waitUntil:'networkidle'}); + + await page.locator('#button-edition').click(); + await page.locator('a#edition-draw').click(); + + await page.waitForTimeout(300); + + // edition id done on #map + await page.locator('#map').click({ + position: { + x: 532, + y: 293 + } + }); + + page.locator("#jforms_view_edition input#jforms_view_edition_title").fill("Test insert"); + + const reloadMapPromise = page.waitForRequest(request => + request.url().includes('GetMap') && + request.method() === 'GET' && + // check format + request.url().includes('FORMAT=image%2Fpng') && + // check service + request.url().includes('SERVICE=WMS') && + // check styles + request.url().includes('STYLES=default%2Cdefault%2Cdefault%2Cdefault%2Cdefault%2C') && + // check layers + request.url().includes('LAYERS=single_wms_baselayer%2Csingle_wms_lines%2Csingle_wms_points%2Csingle_wms_points_group%2Csingle_wms_lines_group%2CGroupAsLayer') + ); + + await page.locator("#jforms_view_edition #jforms_view_edition__submit_submit").click(); + const reloaded = await reloadMapPromise; + + const reloadReqPromise = await reloaded.response(); + expect(reloadReqPromise?.status()).toBe(200) + + }) }) diff --git a/tests/qgis-projects/tests/single_wms_image.qgs b/tests/qgis-projects/tests/single_wms_image.qgs index 776360bbc9..5fbbeafdc0 100644 --- a/tests/qgis-projects/tests/single_wms_image.qgs +++ b/tests/qgis-projects/tests/single_wms_image.qgs @@ -1,5 +1,5 @@ - + @@ -21,72 +21,72 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -105,22 +105,22 @@ single_wms_tiled_baselayer_18228037_1139_4478_ae3e_3161e331ba07 - + - - - - - - - - - + + + + + + + + + - + meters 430224.52479840919841081 @@ -147,65 +147,65 @@ - - - - + Annotations_c6664103_04b9_4abb_9927_30c878bca869 @@ -256,7 +256,7 @@ - + -20037508.34278924390673637 -20037508.34278924763202667 @@ -297,7 +297,7 @@ OpenStreetMap tiles OpenStreetMap is built by a community of mappers that contribute and maintain data about roads, trails, cafés, railway stations, and much more, all over the world. - + Base map and data from OpenStreetMap and OpenStreetMap Foundation (CC-BY-SA). © https://www.openstreetmap.org and contributors. @@ -318,7 +318,7 @@ - + wms @@ -335,97 +335,97 @@ 0 0 - + - + - + - + - + - + @@ -434,21 +434,21 @@ - + - + None @@ -460,13 +460,13 @@ - + resamplingFilter 0 - + 3.80298443326216784 43.56410038340207791 @@ -532,7 +532,7 @@ - + @@ -557,173 +557,173 @@ 1 0 - + - + - + - + - + - + - + - + - + - + - + @@ -734,62 +734,62 @@ 0 0 1 - - - - + + + + - + - + @@ -797,36 +797,36 @@ - + - - + - + - - + + - - + + - - + + @@ -854,11 +854,11 @@ - + - @@ -906,7 +906,7 @@ def my_form_open(dialog, layer, feature): "title" - + 3.81269890511455989 43.56401658401840393 @@ -973,7 +973,7 @@ def my_form_open(dialog, layer, feature): - + @@ -998,433 +998,433 @@ def my_form_open(dialog, layer, feature): 1 0 - + - + - + - + - + - + - + - + - + - - - - - + + + + + - + - + - + - + - + - + - + - + - + - + - + - + @@ -1435,62 +1435,62 @@ def my_form_open(dialog, layer, feature): 0 0 1 - - - - + + + + - + - + @@ -1498,12 +1498,12 @@ def my_form_open(dialog, layer, feature): - + @@ -1514,14 +1514,14 @@ def my_form_open(dialog, layer, feature): - + - + - - + + - - + + - - + + @@ -1549,11 +1549,11 @@ def my_form_open(dialog, layer, feature): - + - @@ -1601,7 +1601,7 @@ def my_form_open(dialog, layer, feature): "title" - + 3.88174104435118705 43.62005232408321831 @@ -1667,7 +1667,7 @@ def my_form_open(dialog, layer, feature): - + @@ -1692,189 +1692,189 @@ def my_form_open(dialog, layer, feature): 1 0 - + - + - + - + - + - + - + - + - + - + - + @@ -1885,62 +1885,62 @@ def my_form_open(dialog, layer, feature): 0 0 1 - - - - + + + + - + - + @@ -1948,12 +1948,12 @@ def my_form_open(dialog, layer, feature): - + @@ -1964,14 +1964,14 @@ def my_form_open(dialog, layer, feature): - + - + - - + + - - + + - - + + @@ -1999,11 +1999,11 @@ def my_form_open(dialog, layer, feature): - + - @@ -2051,7 +2051,7 @@ def my_form_open(dialog, layer, feature): "title" - + 3.89746923687410218 43.62457311261664472 @@ -2117,7 +2117,7 @@ def my_form_open(dialog, layer, feature): - + @@ -2142,189 +2142,189 @@ def my_form_open(dialog, layer, feature): 1 0 - + - + - + - + - + - + - + - + - + - + - + @@ -2335,62 +2335,62 @@ def my_form_open(dialog, layer, feature): 0 0 1 - - - - + + + + - + - + @@ -2398,12 +2398,12 @@ def my_form_open(dialog, layer, feature): - + @@ -2414,14 +2414,14 @@ def my_form_open(dialog, layer, feature): - + - + - - + + - - + + - - + + @@ -2449,11 +2449,11 @@ def my_form_open(dialog, layer, feature): - + - @@ -2501,7 +2501,7 @@ def my_form_open(dialog, layer, feature): "title" - + 3.85664532539917992 43.57105532588823138 @@ -2568,7 +2568,7 @@ def my_form_open(dialog, layer, feature): - + @@ -2585,188 +2585,188 @@ def my_form_open(dialog, layer, feature): - + 1 1 1 0 - + - + - + - + - + - + - + - + - + - + - + @@ -2777,7 +2777,7 @@ def my_form_open(dialog, layer, feature): @@ -2785,54 +2785,54 @@ def my_form_open(dialog, layer, feature): 0 0 1 - - - - + + + + - + - + @@ -2840,12 +2840,12 @@ def my_form_open(dialog, layer, feature): - + @@ -2872,16 +2872,16 @@ def my_form_open(dialog, layer, feature): - - + + - - + + - - + + @@ -2891,11 +2891,11 @@ def my_form_open(dialog, layer, feature): - + - @@ -2954,181 +2954,181 @@ def my_form_open(dialog, layer, feature): 1 0 - + - + - + - + - + - + - + - + - + - + - + @@ -3139,62 +3139,62 @@ def my_form_open(dialog, layer, feature): 0 0 1 - - - - + + + + - + - + @@ -3202,12 +3202,12 @@ def my_form_open(dialog, layer, feature): - + @@ -3218,14 +3218,14 @@ def my_form_open(dialog, layer, feature): - + - + - - + + - - + + - - + + @@ -3253,11 +3253,11 @@ def my_form_open(dialog, layer, feature): - + - @@ -3305,7 +3305,7 @@ def my_form_open(dialog, layer, feature): "title" - + 3.88567309248191517 43.6228987861304347 @@ -3371,7 +3371,7 @@ def my_form_open(dialog, layer, feature): - + @@ -3396,181 +3396,181 @@ def my_form_open(dialog, layer, feature): 1 0 - + - + - + - + - + - + - + - + - + - + - + @@ -3581,62 +3581,62 @@ def my_form_open(dialog, layer, feature): 0 0 1 - - - - + + + + - + - + @@ -3644,12 +3644,12 @@ def my_form_open(dialog, layer, feature): - + @@ -3660,14 +3660,14 @@ def my_form_open(dialog, layer, feature): - + - + - - + + - - + + - - + + @@ -3695,11 +3695,11 @@ def my_form_open(dialog, layer, feature): - + - @@ -3747,7 +3747,7 @@ def my_form_open(dialog, layer, feature): "title" - + 3.839991945080798 43.57356896293617865 @@ -3814,7 +3814,7 @@ def my_form_open(dialog, layer, feature): - + @@ -3839,173 +3839,173 @@ def my_form_open(dialog, layer, feature): 1 0 - + - + - + - + - + - + - + - + - + - + - + @@ -4016,62 +4016,62 @@ def my_form_open(dialog, layer, feature): 0 0 1 - - - - + + + + - + - + @@ -4079,36 +4079,36 @@ def my_form_open(dialog, layer, feature): - + - - + - + - - + + - - + + - - + + @@ -4136,11 +4136,11 @@ def my_form_open(dialog, layer, feature): - + - @@ -4188,7 +4188,7 @@ def my_form_open(dialog, layer, feature): "title" - + 3.88960514061264506 43.62725193799943213 @@ -4262,173 +4262,173 @@ def my_form_open(dialog, layer, feature): 1 0 - + - + - + - + - + - + - + - + - + - + - + @@ -4452,14 +4452,14 @@ def my_form_open(dialog, layer, feature): - + - + - - + + - - + + - - + + @@ -4487,7 +4487,7 @@ def my_form_open(dialog, layer, feature): - + @@ -4510,7 +4510,7 @@ def my_form_open(dialog, layer, feature): - + 3.80298443326216784 43.56410038340207791 @@ -4576,7 +4576,7 @@ def my_form_open(dialog, layer, feature): - + @@ -4601,173 +4601,173 @@ def my_form_open(dialog, layer, feature): 1 0 - + - + - + - + - + - + - + - + - + - + - + @@ -4778,61 +4778,62 @@ def my_form_open(dialog, layer, feature): 0 0 1 - - - + + + + - + - + @@ -4840,36 +4841,36 @@ def my_form_open(dialog, layer, feature): - + - - + - + - - + + - - + + - - + + @@ -4897,11 +4898,11 @@ def my_form_open(dialog, layer, feature): - + - @@ -5114,9 +5115,9 @@ def my_form_open(dialog, layer, feature): @@ -5147,7 +5148,7 @@ def my_form_open(dialog, layer, feature): - + PROJCRS["WGS 84 / Pseudo-Mercator",BASEGEOGCRS["WGS 84",ENSEMBLE["World Geodetic System 1984 ensemble",MEMBER["World Geodetic System 1984 (Transit)"],MEMBER["World Geodetic System 1984 (G730)"],MEMBER["World Geodetic System 1984 (G873)"],MEMBER["World Geodetic System 1984 (G1150)"],MEMBER["World Geodetic System 1984 (G1674)"],MEMBER["World Geodetic System 1984 (G1762)"],MEMBER["World Geodetic System 1984 (G2139)"],ELLIPSOID["WGS 84",6378137,298.257223563,LENGTHUNIT["metre",1]],ENSEMBLEACCURACY[2.0]],PRIMEM["Greenwich",0,ANGLEUNIT["degree",0.0174532925199433]],ID["EPSG",4326]],CONVERSION["Popular Visualisation Pseudo-Mercator",METHOD["Popular Visualisation Pseudo Mercator",ID["EPSG",1024]],PARAMETER["Latitude of natural origin",0,ANGLEUNIT["degree",0.0174532925199433],ID["EPSG",8801]],PARAMETER["Longitude of natural origin",0,ANGLEUNIT["degree",0.0174532925199433],ID["EPSG",8802]],PARAMETER["False easting",0,LENGTHUNIT["metre",1],ID["EPSG",8806]],PARAMETER["False northing",0,LENGTHUNIT["metre",1],ID["EPSG",8807]]],CS[Cartesian,2],AXIS["easting (X)",east,ORDER[1],LENGTHUNIT["metre",1]],AXIS["northing (Y)",north,ORDER[2],LENGTHUNIT["metre",1]],USAGE[SCOPE["Web mapping and visualisation."],AREA["World between 85.06°S and 85.06°N."],BBOX[-85.06,-180,85.06,180]],ID["EPSG",3857]] +proj=merc +a=6378137 +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0 +y_0=0 +k=1 +units=m +nadgrids=@null +wktext +no_defs @@ -5161,41 +5162,41 @@ def my_form_open(dialog, layer, feature): - + - + - + - + diff --git a/tests/qgis-projects/tests/single_wms_image.qgs.cfg b/tests/qgis-projects/tests/single_wms_image.qgs.cfg index ab194d7950..fa50a6cfe3 100644 --- a/tests/qgis-projects/tests/single_wms_image.qgs.cfg +++ b/tests/qgis-projects/tests/single_wms_image.qgs.cfg @@ -1,14 +1,17 @@ { "metadata": { - "qgis_desktop_version": 32815, - "lizmap_plugin_version_str": "4.2.2", - "lizmap_plugin_version": 40202, + "qgis_desktop_version": 32809, + "lizmap_plugin_version_str": "4.3.6", + "lizmap_plugin_version": 40306, "lizmap_web_client_target_version": 30800, "lizmap_web_client_target_status": "Dev", "instance_target_url": "http://localhost:8130/", "instance_target_repository": "intranet" }, "warnings": {}, + "debug": { + "total_time": 0.52 + }, "options": { "projection": { "proj4": "+proj=merc +a=6378137 +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0 +y_0=0 +k=1 +units=m +nadgrids=@null +wktext +no_defs", @@ -545,7 +548,28 @@ } }, "tooltipLayers": {}, - "editionLayers": {}, + "editionLayers": { + "single_wms_points": { + "layerId": "single_wms_points_7462146f_833e_4d7f_be4f_bccfc4ca1662", + "snap_layers": [], + "snap_vertices": "False", + "snap_segments": "False", + "snap_intersections": "False", + "snap_vertices_tolerance": 10, + "snap_segments_tolerance": 10, + "snap_intersections_tolerance": 10, + "provider": "postgres", + "capabilities": { + "createFeature": "True", + "allow_without_geom": "False", + "modifyAttribute": "True", + "modifyGeometry": "True", + "deleteFeature": "False" + }, + "geometryType": "point", + "order": 0 + } + }, "layouts": { "config": { "default_popup_print": false