]> git.openstreetmap.org Git - nominatim-ui.git/blob - test/search.js
testcase that search result displays API and debug link (#134)
[nominatim-ui.git] / test / search.js
1 const assert = require('assert');
2
3 describe('Search Page', function () {
4   let page;
5
6   describe('No search', function () {
7     before(async function () {
8       page = await browser.newPage();
9       await page.goto('http://localhost:9999/search.html');
10     });
11
12     after(async function () {
13       await page.close();
14     });
15
16     it('should have a HTML page title', async function () {
17       assert.equal(await page.title(), 'Nominatim Demo');
18     });
19   });
20
21   describe('Search for City of London', function () {
22     before(async function () {
23       page = await browser.newPage();
24       await page.goto('http://localhost:9999/search.html');
25       await page.type('input[name=q]', 'City of London');
26       await page.click('button[type=submit]');
27       await page.waitForSelector('#searchresults');
28       // await page.screenshot({ path: "./screen.png", fullPage: true });
29     });
30
31     after(async function () {
32       await page.close();
33     });
34
35     it('should have a HTML page title', async function () {
36       assert.equal(await page.title(), 'Result for City of London | Nominatim Demo');
37     });
38
39     it('should display the API request and debug URL', async function () {
40       let link_titles = await page.$$eval('#api-request a', links => links.map(l => l.innerHTML));
41       assert.deepEqual(link_titles, ['API request', 'debug output']);
42     });
43
44     it('should display a map', async function () {
45       await page.waitForSelector('#map');
46       assert.equal((await page.$$('#map')).length, 1);
47     });
48   });
49 });