Skip to content

Commit

Permalink
Merge pull request #5058 from Gustry/url-params-constructor
Browse files Browse the repository at this point in the history
Tests - Use URLSearchParams constructor to build querystrings
  • Loading branch information
Gustry authored Dec 2, 2024
2 parents 1f99c93 + b212a64 commit 8513b32
Showing 1 changed file with 73 additions and 6 deletions.
79 changes: 73 additions & 6 deletions tests/end2end/playwright/filter-layer-by-user.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,22 @@ test.describe('Filter layer data by user - not connected', () => {
test('WMS GetFeatureInfo JSON', async ({ page }) => {

const getFeatureInfo = await page.evaluate(async () => {
return await fetch("/index.php/lizmap/service?repository=testsrepository&project=filter_layer_by_user&SERVICE=WMS&REQUEST=GetFeatureInfo&VERSION=1.3.0&CRS=EPSG%3A2154&INFO_FORMAT=application%2Fjson&QUERY_LAYERS=green_filter_layer_by_user_edition_only%2Cblue_filter_layer_by_user%2Cred_layer_with_no_filter&LAYERS=green_filter_layer_by_user_edition_only%2Cblue_filter_layer_by_user%2Cred_layer_with_no_filter&STYLE=default%2Cdefault%2Cdefault&FEATURE_COUNT=10&FILTER=green_filter_layer_by_user_edition_only:\"gid\" > 0")
const params = {
repository: "testsrepository",
project: "filter_layer_by_user",
SERVICE: "WMS",
REQUEST: "GetFeatureInfo",
VERSION: "1.3.0",
CRS: "EPSG:2154",
INFO_FORMAT: "application/json",
QUERY_LAYERS: "green_filter_layer_by_user_edition_only,blue_filter_layer_by_user,red_layer_with_no_filter",
LAYERS: "green_filter_layer_by_user_edition_only,blue_filter_layer_by_user,red_layer_with_no_filter",
STYLE: "default,default,default",
FEATURE_COUNT: "10",
FILTER: 'green_filter_layer_by_user_edition_only:"gid" > 0'
};
const query = new URLSearchParams(params);
return await fetch("/index.php/lizmap/service?" + query.toString())
.then(r => r.ok ? r.json() : Promise.reject(r))
})

Expand All @@ -42,7 +57,17 @@ test.describe('Filter layer data by user - not connected', () => {
test('WFS GetFeature', async ({ page }) => {

let getFeature = await page.evaluate(async () => {
return await fetch("/index.php/lizmap/service?repository=testsrepository&project=filter_layer_by_user&SERVICE=WFS&REQUEST=GetFeature&VERSION=1.0.0&OUTPUTFORMAT=GeoJSON&TYPENAME=blue_filter_layer_by_user")
const params = {
repository: "testsrepository",
project: "filter_layer_by_user",
SERVICE: "WFS",
REQUEST: "GetFeature",
VERSION: "1.0.0",
OUTPUTFORMAT: "GeoJSON",
TYPENAME: "blue_filter_layer_by_user"
};
const query = new URLSearchParams(params);
return await fetch("/index.php/lizmap/service?" + query.toString())
.then(r => r.ok ? r.json() : Promise.reject(r))
})

Expand Down Expand Up @@ -191,7 +216,17 @@ test.describe('Filter layer data by user - user in group a', () => {
test('WFS GetFeature', async ({ page }) => {

let getFeature = await page.evaluate(async () => {
return await fetch("/index.php/lizmap/service?repository=testsrepository&project=filter_layer_by_user&SERVICE=WFS&REQUEST=GetFeature&VERSION=1.0.0&OUTPUTFORMAT=GeoJSON&TYPENAME=blue_filter_layer_by_user")
const params = {
repository: "testsrepository",
project: "filter_layer_by_user",
SERVICE: "WFS",
REQUEST: "GetFeature",
VERSION: "1.0.0",
OUTPUTFORMAT: "GeoJSON",
TYPENAME: "blue_filter_layer_by_user"
};
const query = new URLSearchParams(params);
return await fetch("/index.php/lizmap/service?" + query.toString())
.then(r => r.ok ? r.json() : Promise.reject(r))
})

Expand All @@ -202,7 +237,18 @@ test.describe('Filter layer data by user - user in group a', () => {
expect(feature.id).not.toBeUndefined()

getFeature = await page.evaluate(async () => {
return await fetch("/index.php/lizmap/service?repository=testsrepository&project=filter_layer_by_user&SERVICE=WFS&REQUEST=GetFeature&VERSION=1.0.0&OUTPUTFORMAT=GeoJSON&TYPENAME=blue_filter_layer_by_user&EXP_Filter=%22gid%22%20=%203")
const params = {
repository: "testsrepository",
project: "filter_layer_by_user",
SERVICE: "WFS",
REQUEST: "GetFeature",
VERSION: "1.0.0",
OUTPUTFORMAT: "GeoJSON",
TYPENAME: "blue_filter_layer_by_user",
EXP_Filter: '"gid" = 3'
};
const query = new URLSearchParams(params);
return await fetch("/index.php/lizmap/service?" + query.toString())
.then(r => r.ok ? r.json() : Promise.reject(r))
})

Expand Down Expand Up @@ -355,7 +401,17 @@ test.describe('Filter layer data by user - admin', () => {
test('WFS GetFeature', async ({ page }) => {

let getFeature = await page.evaluate(async () => {
return await fetch("/index.php/lizmap/service?repository=testsrepository&project=filter_layer_by_user&SERVICE=WFS&REQUEST=GetFeature&VERSION=1.0.0&OUTPUTFORMAT=GeoJSON&TYPENAME=blue_filter_layer_by_user")
const params = {
repository: "testsrepository",
project: "filter_layer_by_user",
SERVICE: "WFS",
REQUEST: "GetFeature",
VERSION: "1.0.0",
OUTPUTFORMAT: "GeoJSON",
TYPENAME: "blue_filter_layer_by_user"
};
const query = new URLSearchParams(params);
return await fetch("/index.php/lizmap/service?" + query.toString())
.then(r => r.ok ? r.json() : Promise.reject(r))
})

Expand All @@ -366,7 +422,18 @@ test.describe('Filter layer data by user - admin', () => {
expect(feature.id).not.toBeUndefined()

getFeature = await page.evaluate(async () => {
return await fetch("/index.php/lizmap/service?repository=testsrepository&project=filter_layer_by_user&SERVICE=WFS&REQUEST=GetFeature&VERSION=1.0.0&OUTPUTFORMAT=GeoJSON&TYPENAME=blue_filter_layer_by_user&EXP_Filter=%22gid%22%20=%203")
const params = {
repository: "testsrepository",
project: "filter_layer_by_user",
SERVICE: "WFS",
REQUEST: "GetFeature",
VERSION: "1.0.0",
OUTPUTFORMAT: "GeoJSON",
TYPENAME: "blue_filter_layer_by_user",
EXP_Filter: '"gid" = 3'
};
const query = new URLSearchParams(params);
return await fetch("/index.php/lizmap/service?" + query.toString())
.then(r => r.ok ? r.json() : Promise.reject(r))
})

Expand Down

0 comments on commit 8513b32

Please sign in to comment.