Skip to content
Open
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
4 changes: 3 additions & 1 deletion assets/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,9 @@ const initLizmapApp = () => {
}

// end waiting, does not depend on ongoing asynchronous actions
lizMap.waitEnd(startupConfigurations?.getFeatureInfo);
// startupFeatures is passed so highlights are re-applied after displayGetFeatureInfo clears them,
// even when the call is deferred until popup is initialized
lizMap.waitEnd(startupConfigurations?.getFeatureInfo, startupConfigurations?.startupFeatures);

return;
}, 'lizmap.class.loaded');
Expand Down
25 changes: 19 additions & 6 deletions assets/src/legacy/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -3651,19 +3651,32 @@ window.lizMap = function() {
* Wait end leads to interface modifications
* Removes waiter and display getFeatureInfo, if requested
* @param {Object} getFeatureInfo
* @param {Object} [startupFeatures] - GeoJSON startup features to re-highlight after popup display
* @returns {void}
*/
waitEnd: (getFeatureInfo)=>{
waitEnd: (getFeatureInfo, startupFeatures)=>{
$('body').css('cursor', 'auto');
$('#loading').dialog('close');

// Display getFeatureInfo if requested
if(getFeatureInfo){
displayGetFeatureInfo(getFeatureInfo,
{
x: map.size.w / 2,
y: map.size.h / 2
});
const showGetFeatureInfo = () => {
displayGetFeatureInfo(getFeatureInfo,
{
x: map.size.w / 2,
y: map.size.h / 2
});
// Re-apply startup highlights cleared by popup display
if (startupFeatures) {
lizMap.mainLizmap.map.setHighlightFeatures(startupFeatures, "geojson");
}
};
// popup is initialized after layers load — defer if not ready yet
if (lizMap.mainLizmap?.popup) {
showGetFeatureInfo();
} else {
lizMap.mainEventDispatcher.subscribe(showGetFeatureInfo, 'lizmap.modules.initialized');
}
}
},
/**
Expand Down
21 changes: 21 additions & 0 deletions tests/end2end/playwright/startup.spec.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
// @ts-check
import { test, expect } from '@playwright/test';
import { ProjectPage } from "./pages/project";
Expand Down Expand Up @@ -41,6 +41,27 @@
await expect(page.locator('#lizmap-startup-features-error-message')).toHaveCount(1);
});

test('Zoom to features extent and show popup with popup=true', async ({ page }) => {
const project = new ProjectPage(page, 'startup');
const getFeatureInfoPromise = project.waitForGetFeatureInfoRequest();
await project.openWithExtraParams({
'layer': 'sousquartiers',
'filter': '"quartmno" = \'PA\' OR "quartmno" = \'HO\'',
'popup': 'true',
});

// Wait for the GetFeatureInfo request triggered by popup=true
const getFeatureInfoRequest = await getFeatureInfoPromise;
const postData = getFeatureInfoRequest.postData() ?? '';
expect(postData).toContain('GetFeatureInfo');
expect(postData).toContain('sousquartiers');
Comment on lines +54 to +57
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use toContainParametersInPostData from expect-request.


Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here wait for response, and use toBeHtml (if it is an HTML response) from expect-response.

// The popup dock must be visible with feature content
await expect(project.popupContent).toBeVisible();
const singleFeatures = await project.getPopupSingleFeatures();
await expect(singleFeatures).not.toHaveCount(0);
});

test('Projects with dot or space can load', async ({ page }) => {
let project = new ProjectPage(page, 'base_layers with space');
await project.open();
Expand Down
Loading