X-Git-Url: https://git.openstreetmap.org./nominatim-ui.git/blobdiff_plain/23d68e84c00ba741a29e4e088ef12aa7b23e045c..b663bdadf4374b4b660755401bf16f66e4c464b5:/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'); + }); + }); });