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

[Backport release_3_9] Tests - Use URLSearchParams constructor to build querystrings #5062

Merged
merged 1 commit into from
Dec 2, 2024
Merged
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
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
Loading