Skip to content

Commit

Permalink
test: Fix e2e tests and issues connected with them
Browse files Browse the repository at this point in the history
  • Loading branch information
FilipLeitner committed Jan 22, 2024
1 parent 253c5da commit 1c30d01
Show file tree
Hide file tree
Showing 17 changed files with 73 additions and 68 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,5 @@ hslayers-server.db
projects/hslayers-server/data/hsl-share.db
cypress/videos
cypress/screenshots
cypress/downloads/*
cypress/tests/__image_snapshots__
27 changes: 22 additions & 5 deletions cypress/tests/add-data-catalogue.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,22 +70,39 @@ describe('Hslayers application', () => {
);
});

it('Should be possible to add layer as WMS', () => {
it('Should be possible to add layer', () => {
cy.wait(2000);
cy.get(
'hs-add-data-catalogue .list-group hs-catalogue-list-item:first',
).click();
cy.get('.hs-catalogue-item-body a:first span:not(.hs-loader)')
cy.get('.hs-catalogue-item-body div div.btn-group span:not(.hs-loader)')
.should('have.html', 'Add to map')
.click();
//Should switch to Layermanager
cy.get(
'.hs-main-panel:not([hidden]) hs-panel-header[name*="layerManager"]',
).should('exist');
});

it('Should be possible to add layer as WMST/WMTS/WFS', () => {
cy.wait(2000);
cy.get(
'hs-add-data-catalogue .list-group hs-catalogue-list-item:first',
).click();
cy.get('.hs-catalogue-item-body div div button.dropdown-toggle').click();

cy.get('[title*="What does it mean?"]:first').should('exist').click();
cy.get('hs-catalogue-list-item div[data-toggle="buttons"] label').should(
'have.length',
3,
);
cy.get(
'hs-catalogue-list-item div[data-toggle="buttons"]:first label:first',
'hs-catalogue-list-item div[data-toggle="buttons"] label:first',
).click();

//Should switch to Layermanager
// //Should switch to Layermanager
cy.get(
'.hs-main-panel:not([hidden]) hs-panel-header[name*="layermanager"]',
'.hs-main-panel:not([hidden]) hs-panel-header[name*="layerManager"]',
).should('exist');
});
});
31 changes: 8 additions & 23 deletions cypress/tests/add-data-url.cy.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
function checkIfLayerAdded(layerName) {
cy.get(`hs-panel-header[name="layermanager"]`).should('be.visible');
cy.get(`hs-panel-header[name="layerManager"]`).should('be.visible');
cy.get(
'hs-layer-manager-layer-list li:first .d-flex button.hs-lm-item-visibility',
'hs-layer-manager-layer-list:first li:last .d-flex button.hs-lm-item-visibility',
).should('have.class', 'hs-checkmark');
cy.get('hs-layer-manager-layer-list li:first .hs-lm-item-title').should(
cy.get('hs-layer-manager-layer-list:first li:last .hs-lm-item-title').should(
'have.text',
` ${layerName} `, //Extra padding around title
);
Expand All @@ -15,7 +15,7 @@ function addLayerAndCheckIfAdded() {

//it('Layer should be added', () => {
cy.get('hs-layer-table table tr:first input[type="checkbox"]').click();
cy.get('hs-layer-table table tr td:nth-child(2n) span').then(($td) => {
cy.get('hs-layer-table table tr:first td:nth-child(2n) span').then(($td) => {
const layerName = $td.html();
cy.get('button[title="Add selected layers to the map"').click();
checkIfLayerAdded(layerName);
Expand All @@ -29,15 +29,15 @@ function openPanelAndTypeTab(index) {
).click();
cy.get(`hs-panel-header[name="addData"]`).should('be.visible');
//Open corresponding type tab
cy.get('hs-add-data ul[role="tablist"] li:nth-child(2n) a').click();
cy.get('hs-add-data ul li:nth-child(2n) a').click();
cy.get(`hs-add-data-url>.d-flex>.container>.row>button`).eq(index).click();
}

describe('Hslayers application', () => {
beforeEach(() => {
cy.visit('/');
//Open layer manager
cy.get('.hs-sidebar-item[data-cy="layermanager"]').click();
cy.get('.hs-sidebar-item[data-cy="layerManager"]').click();
//Turn off all layers
cy.get('hs-layer-manager-layer-list li .d-flex button.hs-checkmark').each(
(button) => {
Expand All @@ -54,9 +54,6 @@ describe('Hslayers application', () => {
);
cy.get(`hs-url-wms hs-common-url input + button`).click();
addLayerAndCheckIfAdded();
//it('Layer should be visible on map', () => {
cy.wait(3000); //Need to wait for failed layman request error toast to disappear if HsConfig.errorToastDuration is large
cy.get('.hs-ol-map').matchImage();
});

it('WMTS layer should be visible on map', () => {
Expand All @@ -67,9 +64,6 @@ describe('Hslayers application', () => {
);
cy.get(`hs-url-wmts hs-common-url input + button`).click();
addLayerAndCheckIfAdded();
//it('Layer should be visible on map', () => {
cy.wait(2000);
cy.get('.hs-ol-map').matchImage();
});

it('WFS layer should be visible on map', () => {
Expand All @@ -81,9 +75,6 @@ describe('Hslayers application', () => {
);
cy.get(`hs-url-wfs hs-common-url input + button`).click();
addLayerAndCheckIfAdded();
//it('Layer should be visible on map', () => {
cy.wait(2000);
cy.get('.hs-ol-map').matchImage();
});

it('geoJSON layer should be visible on map', () => {
Expand All @@ -97,14 +88,8 @@ describe('Hslayers application', () => {

const layerName = 'Added geojson layer';
cy.get(`input.form-control[name="name"]`).type(layerName);
cy.get('.form-horizontal > :nth-child(2) > .btn-primary').should(
'not.have.attr',
'disabled',
);
cy.get('.form-horizontal > :nth-child(2) > .btn-primary').click();
cy.get('hs-add-to-map .btn-primary').should('not.have.attr', 'disabled');
cy.get('hs-add-to-map .btn-primary').click();
checkIfLayerAdded(layerName);
//it('Layer should be visible on map', () => {
cy.wait(2000);
cy.get('.hs-ol-map').matchImage();
});
});
2 changes: 1 addition & 1 deletion cypress/tests/external.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ describe('Hslayers application', () => {
beforeEach(() => {
cy.visit('/');
//Open layer manager
cy.get('.hs-sidebar-item[data-cy="layermanager"]').click();
cy.get('.hs-sidebar-item[data-cy="layerManager"]').click();
});

it('Should zoom to feature', () => {
Expand Down
14 changes: 5 additions & 9 deletions cypress/tests/language.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,7 @@ describe('Hslayers application', () => {
'hs-mini-sidebar .hs-sidebar-item.hs-panel-hidden[data-cy="language"]',
).click();
cy.get('hs-language .list-group .btn:last').click();
cy.get('hs-language hs-panel-header').should(
'have.attr',
'ng-reflect-title',
'Linguam mutare',
);
cy.get('hs-language hs-panel-header span').should(
cy.get('hs-language hs-panel-header a.nav-link').should(
'contain.text',
'Linguam mutare',
);
Expand All @@ -20,8 +15,9 @@ describe('Hslayers application', () => {
it('App should open with a language other than the default', () => {
cy.visit('/?hs-lang=cs');

cy.get(
'hs-some-panel > .card > hs-panel-header > .card-header > .flex-grow-1',
).should('contain.text', 'Můj úžasný panel');
cy.get('hs-some-panel hs-panel-header a.nav-link').should(
'contain.text',
'Můj úžasný panel',
);
});
});
21 changes: 9 additions & 12 deletions cypress/tests/layermanager.cy.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
describe('Hslayers application', () => {
beforeEach(() => {
cy.visit('/');
cy.wait(2000);

//Open layer manager
cy.get('.hs-sidebar-item[data-cy="layermanager"]').click();
cy.get('.hs-sidebar-item[data-cy="layerManager"]').click();
//Turn off all layers
cy.get('hs-layer-manager-layer-list li .d-flex button.hs-checkmark').each(
(button) => {
Expand All @@ -19,9 +21,7 @@ describe('Hslayers application', () => {
);
return;
}
cy.get(
'.hs-main-panel:not([hidden]) hs-panel-header[name*="layermanager"] extra-buttons button:first',
).click();
cy.get('[data-cy="mainButtonContainer"] > .btn').click();

cy.get('.cdk-drop-list').then(($list) => {
const toBeFirstLayerName = $list.find('.cdk-drag:nth-child(2) div p')[0]
Expand All @@ -42,9 +42,9 @@ describe('Hslayers application', () => {
});

it('Should remove all layers and then reset to default', () => {
cy.get('.card-header > .d-flex > .btn-group > .dropdown-toggle').click();
cy.get('extra-buttons div.dropdown-menu.show').should('be.visible');
cy.get('extra-buttons div.dropdown-menu.show a:first').click();
cy.get('hs-panel-header .dropdown-toggle').click();
cy.get('.extra-buttons-container').should('be.visible');
cy.get('extra-buttons a:first').click();

cy.get('[data-cy="catalogue"]').should('not.be.visible');
const removeButton = cy
Expand All @@ -58,11 +58,8 @@ describe('Hslayers application', () => {

cy.get('.hs-lm-mapcontentlist').children().should('have.length', 1); //All groups are removed

cy.get('.card-header > .d-flex > .btn-group > .dropdown-toggle').click();
cy.get('extra-buttons div.dropdown-menu.show')
.find('a')
.contains('Reset map')
.click();
cy.get('hs-panel-header .dropdown-toggle').click();
cy.get('extra-buttons').find('a').contains('Reset map').click();

cy.get('.hs-lm-mapcontentlist').children().should('have.length', 4); //All groups retrieved
});
Expand Down
11 changes: 7 additions & 4 deletions cypress/tests/sidebar.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ describe('Hslayers application', () => {
beforeEach(() => {
cy.visit('/');
//Open layer manager
cy.get('.hs-sidebar-item[data-cy="layermanager"]').click();
cy.get('.hs-sidebar-item[data-cy="layerManager"]').click();
//Turn off all layers
cy.get('hs-layer-manager-layer-list li .d-flex button.hs-checkmark').each(
(button) => {
cy.wrap(button).click();
},
);
//Close layer manager
cy.get('.hs-sidebar-item[data-cy="layermanager"]:first').click();
cy.get('.hs-sidebar-item[data-cy="layerManager"]:first').click();
});

it('All panels should open', () => {
Expand Down Expand Up @@ -43,12 +43,15 @@ describe('Hslayers application', () => {
);
});

it('Only 8 sidebar panels should be visible', () => {
/**
* This changes based on current test-app config
*/
it('Only 9 sidebar panels should be visible', () => {
cy.viewport(600, 1000);
// Wait for the layout to update
cy.wait(500);
cy.get('hs-sidebar span.hs-sidebar-item:not(.hs-panel-hidden)')
.its('length')
.should('equal', 8);
.should('equal', 9);
});
});
9 changes: 5 additions & 4 deletions cypress/tests/styles.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ describe('Hslayers application', () => {
beforeEach(() => {
cy.visit('/');
//Open layer manager
cy.get('.hs-sidebar-item[data-cy="layermanager"]').click();
cy.get('.hs-sidebar-item[data-cy="layerManager"]').click();
//Turn off all layers
cy.get('hs-layer-manager-layer-list li .d-flex button.hs-checkmark').each(
(button) => {
Expand Down Expand Up @@ -51,9 +51,10 @@ describe('Hslayers application', () => {

it('Should support SLD 1.1.0', () => {
openStyler();
cy.get('hs-styles button[title="Reset to default style"]').click();
cy.get('.modal-footer > .btn-primary').click();
cy.get('hs-styles button[title="Upload style as SLD file"]').click();
cy.get('hs-panel-header .dropdown-toggle').click();
cy.get('.extra-buttons-container').should('be.visible');
cy.get('extra-buttons a:nth-child(2)').click();

cy.get('hs-styles input[type=file]').selectFile(
'cypress/fixtures/sld-1.1.0.sld',
{force: true},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</li>

<div class="extra-content d-flex position-absolute top-0">
<div #mainButtonContainer class="d-flex">
<div #mainButtonContainer class="d-flex" data-cy="mainButtonContainer">
<ng-content select="[mainButton]"></ng-content>
</div>
<div [hidden]="!hasExtraButtons()" class="btn-group" ngbDropdown placement="bottom-end" display="dynamic">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div class="card panel-default hs-main-panel hs-layermanager-card" *ngIf="isVisible$ | async"
[ngClass]="panelWidthClass">
<hs-panel-header name="layermanager" [panelTabs]="'LM'">
<hs-panel-header name="layerManager" [panelTabs]="'LM'">
<button mainButton class="btn btn-sm btn-outline-primary border-0 align-items-center d-flex gap-2"
[class.text-bg-primary]="physicalLayerListEnabled"
(click)="physicalLayerListEnabled = !physicalLayerListEnabled" [title]="'LAYERMANAGER.enablePhysicalLayerList' |
Expand Down
4 changes: 2 additions & 2 deletions projects/hslayers/components/query/query.component.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div class="card hs-main-panel" *ngIf="isVisible$ | async" [ngClass]="panelWidthClass">
<hs-panel-header name="info" [panelTabs]="'INFO'"></hs-panel-header>
<hs-panel-header name="query" [panelTabs]="'INFO'"></hs-panel-header>
<div class="card hs-main-panel" *ngIf="noFeatureSelected()">
<div class="d-flex flex-column align-items-center p-4">
<i class="icon-cursor bg-primary p-3 text-white rounded "
Expand All @@ -8,7 +8,7 @@
<p class="small">{{'QUERY.infoPanel.clickOnMap' | translateHs }}</p>
</div>
</div>
<hs-query-default-info-panel-body *ngIf="hsLayoutService.mainpanel === 'info'">
<hs-query-default-info-panel-body *ngIf="hsLayoutService.mainpanel === 'query'">
</hs-query-default-info-panel-body>
<hs-custom-info-panel-body></hs-custom-info-panel-body>
<div class="container-fluid"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div class="card panel-default hs-main-panel mainpanel hs-stc-mainpanel" *ngIf="isVisible$ | async"
[ngClass]="panelWidthClass">
<hs-panel-header name=" saveMap" [panelTabs]="'SAVECOMPOSITION'">
<hs-panel-header name="saveMap" [panelTabs]="'SAVECOMPOSITION'">
</hs-panel-header>
<div class="card-body">
<div class="form-group">
Expand Down
2 changes: 1 addition & 1 deletion projects/hslayers/components/share/share.component.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div class="card panel-default hs-main-panel" *ngIf="isVisible$ | async" [ngClass]="panelWidthClass">
<hs-panel-header name="permalink" [panelTabs]="'PERMALINK'">
<hs-panel-header name="share" [panelTabs]="'PERMALINK'">
</hs-panel-header>
<div class="card-body">
<div class="card-body">
Expand Down
3 changes: 2 additions & 1 deletion projects/hslayers/src/assets/locales/cs.json
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,8 @@
"ignoreExtentInfo": "Zobrazit prvky nebo jejich části skryté mimo původní rozsah.",
"changeLayerType": "Opravdu chcete změnit typ vrstvy?",
"layerTypeChangeNote": "Změna může ovlivnit rychlost načítání",
"confirmLayerTypeChange": "Potvrďte změnu typu vrstvy"
"confirmLayerTypeChange": "Potvrďte změnu typu vrstvy",
"styleLayer": "Upravit styl vrstvy"
},
"layerList": {
"layerIsQueryable": "Tato vrstva je dotazovatelná",
Expand Down
3 changes: 2 additions & 1 deletion projects/hslayers/src/assets/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,8 @@
"ignoreExtentInfo": "Show features or their parts hidden outside of the initial extent.",
"changeLayerType": "Do you really want to change layer type?",
"layerTypeChangeNote": "Change might affect loading performance",
"confirmLayerTypeChange": "Confirm layer type change"
"confirmLayerTypeChange": "Confirm layer type change",
"styleLayer": "Style layer"
},
"layerList": {
"layerIsQueryable": "This layer is queryable",
Expand Down
3 changes: 2 additions & 1 deletion projects/hslayers/src/assets/locales/sk.json
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,8 @@
"ignoreExtentInfo": "Zobraziť prvky alebo ich časti skryté mimo pôvodného rozsahu.",
"changeLayerType": "Naozaj chcete zmeniť typ vrstvy?",
"layerTypeChangeNote": "Zmena môže ovplyvniť rýchlosť načítania",
"confirmLayerTypeChange": "Potvrďte zmenu typu vrstvy"
"confirmLayerTypeChange": "Potvrďte zmenu typu vrstvy",
"styleLayer": "Upraviť štýl vrstvy"
},
"layerList": {
"layerIsQueryable": "Táto vrstva je dotazovateľná",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<div *ngIf="isVisible$ | async" class="card hs-main-panel" [ngClass]="panelWidthClass">
<hs-panel-header name="custom" [panelTabs]="'My Cool Panel'">
<!-- Empty string as a translationModule to overwrite default PANEL_HEADER to satisfy traslationOverrides definition
Another possiblity would be to define panelName using PANEL_HEADER obj in config -->
<hs-panel-header name="custom" [panelTabs]="'My Cool Panel'" [translationModule]="''">
</hs-panel-header>
<div class="card-body">
<div class="mx-3 my-2">
Expand Down

0 comments on commit 1c30d01

Please sign in to comment.