Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests - Migrate overview tests #5346

Merged
merged 2 commits into from
Feb 4, 2025
Merged
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: 4 additions & 0 deletions tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,10 @@ You can then :

You can also install the handy [Playwright extension](https://marketplace.visualstudio.com/items?itemName=ms-playwright.playwright) on VSCode.

#### Writing tests

A tests doing only a **read-only** on Lizmap must be tagged as `@readonly`, otherwise, it must be tagged `@write`.

### Artifacts

When GitHub Action is failing, all screenshots and downloaded files are uploaded in an ZIP.
Expand Down
105 changes: 58 additions & 47 deletions tests/end2end/playwright/overview.spec.js
Original file line number Diff line number Diff line change
@@ -1,68 +1,79 @@
// @ts-check
import { test, expect } from '@playwright/test';
import { gotoMap } from './globals';
import { expectParametersToContain } from './globals';
import {ProjectPage} from "./pages/project";

test.describe('Overview', () => {
test('2154', async ({ page }) => {
test.describe('Overview',
{
tag: ['@readonly'],
}, () => {

test('EPSG:2154', async ({ page }) => {
const requestPromise = page.waitForRequest(/GetMap/);

const url = '/index.php/view/map/?repository=testsrepository&project=overview-2154';
await gotoMap(url, page);
const project = new ProjectPage(page, 'overview-2154');
await project.open();

const request = await requestPromise;
const requestUrl = request.url();
expect(requestUrl).toContain('SERVICE=WMS');
expect(requestUrl).toContain('VERSION=1.3.0');
expect(requestUrl).toContain('REQUEST=GetMap');
expect(requestUrl).toContain('FORMAT=image%2Fpng');
expect(requestUrl).toContain('TRANSPARENT=TRUE');
expect(requestUrl).toContain('LAYERS=Overview');
expect(requestUrl).toContain('CRS=EPSG%3A2154');
expect(requestUrl).toContain('STYLES=');
expect(requestUrl).toContain('WIDTH=232');
expect(requestUrl).toContain('HEIGHT=110');
expect(requestUrl).toContain('BBOX=758432.36%2C6273694.3%2C782221.64%2C6284973.7');
const expectedParameters = {
'SERVICE': 'WMS',
'VERSION': '1.3.0',
'REQUEST': 'GetMap',
'FORMAT': 'image/png',
'TRANSPARENT': /\b(\w*^true$\w*)\b/gmi,
'LAYERS': 'Overview',
'CRS': 'EPSG:2154',
'STYLES': '',
'WIDTH': '232',
'HEIGHT': '110',
'BBOX': /758432.36\d*,6273694.3\d*,782221.64\d*,6284973.7\d*/,
}
await expectParametersToContain('GetMap', request.url(), expectedParameters);
});

test('4326', async ({ page }) => {
test('EPSG:4326', async ({ page }) => {
const requestPromise = page.waitForRequest(/GetMap/);

const url = '/index.php/view/map/?repository=testsrepository&project=overview-4326';
await gotoMap(url, page);
const project = new ProjectPage(page, 'overview-4326');
await project.open();

const request = await requestPromise;
const requestUrl = request.url();
expect(requestUrl).toContain('SERVICE=WMS');
expect(requestUrl).toContain('VERSION=1.3.0');
expect(requestUrl).toContain('REQUEST=GetMap');
expect(requestUrl).toContain('FORMAT=image%2Fpng');
expect(requestUrl).toContain('TRANSPARENT=TRUE');
expect(requestUrl).toContain('LAYERS=overview');
expect(requestUrl).toContain('CRS=EPSG%3A4326');
expect(requestUrl).toContain('STYLES=');
expect(requestUrl).toContain('WIDTH=232');
expect(requestUrl).toContain('HEIGHT=110');
expect(requestUrl).toContain('BBOX=43.55949198040038%2C3.765259498508828%2C43.65959251444461%2C3.9763806248566715');
const expectedParameters = {
'SERVICE': 'WMS',
'VERSION': '1.3.0',
'REQUEST': 'GetMap',
'FORMAT': 'image/png',
'TRANSPARENT': /\b(\w*^true$\w*)\b/gmi,
'LAYERS': 'overview',
'CRS': 'EPSG:4326',
'STYLES': '',
'WIDTH': '232',
'HEIGHT': '110',
'BBOX': /43.559491\d*,3.765259\d*,43.659592\d*,3.976380\d*/,
}
await expectParametersToContain('GetMap', request.url(), expectedParameters);
});

test('3857', async ({ page }) => {
test('EPSG:3857', async ({ page }) => {
const requestPromise = page.waitForRequest(/GetMap/);

const url = '/index.php/view/map/?repository=testsrepository&project=overview-3857';
await gotoMap(url, page);
const project = new ProjectPage(page, 'overview-3857');
await project.open();

const request = await requestPromise;
const requestUrl = request.url();
expect(requestUrl).toContain('SERVICE=WMS');
expect(requestUrl).toContain('VERSION=1.3.0');
expect(requestUrl).toContain('REQUEST=GetMap');
expect(requestUrl).toContain('FORMAT=image%2Fpng');
expect(requestUrl).toContain('TRANSPARENT=TRUE');
expect(requestUrl).toContain('LAYERS=Overview_1');
expect(requestUrl).toContain('CRS=EPSG%3A3857');
expect(requestUrl).toContain('STYLES=');
expect(requestUrl).toContain('WIDTH=232');
expect(requestUrl).toContain('HEIGHT=110');
expect(requestUrl).toContain('BBOX=411699.3269569552%2C5396012.897530658%2C450848.7321200949%2C5414575.115495941');
const expectedParameters = {
'SERVICE': 'WMS',
'VERSION': '1.3.0',
'REQUEST': 'GetMap',
'FORMAT': 'image/png',
'TRANSPARENT': /\b(\w*^true$\w*)\b/gmi,
'LAYERS': 'Overview_1',
'CRS': 'EPSG:3857',
'STYLES': '',
'WIDTH': '232',
'HEIGHT': '110',
'BBOX': /411699.32\d*,5396012.89\d*,450848.73\d*,5414575.11\d*/,
}
await expectParametersToContain('GetMap', request.url(), expectedParameters);
});
});
54 changes: 29 additions & 25 deletions tests/end2end/playwright/permalink.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @ts-check
import { test, expect } from '@playwright/test';
import { gotoMap, reloadMap } from './globals';
import {expectParametersToContain, gotoMap, reloadMap} from './globals';

test.describe('Permalink', () => {

Expand Down Expand Up @@ -721,18 +721,20 @@ test.describe('BBox parameter', () => {
const getMapPromise = page.waitForRequest(/GetMap/);
await page.getByLabel('sousquartiers').check();
const getMapRequest = await getMapPromise;
const getMapUrl = getMapRequest.url();
expect(getMapUrl).toContain('SERVICE=WMS');
expect(getMapUrl).toContain('VERSION=1.3.0');
expect(getMapUrl).toContain('REQUEST=GetMap');
expect(getMapUrl).toContain('FORMAT=image%2Fpng');
expect(getMapUrl).toContain('TRANSPARENT=TRUE');
expect(getMapUrl).toContain('LAYERS=sousquartiers');
expect(getMapUrl).toContain('CRS=EPSG%3A2154');
expect(getMapUrl).toContain('STYLES=d%C3%A9faut');
expect(getMapUrl).toContain('WIDTH=958');
expect(getMapUrl).toContain('HEIGHT=633');
expect(getMapUrl).toMatch(/BBOX=762375.04\d+%2C6277986.97\d+%2C775048.61\d+%2C6286361.05\d+/);
const expectedParameters = {
'SERVICE': 'WMS',
'VERSION': '1.3.0',
'REQUEST': 'GetMap',
'FORMAT': /image\/png/, // "image/png; mode=8bit"
'TRANSPARENT': /\b(\w*^true$\w*)\b/gmi,
'LAYERS': 'sousquartiers',
'CRS': 'EPSG:2154',
'STYLES': 'défaut',
'WIDTH': '958',
'HEIGHT': '633',
'BBOX': /762375.04\d+,6277986.97\d+,775048.61\d+,6286361.05\d+/,
}
await expectParametersToContain('GetMap', getMapRequest.url(), expectedParameters);

// Check Permalink tool
const new_share_value = await page.locator('#input-share-permalink').inputValue();
Expand Down Expand Up @@ -768,18 +770,20 @@ test.describe('BBox parameter', () => {
const getMapPromise = page.waitForRequest(/GetMap/);
await page.getByLabel('sousquartiers').check();
const getMapRequest = await getMapPromise;
const getMapUrl = getMapRequest.url();
expect(getMapUrl).toContain('SERVICE=WMS');
expect(getMapUrl).toContain('VERSION=1.3.0');
expect(getMapUrl).toContain('REQUEST=GetMap');
expect(getMapUrl).toContain('FORMAT=image%2Fpng');
expect(getMapUrl).toContain('TRANSPARENT=TRUE');
expect(getMapUrl).toContain('LAYERS=sousquartiers');
expect(getMapUrl).toContain('CRS=EPSG%3A2154');
expect(getMapUrl).toContain('STYLES=d%C3%A9faut');
expect(getMapUrl).toContain('WIDTH=958');
expect(getMapUrl).toContain('HEIGHT=633');
expect(getMapUrl).toMatch(/BBOX=762375.04\d+%2C6277986.97\d+%2C775048.61\d+%2C6286361.05\d+/);
const expectedParameters = {
'SERVICE': 'WMS',
'VERSION': '1.3.0',
'REQUEST': 'GetMap',
'FORMAT': /image\/png/, // "image/png; mode=8bit"
'TRANSPARENT': /\b(\w*^true$\w*)\b/gmi,
'LAYERS': 'sousquartiers',
'CRS': 'EPSG:2154',
'STYLES': 'défaut',
'WIDTH': '958',
'HEIGHT': '633',
'BBOX': /762375.04\d+,6277986.97\d+,775048.61\d+,6286361.05\d+/,
}
await expectParametersToContain('GetMap', getMapRequest.url(), expectedParameters);

// Check Permalink tool
const new_share_value = await page.locator('#input-share-permalink').inputValue();
Expand Down
11 changes: 9 additions & 2 deletions tests/end2end/playwright/project_load_warning.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@
import { test, expect } from '@playwright/test';
import { ProjectPage } from './pages/project';

test.describe('Project warnings in CFG as admin', () => {
test.describe('Project warnings in CFG as admin',
{
tag: ['@readonly'],
}, () => {

test.use({ storageState: 'playwright/.auth/admin.json' });

test('Visit map with a warning', async ({ page }) => {
Expand All @@ -13,7 +17,10 @@ test.describe('Project warnings in CFG as admin', () => {

});

test.describe('Project warnings in CFG as anonymous', () => {
test.describe('Project warnings in CFG as anonymous',
{
tag: ['@readonly'],
}, () => {

test('Visit map without a warning', async ({ page }) => {
const project = new ProjectPage(page, 'project_cfg_warnings');
Expand Down
29 changes: 21 additions & 8 deletions tests/end2end/playwright/qgis-request.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@ test.describe('QGIS Requests', () => {
await gotoMap(url, page)

const single = await page.evaluate(async () => {
return await fetch("/index.php/lizmap/service?repository=testsrepository&project=layer_legends&SERVICE=WMS&VERSION=1.3.0&REQUEST=GetLegendGraphic&LAYER=layer_legend_single_symbol&STYLE=&EXCEPTIONS=application/vnd.ogc.se_inimage&FORMAT=application/json&TRANSPARENT=TRUE&DPI=96")
.then(r => r.ok ? r.json() : Promise.reject(r))
return await fetch(
"/index.php/lizmap/service?repository=testsrepository&project=layer_legends&" +
"SERVICE=WMS&VERSION=1.3.0&REQUEST=GetLegendGraphic&LAYER=layer_legend_single_symbol&STYLE=&" +
"EXCEPTIONS=application/vnd.ogc.se_inimage&FORMAT=application/json&TRANSPARENT=TRUE&DPI=96"
).then(r => r.ok ? r.json() : Promise.reject(r))
})
// check root
expect(single.nodes).toHaveLength(1)
Expand All @@ -23,8 +26,11 @@ test.describe('QGIS Requests', () => {
expect(singleNode.symbols).toBeUndefined()

const categorized = await page.evaluate(async () => {
return await fetch("/index.php/lizmap/service?repository=testsrepository&project=layer_legends&SERVICE=WMS&VERSION=1.3.0&REQUEST=GetLegendGraphic&LAYER=layer_legend_categorized&STYLE=&EXCEPTIONS=application/vnd.ogc.se_inimage&FORMAT=application/json&TRANSPARENT=TRUE&DPI=96")
.then(r => r.ok ? r.json() : Promise.reject(r))
return await fetch(
"/index.php/lizmap/service?repository=testsrepository&project=layer_legends&" +
"SERVICE=WMS&VERSION=1.3.0&REQUEST=GetLegendGraphic&LAYER=layer_legend_categorized&STYLE=&" +
"EXCEPTIONS=application/vnd.ogc.se_inimage&FORMAT=application/json&TRANSPARENT=TRUE&DPI=96"
).then(r => r.ok ? r.json() : Promise.reject(r))
})
// check root
expect(categorized.nodes).toHaveLength(1)
Expand All @@ -39,8 +45,11 @@ test.describe('QGIS Requests', () => {
expect(categorizedNode.symbols).toHaveLength(2)

const group = await page.evaluate(async () => {
return await fetch("/index.php/lizmap/service?repository=testsrepository&project=layer_legends&SERVICE=WMS&VERSION=1.3.0&REQUEST=GetLegendGraphic&LAYER=legend_option_test&STYLE=&EXCEPTIONS=application/vnd.ogc.se_inimage&FORMAT=application/json&TRANSPARENT=TRUE&DPI=96")
.then(r => r.ok ? r.json() : Promise.reject(r))
return await fetch(
"/index.php/lizmap/service?repository=testsrepository&project=layer_legends&" +
"SERVICE=WMS&VERSION=1.3.0&REQUEST=GetLegendGraphic&LAYER=legend_option_test&STYLE=" +
"&EXCEPTIONS=application/vnd.ogc.se_inimage&FORMAT=application/json&TRANSPARENT=TRUE&DPI=96"
).then(r => r.ok ? r.json() : Promise.reject(r))
})
// check root
expect(group.nodes).toHaveLength(1)
Expand All @@ -58,8 +67,12 @@ test.describe('QGIS Requests', () => {
const combined = await page.evaluate(async () => {
// To get layer_legend_single_symbol first, layer_legend_categorized second and legend_option_test third
// LAYER parameter has to be the inverse: legend_option_test,layer_legend_categorized,layer_legend_single_symbol
return await fetch("/index.php/lizmap/service?repository=testsrepository&project=layer_legends&SERVICE=WMS&VERSION=1.3.0&REQUEST=GetLegendGraphic&LAYER=legend_option_test,layer_legend_categorized,layer_legend_single_symbol&STYLE=&EXCEPTIONS=application/vnd.ogc.se_inimage&FORMAT=application/json&TRANSPARENT=TRUE&DPI=96")
.then(r => r.ok ? r.json() : Promise.reject(r))
return await fetch(
"/index.php/lizmap/service?repository=testsrepository&project=layer_legends&" +
"SERVICE=WMS&VERSION=1.3.0&REQUEST=GetLegendGraphic&" +
"LAYER=legend_option_test,layer_legend_categorized,layer_legend_single_symbol&STYLE=&" +
"EXCEPTIONS=application/vnd.ogc.se_inimage&FORMAT=application/json&TRANSPARENT=TRUE&DPI=96"
).then(r => r.ok ? r.json() : Promise.reject(r))
})
// check root
expect(combined.nodes).toHaveLength(3)
Expand Down
60 changes: 33 additions & 27 deletions tests/end2end/playwright/viewport.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @ts-check
import { test, expect } from '@playwright/test';
import { gotoMap } from './globals';
import {expectParametersToContain, gotoMap} from './globals';

test.describe('Viewport devicePixelRatio 1', () => {
test('Greater than WMS max size', async ({ page }) => {
Expand Down Expand Up @@ -206,19 +206,22 @@ test.describe('Viewport standard', () => {
await page.getByRole('button', { name: 'Zoom in' }).click();
// Check GetMap request
let getMapRequest = await getMapPromise;
let getMapUrl = getMapRequest.url();
expect(getMapUrl).toContain('SERVICE=WMS');
expect(getMapUrl).toContain('VERSION=1.3.0');
expect(getMapUrl).toContain('REQUEST=GetMap');
expect(getMapUrl).toContain('FORMAT=image%2Fpng');
expect(getMapUrl).toContain('TRANSPARENT=TRUE');
expect(getMapUrl).toContain('LAYERS=world');
expect(getMapUrl).toContain('CRS=EPSG%3A3857');
expect(getMapUrl).toContain('STYLES=d%C3%A9faut');
expect(getMapUrl).toContain('DPI=96');
expect(getMapUrl).toContain('WIDTH=958');
expect(getMapUrl).toContain('HEIGHT=633');
expect(getMapUrl).toMatch(/BBOX=-9373014.15\d+%2C-6193233.77\d+%2C9373014.15\d+%2C6193233.77\d+/);
let expectedParameters = {
'SERVICE': 'WMS',
'VERSION': '1.3.0',
'REQUEST': 'GetMap',
'FORMAT': 'image/png',
'TRANSPARENT': /\b(\w*^true$\w*)\b/gmi,
'LAYERS': 'world',
'CRS': 'EPSG:3857',
'STYLES': 'défaut',
'DPI': '96',
'WIDTH': '958',
'HEIGHT': '633',
'BBOX': /-9373014.15\d+,-6193233.77\d+,9373014.15\d+,6193233.77\d+/,
}
await expectParametersToContain('GetMap', getMapRequest.url(), expectedParameters);

// Check zoom
expect(await page.evaluate(() => lizMap.mainLizmap.map.getView().getZoom())).toBe(1);

Expand All @@ -233,19 +236,22 @@ test.describe('Viewport standard', () => {
await page.setViewportSize({ width: viewport?.height, height: viewport?.width });
// Check GetMap request
getMapRequest = await getMapPromise;
getMapUrl = getMapRequest.url();
expect(getMapUrl).toContain('SERVICE=WMS');
expect(getMapUrl).toContain('VERSION=1.3.0');
expect(getMapUrl).toContain('REQUEST=GetMap');
expect(getMapUrl).toContain('FORMAT=image%2Fpng');
expect(getMapUrl).toContain('TRANSPARENT=TRUE');
expect(getMapUrl).toContain('LAYERS=world');
expect(getMapUrl).toContain('CRS=EPSG%3A3857');
expect(getMapUrl).toContain('STYLES=d%C3%A9faut');
expect(getMapUrl).toContain('DPI=96');
expect(getMapUrl).toContain('WIDTH=716');
expect(getMapUrl).toContain('HEIGHT=909');
expect(getMapUrl).toMatch(/BBOX=-7005300.76\d+%2C-8893601.11\d+%2C7005300.76\d+%2C8893601.11\d+/);
expectedParameters = {
'SERVICE': 'WMS',
'VERSION': '1.3.0',
'REQUEST': 'GetMap',
'FORMAT': 'image/png',
'TRANSPARENT': /\b(\w*^true$\w*)\b/gmi,
'LAYERS': 'world',
'CRS': 'EPSG:3857',
'STYLES': 'défaut',
'DPI': '96',
'WIDTH': '716',
'HEIGHT': '909',
'BBOX': /-7005300.76\d+,-8893601.11\d+,7005300.76\d+,8893601.11\d+/,
}
await expectParametersToContain('GetMap', getMapRequest.url(), expectedParameters);

// Check zoom
expect(await page.evaluate(() => lizMap.mainLizmap.map.getView().getZoom())).toBe(1);

Expand Down
Loading