Skip to content

Commit

Permalink
Merge pull request #1163 from geoadmin/bug-PB-1246-location-search
Browse files Browse the repository at this point in the history
PB-1246 : add location search entry title to search bar when selected
  • Loading branch information
pakb authored Dec 9, 2024
2 parents 17bebc7 + cb1884b commit 403439d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/store/modules/search.store.js
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,9 @@ const actions = {

break
}
if (entry.resultType === SearchResultTypes.LOCATION) {
commit('setSearchQuery', { query: entry.sanitizedTitle.trim(), dispatcher })
}
if (state.autoSelect) {
dispatch('setAutoSelect', {
value: false,
Expand Down
9 changes: 7 additions & 2 deletions tests/cypress/tests-e2e/search/search-results.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -323,8 +323,8 @@ describe('Test the search bar result handling', () => {
cy.log('Clicking on the first entry to test handling of zoom/extent/position')
cy.get(searchbarSelector).should('have.value', 'test')
cy.get('@locationSearchResults').first().realClick()
// search bar should not take element's title as value, but stays with the user search query
cy.get(searchbarSelector).should('have.value', 'test')
// search bar should take element's title as value if it's a location
cy.get(searchbarSelector).should('have.value', 'Test location')
// checking that the view has centered on the feature
cy.readStoreValue('state.position.center').should((center) =>
checkLocation(expectedCenterDefaultProjection, center)
Expand Down Expand Up @@ -368,12 +368,17 @@ describe('Test the search bar result handling', () => {
cy.get('@locationSearchResults').should('be.visible')

cy.log('It adds a search for layers features if a visible layers is set to be searchable')
cy.get(searchbarSelector).clear()
cy.get(searchbarSelector).type('test')
cy.wait(['@search-locations', '@search-layers'])
// the layer feature category should not be present (no searchable layer added yet)
cy.get('[data-cy="search-results-featuresearch"]')
.as('layerFeatureSearchCategory')
.should('be.hidden')
// adding the layer through the search results
cy.get('@layerSearchResults').first().click()
// search bar should not take element's title as value, but stays with the user search query
cy.get(searchbarSelector).should('have.value', 'test')
// should re-run a search to include potential layer features
cy.wait(['@search-locations', '@search-layers', '@search-layer-features'])
// checking that the layer has been added to the map
Expand Down

0 comments on commit 403439d

Please sign in to comment.