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 - Eiffel Tower', 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]', 'W5013364');
47 await page.click('button[type=submit]');
48 await page.waitForSelector('.container .row');
51 after(async function () {
55 it('should have header title as Eiffel Tower', async function () {
56 let page_header = await page.$eval('.container h1', el => el.textContent);
58 assert.ok(page_header.includes('Eiffel Tower'));
61 it('should have link to https://www.openstreetmap.org/way/5013364', async function () {
63 assert.strictEqual((await page.$$('a[href="https://www.openstreetmap.org/way/5013364"]')).length, 1);
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']);
82 it('should change page url on clicking display child places', async function () {
84 let [child_places_btn] = await page.$x("//a[contains(text(), 'display child places')]");
86 await child_places_btn.click();
87 await page.waitForNavigation();
89 current_url = new URL(await page.url());
90 assert.strictEqual(current_url.searchParams.get('hierarchy'), '1');
93 it('should have case-insenstive input and can navigate to other details', async function () {
94 let input_field = await page.$('input[type=edit]');
95 await input_field.click({ clickCount: 3 });
96 await input_field.type('w375257537');
97 await page.click('button[type=submit]');
99 await page.waitForSelector('a[href="https://www.openstreetmap.org/way/375257537"]');
100 assert.ok((await page.$eval('.container h1', el => el.textContent)).includes('Taj Mahal'));
104 describe('Place without name, keywords, hierarchy', function () {
105 // e.g. a numeric house number
106 before(async function () {
107 page = await browser.newPage();
108 await page.goto('http://localhost:9999/details.html?osmtype=N&osmid=946563004&keywords=1&hierarchy=1');
109 await page.waitForSelector('.container .row');
112 after(async function () {
116 it('should display No Name, no keywords, no hierarchy', async function () {
117 let page_content = await page.$eval('body', el => el.textContent);
119 assert.ok(page_content.includes('Name No Name'));
120 assert.ok(page_content.includes('Place has no keywords'));
121 assert.ok(page_content.includes('Place is not parent of other places'));