From 3cac33ddb72448cf3fb629d42cbea633eb270013 Mon Sep 17 00:00:00 2001 From: Etienne Trimaille Date: Mon, 3 Feb 2025 20:09:19 +0100 Subject: [PATCH] Tests - Rewrite snapping test to by in Playwright --- tests/end2end/playwright/snap.spec.js | 53 +++++++++++++++++-- .../qgis-projects/tests/form_edition_snap.md | 17 ------ .../tests/form_edition_snap.qgs.cfg | 2 +- 3 files changed, 49 insertions(+), 23 deletions(-) delete mode 100644 tests/qgis-projects/tests/form_edition_snap.md diff --git a/tests/end2end/playwright/snap.spec.js b/tests/end2end/playwright/snap.spec.js index 1afa1c7af4..dcbb8de875 100644 --- a/tests/end2end/playwright/snap.spec.js +++ b/tests/end2end/playwright/snap.spec.js @@ -4,13 +4,10 @@ import { gotoMap } from './globals'; import {ProjectPage} from "./pages/project"; test.describe('Snap on edition', () => { - test.beforeEach(async ({ page }) => { - const url = '/index.php/view/map/?repository=testsrepository&project=form_edition_multilayer_snap'; - await gotoMap(url, page); - }); test('Snap panel functionalities', async ({ page }) => { - + const url = '/index.php/view/map/?repository=testsrepository&project=form_edition_multilayer_snap'; + await gotoMap(url, page); let editFeatureRequestPromise = page.waitForResponse(response => response.url().includes('editFeature')); const project = new ProjectPage(page, 'form_edition_multilayer_snap'); @@ -219,4 +216,50 @@ test.describe('Snap on edition', () => { await expect(page.locator("#edition-point-coord-form-group .snap-layers-list .snap-layer").nth(2).locator("label")).toHaveText("Point snap"); await expect(page.locator("#edition-point-coord-form-group .snap-layers-list .snap-layer").nth(2).locator("label")).toHaveClass("snap-disabled"); }) + + test('Snapping on points, on the map', + { + tag: ['@readonly'], + },async ({ page }) => { + const project = new ProjectPage(page, 'form_edition_snap'); + await project.open(); + + await project.openEditingFormWithLayer('form_edition_snap'); + await project.dock.getByText('Digitization').click(); + + let dftRequest = page.waitForRequest( + request => + request.method() === 'POST' && + request.postData() != null && + request.postData()?.includes('DescribeFeatureType') === true && + request.postData()?.includes('form_edition_snap_layer') === true + ); + + await project.dock.getByText('Start').click(); + + // Either we can enter manually coordinates + await project.dock.locator("#edition-point-coord-x").fill("3.910") + await project.dock.locator("#edition-point-coord-y").fill("43.6161") + + // Or we click on the map + // await project.clickOnMapLegacy(600, 250); + + await dftRequest; + await page.waitForTimeout(1000); + + await project.dock.getByRole('tab', { name: 'Form' }).click(); + await project.editingField('id').fill("90"); + + // What would be the JS API to check for the current drown geometry point, + // which should be different from 3.910 43.6161 because of the snapping + + // let gfiPromise = page.waitForRequest( + // request => request.method() === 'POST' && + // request.postData()?.includes('GetFeatureInfo') === true + // ); + // await gfiPromise; + + await dftRequest; + + }); }) diff --git a/tests/qgis-projects/tests/form_edition_snap.md b/tests/qgis-projects/tests/form_edition_snap.md deleted file mode 100644 index 3ea296fba6..0000000000 --- a/tests/qgis-projects/tests/form_edition_snap.md +++ /dev/null @@ -1,17 +0,0 @@ -# Test form with snapping while editing - -**Project : form_edition_snap** - -## Procedure - -### Creation - -* [ ] Launch edition then click `Digitization` tab and `Start` button in `Snapping` part - * [ ] When moving draw point close to features, it must jump to feature coordinates. - * [ ] Cancel edition in `Form` tab - - -### Modification - -* [ ] Click on one feature on the map then click edition (pen) on displayed popup and `Start` button in `Snapping` part - * [ ] When moving draw point close to features, it must jump to feature coordinates. diff --git a/tests/qgis-projects/tests/form_edition_snap.qgs.cfg b/tests/qgis-projects/tests/form_edition_snap.qgs.cfg index 2671403350..0290525b9d 100644 --- a/tests/qgis-projects/tests/form_edition_snap.qgs.cfg +++ b/tests/qgis-projects/tests/form_edition_snap.qgs.cfg @@ -104,7 +104,7 @@ "snap_vertices": "True", "snap_segments": "True", "snap_intersections": "True", - "snap_vertices_tolerance": 20, + "snap_vertices_tolerance": 90, "snap_segments_tolerance": 10, "snap_intersections_tolerance": 10, "provider": "postgres",