Skip to content

Commit 0a9a855

Browse files
committed
test: verify snap WFS request uses WFS 1.1.0 with SRSNAME
Add a test that confirms the snapping GetFeature request is issued with VERSION=1.1.0 and an explicit SRSNAME matching the map projection, and that no DescribeFeatureType request is sent alongside it. Also remove DescribeFeatureType waits from the existing snap panel test — the new WFS 1.1.0 path bypasses getFeatureData() so no DescribeFeatureType is triggered when loading snap source features.
1 parent 503908b commit 0a9a855

File tree

1 file changed

+52
-10
lines changed

1 file changed

+52
-10
lines changed

tests/end2end/playwright/snap.spec.js

Lines changed: 52 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// @ts-check
22
import { test, expect } from '@playwright/test';
3+
import { expect as requestExpect } from './fixtures/expect-request.js'
34
import { ProjectPage } from "./pages/project";
45

56
test.describe('Snap on edition', () => {
@@ -8,14 +9,59 @@ test.describe('Snap on edition', () => {
89
await project.open();
910
});
1011

12+
test('Snap WFS GetFeature uses WFS 1.1.0 with SRSNAME in the map projection', async ({ page }) => {
13+
const project = new ProjectPage(page, 'form_edition_multilayer_snap');
14+
15+
// Intercept the snap GetFeature request before opening the form —
16+
// snapping is auto-activated on form display for this project.
17+
const snapWfsRequestPromise = page.waitForRequest(
18+
request => request.method() === 'POST'
19+
&& request.postData()?.includes('GetFeature') === true
20+
&& request.postData()?.includes('form_edition_snap_point') === true
21+
);
22+
23+
// Track whether a DescribeFeatureType is sent alongside the snap request.
24+
// With the new WFS 1.1.0 path we no longer go through getFeatureData(), so
25+
// no DescribeFeatureType should be triggered.
26+
let describeFeatureTypeSent = false;
27+
page.on('request', request => {
28+
if (
29+
request.method() === 'POST'
30+
&& request.postData()?.includes('DescribeFeatureType') === true
31+
&& request.postData()?.includes('form_edition_snap_point') === true
32+
) {
33+
describeFeatureTypeSent = true;
34+
}
35+
});
36+
37+
const formRequest = await project.openEditingFormWithLayer('form_edition_snap_control');
38+
await formRequest.response();
39+
await page.getByRole('tab', { name: 'Digitization' }).click();
40+
41+
const snapWfsRequest = await snapWfsRequestPromise;
42+
43+
// The WFS request must use version 1.1.0 with an explicit SRSNAME so that
44+
// QGIS Server reprojects features server-side instead of the client using
45+
// proj4js (which lacks datum-grid shifts and introduces ~cm coordinate drift).
46+
requestExpect(snapWfsRequest).toContainParametersInPostData({
47+
SERVICE: 'WFS',
48+
VERSION: '1.1.0',
49+
REQUEST: 'GetFeature',
50+
TYPENAME: 'form_edition_snap_point',
51+
SRSNAME: 'EPSG:4326', // the project's map projection
52+
});
53+
54+
// Allow any in-flight requests to settle before checking the flag.
55+
await page.waitForTimeout(300);
56+
expect(describeFeatureTypeSent).toBeFalsy();
57+
});
58+
1159
test('Snap panel functionalities', async ({ page }) => {
1260
const project = new ProjectPage(page, 'form_edition_multilayer_snap');
1361

14-
// Set up request watchers before opening the form, as snapping is auto-activated on form display
62+
// Set up request watcher before opening the form, as snapping is auto-activated on form display
1563
let getSnappingPointFeatureRequestPromise = page.waitForRequest(
1664
request => request.method() === 'POST' && request.postData() != null && request.postData()?.includes('GetFeature') === true && request.postData()?.includes('form_edition_snap_point') === true);
17-
let getSnappingPointDescribeFeatureRequestPromise = page.waitForRequest(
18-
request => request.method() === 'POST' && request.postData() != null && request.postData()?.includes('DescribeFeatureType') === true && request.postData()?.includes('form_edition_snap_point') === true);
1965

2066
const formRequest = await project.openEditingFormWithLayer('form_edition_snap_control');
2167
await formRequest.response();
@@ -28,7 +74,7 @@ test.describe('Snap on edition', () => {
2874
await page.getByRole('tab', { name: 'Digitization' }).click()
2975

3076
// snapping is auto-activated when snap layers are configured
31-
await Promise.all([getSnappingPointFeatureRequestPromise, getSnappingPointDescribeFeatureRequestPromise])
77+
await getSnappingPointFeatureRequestPromise;
3278

3379
// check snap panel and controls
3480
await expect(page.locator("#edition-point-coord-form-group").getByRole("button").nth(2)).toBeDisabled();
@@ -91,12 +137,10 @@ test.describe('Snap on edition', () => {
91137

92138
let getSnappingLineFeatureRequestPromise = page.waitForRequest(
93139
request => request.method() === 'POST' && request.postData() != null && request.postData()?.includes('GetFeature') === true && request.postData()?.includes('form_edition_snap_line') === true);
94-
let getSnappingLineDescribeFeatureRequestPromise = page.waitForRequest(
95-
request => request.method() === 'POST' && request.postData() != null && request.postData()?.includes('DescribeFeatureType') === true && request.postData()?.includes('form_edition_snap_line') === true);
96140

97141
await page.locator("#edition-point-coord-form-group").getByRole("button").nth(2).click()
98142

99-
await Promise.all([getSnappingLineFeatureRequestPromise, getSnappingLineDescribeFeatureRequestPromise])
143+
await getSnappingLineFeatureRequestPromise;
100144

101145
await page.waitForTimeout(300);
102146

@@ -142,12 +186,10 @@ test.describe('Snap on edition', () => {
142186

143187
let getSnappingPolygonFeatureRequestPromise = page.waitForRequest(
144188
request => request.method() === 'POST' && request.postData() != null && request.postData()?.includes('GetFeature') === true && request.postData()?.includes('form_edition_snap_polygon') === true);
145-
let getSnappingPolygonDescribeFeatureRequestPromise = page.waitForRequest(
146-
request => request.method() === 'POST' && request.postData() != null && request.postData()?.includes('DescribeFeatureType') === true && request.postData()?.includes('form_edition_snap_polygon') === true);
147189

148190
await page.locator("#edition-point-coord-form-group").getByRole("button").nth(2).click()
149191

150-
await Promise.all([getSnappingPolygonFeatureRequestPromise, getSnappingPolygonDescribeFeatureRequestPromise])
192+
await getSnappingPolygonFeatureRequestPromise;
151193

152194
await page.waitForTimeout(300);
153195

0 commit comments

Comments
 (0)