-
-
Notifications
You must be signed in to change notification settings - Fork 143
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tests e2e Playwright: Added Location seach
Testing that search is well activated.
- Loading branch information
1 parent
1d1bc30
commit f9e241d
Showing
1 changed file
with
106 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
// @ts-check | ||
import { test, expect } from '@playwright/test'; | ||
import { gotoMap } from './globals'; | ||
|
||
test.describe('Location search', () => { | ||
|
||
test('Default', async ({ page }) => { | ||
const url = '/index.php/view/map?repository=testsrepository&project=location_search'; | ||
await gotoMap(url, page, true, 0, false); | ||
|
||
await expect(page.getByPlaceholder('Search')).toHaveCount(1); | ||
|
||
await page.getByPlaceholder('Search').click(); | ||
await page.getByPlaceholder('Search').fill('arceaux'); | ||
|
||
let ignPromise = page.waitForRequest(/data.geopf.fr/); | ||
|
||
await page.getByPlaceholder('Search').press('Enter'); | ||
await ignPromise; | ||
|
||
await expect(page.getByText('IGN', { exact: true })).toHaveCount(1); | ||
await expect(page.getByText('Map data', { exact: true })).toHaveCount(1); | ||
|
||
await page.getByPlaceholder('Search').click(); | ||
await page.getByPlaceholder('Search').fill('mosson'); | ||
|
||
let searchPromise = page.waitForRequest(/searchFts/); | ||
await page.getByPlaceholder('Search').press('Enter'); | ||
await searchPromise; | ||
|
||
await expect(page.getByText('IGN', { exact: true })).toHaveCount(1); | ||
await expect(page.getByText('Map data', { exact: true })).toHaveCount(0); | ||
await expect(page.getByText('Quartier', { exact: true })).toHaveCount(1); | ||
}); | ||
|
||
test('Only IGN', async ({ page }) => { | ||
await page.route('**/service/getProjectConfig*', async route => { | ||
const response = await route.fetch(); | ||
const json = await response.json(); | ||
json.options['searches'] = [ | ||
{ | ||
"type": "externalSearch", | ||
"service": "ign" | ||
} | ||
]; | ||
await route.fulfill({ response, json }); | ||
}); | ||
|
||
const url = '/index.php/view/map?repository=testsrepository&project=location_search'; | ||
await gotoMap(url, page, true, 0, false); | ||
await expect(page.getByPlaceholder('Search')).toHaveCount(1); | ||
|
||
await page.getByPlaceholder('Search').click(); | ||
await page.getByPlaceholder('Search').fill('arceaux'); | ||
|
||
let ignPromise = page.waitForRequest(/data.geopf.fr/); | ||
|
||
await page.getByPlaceholder('Search').press('Enter'); | ||
await ignPromise; | ||
|
||
await expect(page.getByText('IGN', { exact: true })).toHaveCount(1); | ||
await expect(page.getByText('Map data', { exact: true })).toHaveCount(0); | ||
}); | ||
|
||
test('Only Fts', async ({ page }) => { | ||
await page.route('**/service/getProjectConfig*', async route => { | ||
const response = await route.fetch(); | ||
const json = await response.json(); | ||
json.options['searches'] = [ | ||
{ | ||
"type": "Fts", | ||
"service": "lizmapFts", | ||
"url": "/index.php/lizmap/searchFts/get" | ||
} | ||
]; | ||
await route.fulfill({ response, json }); | ||
}); | ||
|
||
const url = '/index.php/view/map?repository=testsrepository&project=location_search'; | ||
await gotoMap(url, page, true, 0, false); | ||
|
||
await expect(page.getByPlaceholder('Search')).toHaveCount(1); | ||
|
||
await page.getByPlaceholder('Search').click(); | ||
await page.getByPlaceholder('Search').fill('arceaux'); | ||
|
||
let searchPromise = page.waitForRequest(/searchFts/); | ||
|
||
await page.getByPlaceholder('Search').press('Enter'); | ||
await searchPromise; | ||
|
||
await expect(page.getByText('IGN', { exact: true })).toHaveCount(0); | ||
await expect(page.getByText('Map data', { exact: true })).toHaveCount(1); | ||
|
||
await page.getByPlaceholder('Search').click(); | ||
await page.getByPlaceholder('Search').fill('mosson'); | ||
|
||
searchPromise = page.waitForRequest(/searchFts/); | ||
await page.getByPlaceholder('Search').press('Enter'); | ||
await searchPromise; | ||
|
||
await expect(page.getByText('Map data', { exact: true })).toHaveCount(0); | ||
await expect(page.getByText('Quartier', { exact: true })).toHaveCount(1); | ||
}); | ||
|
||
}); |