Skip to content

Commit ff175d6

Browse files
committed
e2e: add form filter legend panel tests (#1551)
1 parent 0ea815c commit ff175d6

2 files changed

Lines changed: 58 additions & 0 deletions

File tree

CHANGELOG-3.10.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ with some extra keywords: backend, tests, test, translation, funders, important
5050
### Tests
5151

5252
* e2e snap edition: Enhance Snap panel functionalities
53+
* e2e: form filter - test deactivate-all button and per-layer unfilter icon in legend panel (#1551)
5354

5455
### Backend
5556

tests/end2end/playwright/form-filter.spec.js

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@ import { test, expect } from '@playwright/test';
33
import { ProjectPage } from './pages/project';
44
import { getEchoRequestParams } from './globals';
55

6+
/**
7+
* Layer name as used in the treeview data-testid attribute
8+
* @type {string}
9+
*/
10+
const LAYER_NAME = 'form filter (à)';
11+
612
test.describe('Form filter', () => {
713
test.beforeEach(async ({ page }) => {
814
const project = new ProjectPage(page, 'form_filter');
@@ -100,3 +106,54 @@ test.describe('Form filter', () => {
100106
await expect(page.locator('#ui-id-2 .ui-menu-item div')).toHaveText('monuments');
101107
});
102108
});
109+
110+
test.describe('Form filter - Legend panel interactions', () => {
111+
test.beforeEach(async ({ page }) => {
112+
const project = new ProjectPage(page, 'form_filter');
113+
await project.open();
114+
// Open the form filter panel
115+
await page.locator('#button-filter').click();
116+
});
117+
118+
test('Deactivate all filters button in legend panel clears the active filter', async ({ page }) => {
119+
// Apply a filter via the form filter panel
120+
const getMapPromise = page.waitForRequest(/GetMap/);
121+
await page.locator('#liz-filter-field-test_filter').selectOption('_uvres_d_art_et_monuments_de_l_espace_urbain');
122+
await getMapPromise;
123+
124+
// The "deactivate all filters" button in the layer legend panel must be visible
125+
await expect(page.locator('#layerActionUnfilter')).toBeVisible();
126+
127+
// The layer node in the treeview must have the 'filtered' class
128+
await expect(page.getByTestId(LAYER_NAME).locator('.node')).toContainClass('filtered');
129+
130+
// Click the deactivate-all button in the legend panel
131+
const getMapAfterUnfilter = page.waitForRequest(/GetMap/);
132+
await page.locator('#layerActionUnfilter').click();
133+
await getMapAfterUnfilter;
134+
135+
// The button must be hidden and the 'filtered' class must be removed
136+
await expect(page.locator('#layerActionUnfilter')).not.toBeVisible();
137+
await expect(page.getByTestId(LAYER_NAME).locator('.node')).not.toContainClass('filtered');
138+
});
139+
140+
test('Per-layer filter icon in legend removes the filter for that layer', async ({ page }) => {
141+
// Apply a filter via the form filter panel
142+
const getMapPromise = page.waitForRequest(/GetMap/);
143+
await page.locator('#liz-filter-field-test_filter').selectOption('_uvres_d_art_et_monuments_de_l_espace_urbain');
144+
await getMapPromise;
145+
146+
// The per-layer icon-filter button must be visible inside the treeview node
147+
await expect(page.getByTestId(LAYER_NAME).locator('.icon-filter')).toBeVisible();
148+
149+
// Click the per-layer icon-filter to remove the filter for that layer only
150+
const getMapAfterUnfilter = page.waitForRequest(/GetMap/);
151+
await page.getByTestId(LAYER_NAME).locator('.icon-filter').click();
152+
await getMapAfterUnfilter;
153+
154+
// Filter must be gone: 'filtered' class removed, icon hidden, global button hidden
155+
await expect(page.getByTestId(LAYER_NAME).locator('.node')).not.toContainClass('filtered');
156+
await expect(page.getByTestId(LAYER_NAME).locator('.icon-filter')).not.toBeVisible();
157+
await expect(page.locator('#layerActionUnfilter')).not.toBeVisible();
158+
});
159+
});

0 commit comments

Comments
 (0)