1 import assert from 'assert';
3 const reverse_only = !!process.env.REVERSE_ONLY;
5 describe('Details Page', function () {
8 describe('No search', function () {
9 before(async function () {
10 page = await browser.newPage();
11 await page.goto('http://localhost:9999/details.html');
14 after(async function () {
18 it('should have a HTML page title', async function () {
19 assert.equal(await page.title(), 'Nominatim Demo');
23 describe('With search - no place found', function () {
24 before(async function () {
25 page = await browser.newPage();
26 await page.goto('http://localhost:9999/details.html');
27 await page.type('input[type=edit]', 'N6');
28 await page.click('button[type=submit]');
29 await page.waitForSelector('#api-request');
33 it('should display error', async function () {
34 let page_content = await page.$eval('body', el => el.textContent);
36 assert.ok(page_content.includes('No place with that OSM ID found'));
39 after(async function () {
44 describe('With search - Vaduz (Liechtenstein)', function () {
45 before(async function () {
46 page = await browser.newPage();
47 await page.goto('http://localhost:9999/details.html');
48 await page.type('input[type=edit]', 'R1155956');
49 await page.click('button[type=submit]');
50 await page.waitForSelector('table#address');
53 after(async function () {
57 it('should have header title', async function () {
58 let page_header = await page.$eval('.container h1', el => el.textContent);
60 assert.ok(page_header.includes('Vaduz'));
63 it('should have OSM link', async function () {
64 const url = 'https://www.openstreetmap.org/relation/1155956';
66 assert.strictEqual((await page.$$eval(`a[href="${url}"]`, (links) => links.length)), 2);
69 // Reverse-only installation have no search index, therefore no keywords
71 it('should change url and add new header on clicking display keywords', async function () {
74 let [display_keywords_btn] = await page.$$(
75 "xpath/.//a[contains(text(), 'display keywords')]"
78 await display_keywords_btn.evaluate(node => node.click());
79 await page.waitForNavigation();
81 current_url = new URL(await page.url());
82 assert.strictEqual(current_url.searchParams.get('keywords'), '1');
84 await page.waitForSelector('h3');
85 display_headers = await page.$$eval('h3', elements => elements.map(el => el.textContent));
86 assert.deepStrictEqual(display_headers, ['Name Keywords', 'Address Keywords']);
88 let page_content = await page.$eval('body', el => el.textContent);
89 assert.ok(page_content.includes('vadouz')); // one of the name keywords
94 it('should support case-insensitive search, can navigate to new page', async function () {
95 let input_field = await page.$('input[type=edit]');
96 await input_field.click({ clickCount: 3 });
97 await input_field.type('w375257537');
98 await page.click('button[type=submit]');
100 await page.waitForSelector('a[href="https://www.openstreetmap.org/way/375257537"]');
101 assert.ok((await page.$eval('.container h1', el => el.textContent)).includes('Taj Mahal'));
105 describe('With street search - a place that is parent of buildings', function () {
106 before(async function () {
107 page = await browser.newPage();
108 await page.goto('http://localhost:9999/details.html?osmtype=W&osmid=32703083');
109 await page.waitForSelector('.container .row');
112 after(async function () {
116 it('should change page url on clicking display child places', async function () {
117 let page_content = await page.$eval('body', el => el.textContent);
118 assert.ok(page_content.includes('Gafleistrasse'));
121 let [child_places_btn] = await page.$$(
122 "xpath/.//a[contains(text(), 'display child places')]"
125 await child_places_btn.evaluate(node => node.click());
126 await page.waitForNavigation();
127 await page.waitForSelector('table#address');
129 current_url = new URL(await page.url());
130 assert.strictEqual(current_url.searchParams.get('hierarchy'), '1');
132 page_content = await page.$eval('body', el => el.textContent);
133 assert.ok(page_content.includes('bus_stop')); // parent of several bus stops
137 describe('Place without name, keywords, hierarchy', function () {
138 // e.g. a numeric house number
139 before(async function () {
140 page = await browser.newPage();
141 await page.goto('http://localhost:9999/details.html?osmtype=N&osmid=946563004&keywords=1&hierarchy=1');
142 await page.waitForSelector('.container .row');
145 after(async function () {
149 it('should display No Name, no keywords, no hierarchy', async function () {
150 let page_content = await page.$eval('body', el => el.textContent);
152 assert.ok(page_content.includes('Name No Name'));
153 if (!process.env.REVERSE_ONLY) {
154 assert.ok(page_content.includes('Place has no keywords'));
156 assert.ok(page_content.includes('Place is not parent of other places'));