X-Git-Url: https://git.openstreetmap.org./nominatim-ui.git/blobdiff_plain/0be37383d730a360a81aad1c5e58a9e9a64a6515..7864c8d54fa686502a9898c6bffeb3160609fc01:/test/reverse.js diff --git a/test/reverse.js b/test/reverse.js index 8e02b23..5641a1a 100644 --- a/test/reverse.js +++ b/test/reverse.js @@ -1,4 +1,4 @@ -const assert = require('assert'); +import assert from 'assert'; describe('Reverse Page', function () { let page; @@ -33,4 +33,41 @@ describe('Reverse Page', function () { assert.equal(await lon_handle.evaluate(node => node.value), 5); }); }); + + describe('With search', function () { + before(async function () { + page = await browser.newPage(); + await page.goto('http://localhost:9999/reverse.html'); + await page.type('input[name=lat]', '27.1750090510034'); + await page.type('input[name=lon]', '78.04209025'); + await page.click('button[type=submit]'); + await page.waitForSelector('#searchresults'); + }); + + after(async function () { + await page.close(); + }); + + it('should return single result', async function () { + let results_count = await page.$$eval('#searchresults .result', elements => elements.length); + + assert.deepStrictEqual(results_count, 1); + }); + + it('should display a map', async function () { + await page.waitForSelector('#map'); + assert.equal((await page.$$('#map')).length, 1); + }); + + it('should redirect to details page on clicking details button', async function () { + let current_url; + let results = await page.$$('#searchresults .result a'); + + await results[0].click(); + await page.waitForSelector('table#address'); + + current_url = new URL(await page.url()); + assert.deepStrictEqual(current_url.pathname, '/details.html'); + }); + }); });