1 import { test, expect } from './shared.js';
3 const reverse_only = !!process.env.REVERSE_ONLY;
5 test.describe('Details Page', () => {
7 test.describe('No search', () => {
10 test.beforeAll(async ({ browser }) => {
11 page = await browser.newPage();
12 await page.goto('/details.html');
15 test.afterAll(async () => {
19 test('should have a HTML page title', async () => {
20 expect(await page.title()).toBe('Nominatim Demo');
24 test.describe('With search - no place found', () => {
27 test.beforeAll(async ({ browser }) => {
28 page = await browser.newPage();
29 await page.goto('/details.html');
30 await page.locator('input[type=edit]').fill('N6');
31 await page.locator('button[type=submit]').click();
32 await page.locator('#api-request').waitFor();
35 test.afterAll(async () => {
39 test('should display error', async () => {
40 await expect(page.locator('body')).toContainText(
41 'No place with that OSM ID found'
46 test.describe('With search - Vaduz (Liechtenstein)', () => {
49 test.beforeAll(async ({ browser }) => {
50 page = await browser.newPage();
51 await page.goto('/details.html');
52 await page.locator('input[type=edit]').fill('R1155956');
53 await page.locator('button[type=submit]').click();
54 await page.locator('table#address').waitFor();
57 test.afterAll(async () => {
61 test('should have header title', async () => {
62 await expect(page.locator('.container h1')).toContainText('Vaduz');
65 test('should have OSM link', async () => {
66 const url = 'https://www.openstreetmap.org/relation/1155956';
67 await expect(page.locator(`a[href="${url}"]`)).toHaveCount(2);
70 // Reverse-only installation have no search index, therefore no keywords
73 test('should have a link to postcode which includes country code',
75 const url = 'search.html?postalcode=9490&country=li';
76 await expect(page.locator(`a[href="${url}"]`)).toHaveCount(1);
80 test('should change url and add new header on clicking display keywords',
82 await page.locator('a', { hasText: 'display keywords' }).click();
83 await page.waitForURL(/keywords=1/);
85 const current_url = new URL(page.url());
86 expect(current_url.searchParams.get('keywords')).toBe('1');
88 await page.locator('h3').first().waitFor();
89 const display_headers = await page.locator('h3').evaluateAll(
90 elements => elements.map(el => el.textContent)
92 expect(display_headers).toEqual(
93 ['Name Keywords', 'Address Keywords']
96 await expect(page.locator('body')).toContainText('vadouz');
101 test('should support case-insensitive search, can navigate to new page',
103 await page.locator('input[type=edit]').fill('w375257537');
104 await page.locator('button[type=submit]').click();
107 'a[href="https://www.openstreetmap.org/way/375257537"]'
109 await expect(page.locator('.container h1')).toContainText('Taj Mahal');
115 'With street search - a place that is parent of buildings',
119 test.beforeAll(async ({ browser }) => {
120 page = await browser.newPage();
122 '/details.html?osmtype=W&osmid=32703083'
124 await page.locator('.container .row').first().waitFor();
127 test.afterAll(async () => {
131 test('should change page url on clicking display child places',
133 await expect(page.locator('body')).toContainText('Gafleistrasse');
136 'a', { hasText: 'display child places' }
138 await page.waitForURL(/hierarchy=1/);
139 await page.locator('table#address').waitFor();
141 const current_url = new URL(page.url());
142 expect(current_url.searchParams.get('hierarchy')).toBe('1');
144 await expect(page.locator('body')).toContainText('bus_stop');
150 test.describe('Place without name, keywords, hierarchy', () => {
153 // e.g. a numeric house number
154 test.beforeAll(async ({ browser }) => {
155 page = await browser.newPage();
157 '/details.html?osmtype=N&osmid=946563004&keywords=1&hierarchy=1'
159 await page.locator('.container .row').first().waitFor();
162 test.afterAll(async () => {
166 test('should display No Name, no keywords, no hierarchy', async () => {
167 await expect(page.locator('body')).toContainText('NameNo Name');
168 if (!process.env.REVERSE_ONLY) {
169 await expect(page.locator('body')).toContainText(
170 'Place has no keywords'
173 await expect(page.locator('body')).toContainText(
174 'Place is not parent of other places'