Skip to content

Commit f8f9109

Browse files
AliyanHprushforth
authored andcommitted
remove _updateFeature as it is not being used anymore + updated _reRender to add events in map-feature.js
Intentionally set focus on map viewer at test begin Attempt to remove system dependencies in tests Prettier format Change tests to use https when accessing WMS services Revert timeout for playwright to 30s
1 parent 1b452fa commit f8f9109

9 files changed

+24
-39
lines changed

playwright.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const config = {
2-
timeout: 30000,
2+
timeout: 15000,
33
testDir: './test/e2e',
44
webServer: {
55
command: 'node test/server.js',

src/map-feature.js

+2-30
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,6 @@ export class MapFeature extends HTMLElement {
146146
if (this._groupEl.isConnected) {
147147
let native = this._getNativeZoomAndCS(this._layer._content);
148148
let placeholder = document.createElement('span');
149-
let mapmlvectors = this._layer._mapmlvectors;
150149
this._groupEl.insertAdjacentElement('beforebegin', placeholder);
151150

152151
this._featureGroup._map.removeLayer(this._featureGroup);
@@ -155,9 +154,10 @@ export class MapFeature extends HTMLElement {
155154
.addData(this, native.cs, native.zoom)
156155
.addTo(this._map);
157156
placeholder.replaceWith(this._featureGroup.options.group);
158-
// TODO: getBounds() should dynamically update the layerBounds
157+
// TODO: getBounds() should dynamically update the layerBounds and zoomBounds
159158
this._layer._setLayerElExtent();
160159
delete this._getFeatureExtent;
160+
this._setUpEvents();
161161
}
162162
}
163163

@@ -243,34 +243,6 @@ export class MapFeature extends HTMLElement {
243243
});
244244
}
245245

246-
_updateFeature() {
247-
let mapmlvectors = this._layer._mapmlvectors;
248-
// if the parent layer has not yet rendered on the map
249-
if (!mapmlvectors) return;
250-
// if the <layer- > is not removed, then regenerate featureGroup and update the mapmlvectors accordingly
251-
let native = this._getNativeZoomAndCS(this._layer._content);
252-
this._featureGroup = mapmlvectors.addData(this, native.cs, native.zoom);
253-
mapmlvectors._layers[this._featureGroup._leaflet_id] = this._featureGroup;
254-
this._groupEl = this._featureGroup.options.group;
255-
if (mapmlvectors._staticFeature) {
256-
let container = this._layer.shadowRoot || this._layer._layerEl;
257-
// update zoom bounds of vector layer
258-
mapmlvectors.zoomBounds = M.getZoomBounds(
259-
this._layer._content,
260-
this._getNativeZoomAndCS(this._layer._content).zoom
261-
);
262-
// update layer bounds of vector layer
263-
mapmlvectors.layerBounds = M.getBounds(this._layer._content);
264-
// add feature layers to map
265-
// mapmlvectors._resetFeatures();
266-
this._layer._setLayerElExtent();
267-
// update map's zoom limit
268-
this._map._addZoomLimit(mapmlvectors);
269-
L.extend(mapmlvectors.options, mapmlvectors.zoomBounds);
270-
}
271-
this._setUpEvents();
272-
}
273-
274246
_setUpEvents() {
275247
['click', 'focus', 'blur', 'keyup', 'keydown'].forEach((name) => {
276248
// when <g> is clicked / focused / blurred

test/e2e/core/featureIndexOverlayFocus.test.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ test.describe('Feature Index Overlay Focus tests', () => {
8080
).toBe(false);
8181
});
8282
test('Feature index overlay and reticle show on history-based navigation', async () => {
83+
await page.locator('#map1').focus();
8384
await page.keyboard.press('ArrowRight');
8485
await page.keyboard.press('ArrowUp');
8586
await page.keyboard.press('ArrowRight');
@@ -88,11 +89,10 @@ test.describe('Feature Index Overlay Focus tests', () => {
8889
await page.locator('#map1').getByText('Back').click();
8990
await page.keyboard.press('Shift+F10');
9091
await page.locator('#map1').getByText('Back').click();
91-
const afterHistoryNavReticle = page.locator(
92+
const afterHistoryNavReticle = await page.locator(
9293
'#map1 .mapml-feature-index-box'
9394
);
9495
expect(await afterHistoryNavReticle.isHidden()).toBe(false);
95-
9696
const afterHistoryNavOutput = page.locator(
9797
'#map1 output.mapml-feature-index'
9898
);
@@ -101,7 +101,7 @@ test.describe('Feature Index Overlay Focus tests', () => {
101101
o.classList.contains('mapml-screen-reader-output')
102102
)
103103
).toBe(false);
104-
await page.locator('#map1').getByTitle('Reload').click();
104+
//await page.locator('#map1').getByTitle('Reload').click();
105105
});
106106
test('Feature index overlay and reticle show on geolocation activation, deactivation', async () => {
107107
await page

test/e2e/core/metaDefault.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
<map-input name="xmax" type="location" units="pcrs" position="top-right" axis="easting" ></map-input>
3232
<map-input name="ymax" type="location" units="pcrs" position="top-left" axis="northing" ></map-input>
3333
<map-link rel="image"
34-
tref="http://maps.geogratis.gc.ca/wms/toporama_en?SERVICE=WMS&REQUEST=GetMap&FORMAT=image/jpeg&TRANSPARENT=FALSE&STYLES=&VERSION=1.3.0&LAYERS=WMS-Toporama&WIDTH={w}&HEIGHT={h}&CRS=EPSG:3978&BBOX={xmin},{ymin},{xmax},{ymax}&m4h=t" ></map-link>
34+
tref="https://maps.geogratis.gc.ca/wms/toporama_en?SERVICE=WMS&REQUEST=GetMap&FORMAT=image/jpeg&TRANSPARENT=FALSE&STYLES=&VERSION=1.3.0&LAYERS=WMS-Toporama&WIDTH={w}&HEIGHT={h}&CRS=EPSG:3978&BBOX={xmin},{ymin},{xmax},{ymax}&m4h=t" ></map-link>
3535
</map-extent>
3636
</layer->
3737
<layer- id="defaultMeta" label="Default meta" checked>

test/e2e/data/tiles/cbmt/templatedImage.mapml

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<map-input name="ymin" type="location" units="pcrs" position="bottom-left" axis="northing" min="28448056.0" max="42672085.0"></map-input>
1515
<map-input name="xmax" type="location" units="pcrs" position="top-right" axis="easting" min="28448056.0" max="38608077.0"></map-input>
1616
<map-input name="ymax" type="location" units="pcrs" position="top-left" axis="northing" min="28448056.0" max="42672085.0"></map-input>
17-
<map-link rel="image" tref="http://maps.geogratis.gc.ca/wms/toporama_en?SERVICE=WMS&amp;REQUEST=GetMap&amp;FORMAT=image/jpeg&amp;TRANSPARENT=FALSE&amp;STYLES=&amp;VERSION=1.3.0&amp;LAYERS=WMS-Toporama&amp;WIDTH={w}&amp;HEIGHT={h}&amp;CRS=EPSG:3978&amp;BBOX={xmin},{ymin},{xmax},{ymax}&amp;m4h=t"></map-link>
17+
<map-link rel="image" tref="https://maps.geogratis.gc.ca/wms/toporama_en?SERVICE=WMS&amp;REQUEST=GetMap&amp;FORMAT=image/jpeg&amp;TRANSPARENT=FALSE&amp;STYLES=&amp;VERSION=1.3.0&amp;LAYERS=WMS-Toporama&amp;WIDTH={w}&amp;HEIGHT={h}&amp;CRS=EPSG:3978&amp;BBOX={xmin},{ymin},{xmax},{ymax}&amp;m4h=t"></map-link>
1818
</map-extent>
1919
</map-body>
2020
</mapml->

test/e2e/layers/multipleExtents.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
<map-input name="xmax" type="location" units="pcrs" position="top-right" axis="easting" ></map-input>
5050
<map-input name="ymax" type="location" units="pcrs" position="top-left" axis="northing" ></map-input>
5151
<map-link rel="image"
52-
tref="http://maps.geogratis.gc.ca/wms/toporama_en?SERVICE=WMS&REQUEST=GetMap&FORMAT=image/jpeg&TRANSPARENT=FALSE&STYLES=&VERSION=1.3.0&LAYERS=WMS-Toporama&WIDTH={w}&HEIGHT={h}&CRS=EPSG:3978&BBOX={xmin},{ymin},{xmax},{ymax}&m4h=t" ></map-link>
52+
tref="https://maps.geogratis.gc.ca/wms/toporama_en?SERVICE=WMS&REQUEST=GetMap&FORMAT=image/jpeg&TRANSPARENT=FALSE&STYLES=&VERSION=1.3.0&LAYERS=WMS-Toporama&WIDTH={w}&HEIGHT={h}&CRS=EPSG:3978&BBOX={xmin},{ymin},{xmax},{ymax}&m4h=t" ></map-link>
5353
</map-extent>
5454
</layer->
5555
</mapml-viewer>

test/e2e/layers/multipleQueryExtents.test.js

+13
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ test.describe('Multiple Extent Query Tests', () => {
2222
await page.evaluateHandle(() =>
2323
document.querySelector('mapml-viewer').zoomTo(85, 147, 0)
2424
);
25+
await page.waitForTimeout(1000);
2526
await page.click('mapml-viewer');
2627
await page.waitForSelector('.leaflet-popup-content-wrapper p');
2728
let numFeatures = await page.$eval(
@@ -103,6 +104,7 @@ test.describe('Multiple Extent Query Tests', () => {
103104
await page.evaluateHandle(() =>
104105
document.querySelector('mapml-viewer').zoomTo(10, 5, 0)
105106
);
107+
await page.waitForTimeout(1000);
106108
await page.locator('mapml-viewer').click({ position: { x: 250, y: 250 } });
107109
await page
108110
.locator(
@@ -118,6 +120,12 @@ test.describe('Multiple Extent Query Tests', () => {
118120

119121
test('Only features from one extent are returned for queries inside its (non overlapping) bounds', async () => {
120122
await page.getByRole('button', { name: 'Close popup' }).click();
123+
const viewer = await page.locator('mapml-viewer');
124+
await viewer.evaluate((viewer) => {
125+
viewer.reload();
126+
});
127+
// panning / zooming takes time...
128+
await page.waitForTimeout(1000);
121129
await page.locator('mapml-viewer').click({ position: { x: 450, y: 150 } });
122130
await page.getByTitle('Next Feature').click();
123131
await page.getByTitle('Next Feature').click();
@@ -145,6 +153,8 @@ test.describe('Multiple Extent Query Tests', () => {
145153
await page.evaluateHandle(() =>
146154
document.querySelector('mapml-viewer').zoomTo(-18, 5, 0)
147155
);
156+
// panning / zooming takes time...
157+
await page.waitForTimeout(300);
148158
await page.locator('mapml-viewer').click({ position: { x: 400, y: 250 } });
149159
const popupNumRight = await page.$eval(
150160
'div > div.leaflet-pane.leaflet-map-pane > div.leaflet-pane.leaflet-popup-pane',
@@ -154,6 +164,7 @@ test.describe('Multiple Extent Query Tests', () => {
154164
await page.evaluateHandle(() =>
155165
document.querySelector('mapml-viewer').zoomTo(-16, -40, 0)
156166
);
167+
await page.waitForTimeout(300);
157168
await page.locator('mapml-viewer').click({ position: { x: 250, y: 400 } });
158169
const popupNumBottom = await page.$eval(
159170
'div > div.leaflet-pane.leaflet-map-pane > div.leaflet-pane.leaflet-popup-pane',
@@ -163,6 +174,7 @@ test.describe('Multiple Extent Query Tests', () => {
163174
await page.evaluateHandle(() =>
164175
document.querySelector('mapml-viewer').zoomTo(33, -170, 0)
165176
);
177+
await page.waitForTimeout(300);
166178
await page.locator('mapml-viewer').click({ position: { x: 50, y: 250 } });
167179
const popupNumLeft = await page.$eval(
168180
'div > div.leaflet-pane.leaflet-map-pane > div.leaflet-pane.leaflet-popup-pane',
@@ -172,6 +184,7 @@ test.describe('Multiple Extent Query Tests', () => {
172184
await page.evaluateHandle(() =>
173185
document.querySelector('mapml-viewer').zoomTo(30, 98, 0)
174186
);
187+
await page.waitForTimeout(300);
175188
await page.locator('mapml-viewer').click({ position: { x: 250, y: 50 } });
176189
const popupNumTop = await page.$eval(
177190
'div > div.leaflet-pane.leaflet-map-pane > div.leaflet-pane.leaflet-popup-pane',

test/e2e/layers/step/imageStep.test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ test.describe('Templated image layer with step', () => {
99
1,
1010
0,
1111
0,
12-
'http://maps.geogratis.gc.ca/wms/toporama_en?SERVICE=WMS&REQUEST=GetMap&FORMAT=image/jpeg&TRANSPARENT=FALSE&STYLES=&VERSION=1.3.0&LAYERS=WMS-Toporama&WIDTH=300&HEIGHT=150&CRS=EPSG:3978&BBOX=',
12+
'https://maps.geogratis.gc.ca/wms/toporama_en?SERVICE=WMS&REQUEST=GetMap&FORMAT=image/jpeg&TRANSPARENT=FALSE&STYLES=&VERSION=1.3.0&LAYERS=WMS-Toporama&WIDTH=300&HEIGHT=150&CRS=EPSG:3978&BBOX=',
1313
'-5537023.0124460235,-2392385.4881043136,5972375.006350018,3362313.521293707&m4h=t',
1414
'',
1515
'-968982.6263652518,-107703.83540767431,1412272.136144273,1082923.545847088&m4h=t',

test/e2e/layers/step/templatedImageLayerStep.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
<map-input name="ymax" type="location" units="pcrs" position="top-left" axis="northing" min="-3362085.3441706896"
4040
max="3952277.216154434" ></map-input>
4141
<map-link rel="image"
42-
tref="http://maps.geogratis.gc.ca/wms/toporama_en?SERVICE=WMS&amp;REQUEST=GetMap&amp;FORMAT=image/jpeg&amp;TRANSPARENT=FALSE&amp;STYLES=&amp;VERSION=1.3.0&amp;LAYERS=WMS-Toporama&amp;WIDTH={w}&amp;HEIGHT={h}&amp;CRS=EPSG:3978&amp;BBOX={xmin},{ymin},{xmax},{ymax}&amp;m4h=t" ></map-link>
42+
tref="https://maps.geogratis.gc.ca/wms/toporama_en?SERVICE=WMS&amp;REQUEST=GetMap&amp;FORMAT=image/jpeg&amp;TRANSPARENT=FALSE&amp;STYLES=&amp;VERSION=1.3.0&amp;LAYERS=WMS-Toporama&amp;WIDTH={w}&amp;HEIGHT={h}&amp;CRS=EPSG:3978&amp;BBOX={xmin},{ymin},{xmax},{ymax}&amp;m4h=t" ></map-link>
4343
</map-extent>
4444
</layer->
4545
</mapml-viewer>

0 commit comments

Comments
 (0)