Skip to content

Commit 84d4335

Browse files
committed
group popup by layers mode - tests
1 parent e49baac commit 84d4335

File tree

9 files changed

+7348
-0
lines changed

9 files changed

+7348
-0
lines changed

tests/end2end/playwright/pages/project.js

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -824,6 +824,67 @@ export class ProjectPage extends BasePage {
824824
await this.page.locator('#dock-close').click();
825825
}
826826

827+
/**
828+
* Checks group popup by layers component table and returns table rows
829+
* @param {object[]} expectedResults array of expected values for each group
830+
* @returns {Promise<Locator>}
831+
*/
832+
async checkGroupPopupByLayersGroups(expectedResults){
833+
await expect(this.page.locator('lizmap-group-popup-layer')).toHaveCount(1);
834+
let groups = this.page.locator('lizmap-group-popup-layer .lizmap-gpl-table tr');
835+
836+
await expect(groups).toHaveCount(expectedResults.length);
837+
for (let i=0; i< expectedResults.length; i++) {
838+
await expect(groups.nth(i).locator('td').nth(0)).toHaveText(expectedResults[i].name);
839+
await expect(groups.nth(i).locator('td').nth(1)).toHaveText(`(${expectedResults[i].count})`);
840+
}
841+
842+
return groups;
843+
}
844+
845+
/**
846+
* Checks the group popup by layers component single feature interface
847+
* @param {number} backItemLength "Back to layers list" selector expected length
848+
* @param {number} counterLength Counter selector expected length
849+
* @param {string} counterText Counter selector expected text
850+
* @param {number} navButtonsLength Nav buttons selector expected length
851+
* @returns {Promise<void>}
852+
*/
853+
async checkGroupPopupByLayersFeatures(backItemLength, counterLength, counterText, navButtonsLength){
854+
await expect(this.page.locator('lizmap-group-popup-layer .gpl-back')).toHaveCount(backItemLength);
855+
await expect(this.page.locator('lizmap-group-popup-layer .gpl-counter')).toHaveCount(counterLength);
856+
if(counterText) {
857+
await expect(this.page.locator('lizmap-group-popup-layer .gpl-counter')).toHaveText(counterText);
858+
}
859+
await expect(this.page.locator('lizmap-group-popup-layer .gpl-nav-buttons button')).toHaveCount(navButtonsLength);
860+
}
861+
862+
/**
863+
* Group popup by layers: navigate features list back/forth based on direction parameter
864+
* @param {string} direction possible values are 'next' or 'prev', default 'next'
865+
*/
866+
async groupPopupByLayersSwitchFeature(direction = 'next'){
867+
await this.page.locator(`lizmap-group-popup-layer .gpl-${direction}-popup`).click();
868+
}
869+
870+
/**
871+
* Group popup by layers: back to layers list
872+
* @returns {Promise<void>}
873+
*/
874+
async groupPopupByLayersBackToList(){
875+
await this.page.locator('lizmap-group-popup-layer .gpl-back').click();
876+
}
877+
878+
/**
879+
* Returns first level popup single features
880+
* @param {boolean} groupPopupByLayer
881+
* @returns {Promise<Locator>}
882+
*/
883+
async getPopupSingleFeatures(groupPopupByLayer = false){
884+
const singleFeaturesSelector = `${groupPopupByLayer ? 'lizmap-group-popup-layer div[slot="popup"]':'.lizmapPopupContent'} > .lizmapPopupSingleFeature`;
885+
return this.page.locator(singleFeaturesSelector);
886+
}
887+
827888
/**
828889
* clickOnMap function
829890
* Click on the map at the given position

tests/end2end/playwright/popup.spec.js

Lines changed: 207 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -712,3 +712,210 @@ test.describe('Drag and drop design with relations', () => {
712712

713713
});
714714
});
715+
716+
test.describe('Group popup by layers @readonly', () => {
717+
718+
['dock','map','minidock'].forEach((popupLocation) => {
719+
test(`popup on ${popupLocation}`, async ({ page }) => {
720+
if (popupLocation != 'minidock') {
721+
await page.route('**/service/getProjectConfig*', async route => {
722+
const response = await route.fetch();
723+
const json = await response.json();
724+
json.options['popupLocation'] = popupLocation;
725+
await route.fulfill({ response, json });
726+
});
727+
}
728+
729+
const project = new ProjectPage(page, `popup_grouped_by_layer${popupLocation == 'minidock' ? '_minidock' : ''}`);
730+
await project.open();
731+
await project.closeLeftDock();
732+
733+
// Remove catching GetProjectConfig
734+
if (popupLocation != 'minidock') {
735+
await page.unroute('**/service/getProjectConfig*');
736+
}
737+
let getFeatureInfoPromise = project.waitForGetFeatureInfoRequest();
738+
await project.clickOnMap(417, 289);
739+
let getFeatureInfoRequest = await getFeatureInfoPromise;
740+
let getFeatureInfoResponse = await getFeatureInfoRequest.response();
741+
responseExpect(getFeatureInfoResponse).toBeHtml();
742+
await page.waitForTimeout(500);
743+
744+
const loc = await page.evaluate('lizMap.config.options.popupLocation');
745+
await expect(loc).toBe(popupLocation);
746+
747+
// check grouped layers
748+
let groups = await project.checkGroupPopupByLayersGroups([
749+
{
750+
name: 'single_wms_points',
751+
count: 4
752+
},
753+
{
754+
name: 'single_wms_lines',
755+
count: 1
756+
},
757+
{
758+
name: 'single_wms_baselayer',
759+
count: 1
760+
},
761+
]);
762+
763+
// check first layer
764+
await groups.nth(0).click();
765+
await project.checkGroupPopupByLayersFeatures(1,1,'1/4',2);
766+
let features = await project.getPopupSingleFeatures(true);
767+
await expect(features).toHaveCount(6);
768+
769+
await expect(features.nth(0)).toBeVisible();
770+
await expect(features.nth(0).locator('.lizmapPopupTitle')).toHaveText('single_wms_points');
771+
await expect(features.nth(1)).not.toBeVisible();
772+
await expect(features.nth(2)).not.toBeVisible();
773+
await expect(features.nth(3)).not.toBeVisible();
774+
await expect(features.nth(4)).not.toBeVisible();
775+
await expect(features.nth(5)).not.toBeVisible();
776+
777+
// switch feature
778+
await project.groupPopupByLayersSwitchFeature();
779+
780+
await project.checkGroupPopupByLayersFeatures(1,1,'2/4',2);
781+
782+
await expect(features.nth(0)).not.toBeVisible();
783+
await expect(features.nth(1)).toBeVisible();
784+
await expect(features.nth(2)).not.toBeVisible();
785+
await expect(features.nth(3)).not.toBeVisible();
786+
await expect(features.nth(4)).not.toBeVisible();
787+
await expect(features.nth(5)).not.toBeVisible();
788+
789+
await project.groupPopupByLayersSwitchFeature();
790+
await project.checkGroupPopupByLayersFeatures(1,1,'3/4',2);
791+
792+
await expect(features.nth(0)).not.toBeVisible();
793+
await expect(features.nth(1)).not.toBeVisible();
794+
await expect(features.nth(2)).toBeVisible();
795+
await expect(features.nth(3)).not.toBeVisible();
796+
await expect(features.nth(4)).not.toBeVisible();
797+
await expect(features.nth(5)).not.toBeVisible();
798+
799+
await project.groupPopupByLayersSwitchFeature('prev');
800+
801+
await project.checkGroupPopupByLayersFeatures(1,1,'2/4',2);
802+
803+
await expect(features.nth(0)).not.toBeVisible();
804+
await expect(features.nth(1)).toBeVisible();
805+
await expect(features.nth(2)).not.toBeVisible();
806+
await expect(features.nth(3)).not.toBeVisible();
807+
await expect(features.nth(4)).not.toBeVisible();
808+
await expect(features.nth(5)).not.toBeVisible();
809+
810+
await project.groupPopupByLayersSwitchFeature();
811+
812+
// back to layers list
813+
await project.groupPopupByLayersBackToList();
814+
groups = await project.checkGroupPopupByLayersGroups([
815+
{
816+
name: 'single_wms_points',
817+
count: 4
818+
},
819+
{
820+
name: 'single_wms_lines',
821+
count: 1
822+
},
823+
{
824+
name: 'single_wms_baselayer',
825+
count: 1
826+
},
827+
]);
828+
829+
await groups.nth(1).click();
830+
await project.checkGroupPopupByLayersFeatures(1,0,'',0);
831+
832+
await expect(features.nth(0)).not.toBeVisible();
833+
await expect(features.nth(1)).not.toBeVisible();
834+
await expect(features.nth(2)).not.toBeVisible();
835+
await expect(features.nth(3)).not.toBeVisible();
836+
await expect(features.nth(4)).toBeVisible();
837+
await expect(features.nth(4).locator('.lizmapPopupTitle')).toHaveText('single_wms_lines');
838+
await expect(features.nth(5)).not.toBeVisible();
839+
840+
// check wether lizmap features table component is rendered
841+
await expect(features.nth(4).locator('lizmap-features-table')).toHaveCount(1);
842+
843+
await project.groupPopupByLayersBackToList();
844+
groups = await project.checkGroupPopupByLayersGroups([
845+
{
846+
name: 'single_wms_points',
847+
count: 4
848+
},
849+
{
850+
name: 'single_wms_lines',
851+
count: 1
852+
},
853+
{
854+
name: 'single_wms_baselayer',
855+
count: 1
856+
},
857+
]);
858+
859+
await groups.nth(2).click();
860+
await project.checkGroupPopupByLayersFeatures(1,0,'',0);
861+
await expect(page.locator('lizmap-group-popup-layer .gpl-back')).toHaveCount(1);
862+
await expect(page.locator('lizmap-group-popup-layer .gpl-counter')).toHaveCount(0);
863+
await expect(page.locator('lizmap-group-popup-layer .gpl-nav-buttons')).toHaveCount(0);
864+
await expect(features.nth(0)).not.toBeVisible();
865+
await expect(features.nth(1)).not.toBeVisible();
866+
await expect(features.nth(2)).not.toBeVisible();
867+
await expect(features.nth(3)).not.toBeVisible();
868+
await expect(features.nth(4)).not.toBeVisible();
869+
await expect(features.nth(5)).toBeVisible();
870+
await expect(features.nth(5).locator('.lizmapPopupTitle')).toHaveText('single_wms_baselayer');
871+
872+
// the status is mantained
873+
await project.groupPopupByLayersBackToList();
874+
groups = await project.checkGroupPopupByLayersGroups([
875+
{
876+
name: 'single_wms_points',
877+
count: 4
878+
},
879+
{
880+
name: 'single_wms_lines',
881+
count: 1
882+
},
883+
{
884+
name: 'single_wms_baselayer',
885+
count: 1
886+
},
887+
]);
888+
889+
await groups.nth(0).click();
890+
await project.checkGroupPopupByLayersFeatures(1,1,'3/4',2);
891+
892+
await expect(features.nth(0)).not.toBeVisible();
893+
await expect(features.nth(1)).not.toBeVisible();
894+
await expect(features.nth(2)).toBeVisible();
895+
await expect(features.nth(3)).not.toBeVisible();
896+
await expect(features.nth(4)).not.toBeVisible();
897+
await expect(features.nth(5)).not.toBeVisible();
898+
899+
// check if relation is visible
900+
await features.nth(2).locator('.nav-item').nth(1).click();
901+
expect(features.nth(2).locator('.lizmapPopupSingleFeature[data-layer-id="table_for_relationnal_value_fbba335b_1fa6_4560_9eed_7591c0aa9b74"]')).toBeVisible()
902+
903+
await project.switcher.click();
904+
//turn off all layers except the single_wms_baselayer and then reuqest popup
905+
await page.getByTestId('single_wms_polygons').locator('input').first().uncheck();
906+
await page.getByTestId('single_wms_points').locator('input').first().uncheck();
907+
await page.getByTestId('single_wms_lines_group').locator('input').first().uncheck();
908+
await page.getByTestId('single_wms_lines').locator('input').first().uncheck();
909+
910+
getFeatureInfoPromise = project.waitForGetFeatureInfoRequest();
911+
await project.clickOnMap(417, 289);
912+
getFeatureInfoRequest = await getFeatureInfoPromise;
913+
getFeatureInfoResponse = await getFeatureInfoRequest.response();
914+
responseExpect(getFeatureInfoResponse).toBeHtml();
915+
await page.waitForTimeout(500);
916+
917+
await project.checkGroupPopupByLayersFeatures(0,0,'',0);
918+
})
919+
})
920+
921+
})

0 commit comments

Comments
 (0)