From: marc tobias Date: Sun, 5 May 2024 13:54:29 +0000 (+0200) Subject: Search page: Set HTML page title for structured searches, too X-Git-Url: https://git.openstreetmap.org./nominatim-ui.git/commitdiff_plain/cf3e8f8daa0f2f4b014b9df6c32a436248237140 Search page: Set HTML page title for structured searches, too --- diff --git a/CHANGES.md b/CHANGES.md index e07ed24..910e011 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,7 @@ # CHANGES + * Search page: Set HTML page title for structured searches, too + * version 3.5.2 - 2024-04-05 * Detail page: Link to postcode search not includes the country code * test-suite: fix typos based on a codespell run diff --git a/src/pages/SearchPage.svelte b/src/pages/SearchPage.svelte index e80729f..24fe1d8 100644 --- a/src/pages/SearchPage.svelte +++ b/src/pages/SearchPage.svelte @@ -45,12 +45,21 @@ fetch_from_api('search', api_request_params, function (data) { results_store.set(data); - update_html_title('Result for ' + api_request_params.q); - if (anyStructuredFieldsSet) { + update_html_title('Result for ' + [ + api_request_params.street, + api_request_params.city, + api_request_params.county, + api_request_params.state, + api_request_params.country, + api_request_params.postalcode + ].filter((text) => text && text.length > 1).join(', ')); + document.querySelector(".nav-tabs a[href='#structured']").click(); document.querySelector('input[name=street]').focus(); } else { + update_html_title('Result for ' + api_request_params.q); + document.querySelector('input[name=q]').focus(); } }); diff --git a/test/search.js b/test/search.js index e87ed0e..4ea86cc 100644 --- a/test/search.js +++ b/test/search.js @@ -146,6 +146,39 @@ describe('Search Page', function () { }); }); + describe('Structured search for Paris', function () { + before(async function () { + page = await browser.newPage(); + await page.goto('http://localhost:9999/search.html'); + await page.click(".nav-link[href='#structured']"); + // await page.screenshot({ path: "./screen.png", fullPage: true }); + await page.type('input[name=city]', 'Paris'); + await page.type('input[name=country]', 'USA'); + await page.click('#structured button[type=submit]'); + await page.waitForSelector('#searchresults'); + }); + + after(async function () { + await page.close(); + }); + + it('should have a HTML page title', async function () { + assert.equal(await page.title(), 'Result for Paris, USA | Nominatim Demo'); + }); + + it('should have added search params', async function () { + let current_url = new URL(await page.url()); + assert.strictEqual(current_url.searchParams.get('q'), null); + assert.strictEqual(current_url.searchParams.get('city'), 'Paris'); + assert.strictEqual(current_url.searchParams.get('country'), 'USA'); + }); + + it('should have at least one result', async function () { + let results_count = await page.$$eval('#searchresults .result', elements => elements.length); + assert.ok(results_count > 1); + }); + }); + describe('Search for OSM URL', function () { before(async function () { page = await browser.newPage();