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', 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]', 'W5013364');
26 await page.click('button[type=submit]');
27 await page.waitForSelector('.container .row');
30 after(async function () {
34 it('should have header title as Eiffel Tower', async function () {
35 let page_header = await page.$eval('.container h1', el => el.textContent);
37 assert.ok(page_header.includes('Eiffel Tower'));
40 it('should have link to https://www.openstreetmap.org/way/5013364', async function () {
42 assert.strictEqual((await page.$$('a[href="https://www.openstreetmap.org/way/5013364"]')).length, 1);
45 it('should change page url and add new header on clicking display keywords', async function () {
48 let [display_keywords_btn] = await page.$x("//a[contains(text(), 'display keywords')]");
50 await display_keywords_btn.click();
51 await page.waitForNavigation();
53 current_url = new URL(await page.url());
54 assert.strictEqual(current_url.searchParams.get('keywords'), '1');
56 await page.waitForSelector('h3');
57 display_headers = await page.$$eval('h3', elements => elements.map(el => el.textContent));
58 assert.deepStrictEqual(display_headers, ['Name Keywords', 'Address Keywords']);
61 it('should change page url on clicking display child places', async function () {
63 let [child_places_btn] = await page.$x("//a[contains(text(), 'display child places')]");
65 await child_places_btn.click();
66 await page.waitForNavigation();
68 current_url = new URL(await page.url());
69 assert.strictEqual(current_url.searchParams.get('hierarchy'), '1');
72 it('should have case-insenstive input and can navigate to other details', async function () {
73 let input_field = await page.$('input[type=edit]');
74 await input_field.click({ clickCount: 3 });
75 await input_field.type('w375257537');
76 await page.click('button[type=submit]');
78 await page.waitForSelector('a[href="https://www.openstreetmap.org/way/375257537"]');
79 assert.ok((await page.$eval('.container h1', el => el.textContent)).includes('Taj Mahal'));