1 const assert = require('assert');
3 describe('Details Page', function () {
6 describe('No search', function () {
7 before(async function () {
8 page = await browser.newPage();
9 await page.goto('http://localhost:9999/details.html');
12 after(async function () {
16 it('should have a HTML page title', async function () {
17 assert.equal(await page.title(), 'Nominatim Demo');
21 describe('With search - no place found', function () {
22 before(async function () {
23 page = await browser.newPage();
24 await page.goto('http://localhost:9999/details.html');
25 await page.type('input[type=edit]', 'n3');
26 await page.click('button[type=submit]');
27 await page.waitForSelector('#api-request');
31 it('should display error', async function () {
32 let page_content = await page.$eval('body', el => el.textContent);
34 assert.ok(page_content.includes('No place with that OSM ID found'));
37 after(async function () {
42 describe('With search - Vaduz (Liechtenstein)', function () {
43 before(async function () {
44 page = await browser.newPage();
45 await page.goto('http://localhost:9999/details.html');
46 await page.type('input[type=edit]', 'R1155956');
47 await page.click('button[type=submit]');
48 await page.waitForSelector('table#address');
51 after(async function () {
55 it('should have header title', async function () {
56 let page_header = await page.$eval('.container h1', el => el.textContent);
58 assert.ok(page_header.includes('Vaduz'));
61 it('should have OSM link', async function () {
63 assert.strictEqual((await page.$$('a[href="https://www.openstreetmap.org/relation/1155956"]')).length, 2);
66 it('should change page url and add new header on clicking display keywords', async function () {
69 let [display_keywords_btn] = await page.$x("//a[contains(text(), 'display keywords')]");
71 await display_keywords_btn.click();
72 await page.waitForNavigation();
74 current_url = new URL(await page.url());
75 assert.strictEqual(current_url.searchParams.get('keywords'), '1');
77 await page.waitForSelector('h3');
78 display_headers = await page.$$eval('h3', elements => elements.map(el => el.textContent));
79 assert.deepStrictEqual(display_headers, ['Name Keywords', 'Address Keywords']);
81 let page_content = await page.$eval('body', el => el.textContent);
82 assert.ok(page_content.includes('qwaansshe')); // one of the name keywords
85 it('should change page url on clicking display child places', async function () {
87 let [child_places_btn] = await page.$x("//a[contains(text(), 'display child places')]");
89 await child_places_btn.click();
90 await page.waitForNavigation();
91 await page.waitForSelector('table#address');
93 current_url = new URL(await page.url());
94 assert.strictEqual(current_url.searchParams.get('hierarchy'), '1');
96 let page_content = await page.$eval('body', el => el.textContent);
97 assert.ok(page_content.includes('Alte Landstrasse')); // one of the streets
100 it('should support case-insenstive search, can navigate to new page', async function () {
101 let input_field = await page.$('input[type=edit]');
102 await input_field.click({ clickCount: 3 });
103 await input_field.type('w375257537');
104 await page.click('button[type=submit]');
106 await page.waitForSelector('a[href="https://www.openstreetmap.org/way/375257537"]');
107 assert.ok((await page.$eval('.container h1', el => el.textContent)).includes('Taj Mahal'));
111 describe('Place without name, keywords, hierarchy', function () {
112 // e.g. a numeric house number
113 before(async function () {
114 page = await browser.newPage();
115 await page.goto('http://localhost:9999/details.html?osmtype=N&osmid=946563004&keywords=1&hierarchy=1');
116 await page.waitForSelector('.container .row');
119 after(async function () {
123 it('should display No Name, no keywords, no hierarchy', async function () {
124 let page_content = await page.$eval('body', el => el.textContent);
126 assert.ok(page_content.includes('Name No Name'));
127 assert.ok(page_content.includes('Place has no keywords'));
128 assert.ok(page_content.includes('Place is not parent of other places'));