Skip to content

Commit deb4d01

Browse files
committed
Another WIP
1 parent 8adef2a commit deb4d01

File tree

4 files changed

+35
-28
lines changed

4 files changed

+35
-28
lines changed

packages/viewer/src/store/plugins/storeSync/params/swisssearch.param.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,11 @@ const swisssearchParamConfig = new UrlParamConfig<string>({
1919
useSearchStore().setSearchQuery(urlParamValue, STORE_DISPATCHER_ROUTER_PLUGIN)
2020
}
2121
},
22-
afterSetValuesInStore: () => removeQueryParamFromHref(URL_PARAM_NAME_SWISSSEARCH),
22+
afterSetValuesInStore: () => {
23+
// Defer removal to next event loop tick to ensure all URL params are processed
24+
// and router state is stable before manually modifying the URL
25+
setTimeout(() => removeQueryParamFromHref(URL_PARAM_NAME_SWISSSEARCH), 0)
26+
},
2327
keepInUrlWhenDefault: false,
2428
valueType: String,
2529
defaultValue: '',

packages/viewer/src/store/plugins/storeSync/params/swisssearchAutoSelect.param.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ const swisssearchAutoSelectParam = new UrlParamConfig<boolean>({
2626
},
2727
afterSetValuesInStore: () => {
2828
console.log('[swisssearchAutoSelectParam] afterSetValuesInStore swisssearchAutoSelectParam')
29-
removeQueryParamFromHref(URL_PARAM_NAME)
29+
// Defer removal to next event loop tick to ensure all URL params are processed
30+
// and router state is stable before manually modifying the URL
31+
setTimeout(() => removeQueryParamFromHref(URL_PARAM_NAME), 0)
3032
},
3133
// Always return default value so this param never gets re-added to URL by storeToUrl plugin
3234
extractValueFromStore: () => false,

packages/viewer/tests/cypress/support/commands.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@ function goToView(view: 'embed' | 'map', options?: GoToViewOptions): void {
209209
routerView += '-embed'
210210
}
211211
}
212+
console.log(`[GoToMapView] Visiting /${withHash ? `#/${routerView}` : ''}${flattenedQueryParams}`)
212213
cy.visit(`/${withHash ? `#/${routerView}` : ''}${flattenedQueryParams}`, {
213214
onBeforeLoad: (win) => {
214215
// initializing the spy every time the app is loaded

packages/viewer/tests/cypress/tests-e2e/search/search-results.cy.ts

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -582,32 +582,32 @@ describe('Test the search bar result handling', () => {
582582
expect(searchStore4.query).to.eq('1530 Payerne')
583583
})
584584
cy.url().should('not.contain', 'swisssearch')
585-
// cy.url().should('not.contain', 'swisssearch_autoselect')
586-
// const acceptableDelta = 0.25
587-
588-
// cy.getPinia().then((pinia) => {
589-
// const mapStore8 = useMapStore(pinia)
590-
// const feature = mapStore8.pinnedLocation
591-
// assertDefined(feature)
592-
// expect(feature).to.be.a('array').that.is.not.empty
593-
// expect(feature.length).to.greaterThan(1)
594-
// expect(feature[0]).to.be.approximately(coordinates[0]!, acceptableDelta)
595-
// expect(feature[1]).to.be.approximately(coordinates[1]!, acceptableDelta)
596-
// })
597-
598-
// // ----------------------------------------------------------------------
599-
// cy.log('Ensuring the search dialog closes once you have selected an item')
600-
// cy.get('[data-cy="search-results-locations"] [data-cy="search-result-entry"]')
601-
// .as('locationSearchResults')
602-
// .first()
603-
// .invoke('text')
604-
// .then((text) => text.trim())
605-
// .should('contains', '1530 Payerne')
606-
607-
// cy.log('Clicking the result, will hide the dropdown of the search result')
608-
// cy.get('@locationSearchResults').should('be.visible')
609-
// cy.get('@locationSearchResults').first().click()
610-
// cy.get('@locationSearchResults').should('not.be.visible')
585+
cy.url().should('not.contain', 'swisssearch_autoselect')
586+
const acceptableDelta = 0.25
587+
588+
cy.getPinia().then((pinia) => {
589+
const mapStore8 = useMapStore(pinia)
590+
const feature = mapStore8.pinnedLocation
591+
assertDefined(feature)
592+
expect(feature).to.be.a('array').that.is.not.empty
593+
expect(feature.length).to.greaterThan(1)
594+
expect(feature[0]).to.be.approximately(coordinates[0]!, acceptableDelta)
595+
expect(feature[1]).to.be.approximately(coordinates[1]!, acceptableDelta)
596+
})
597+
598+
// ----------------------------------------------------------------------
599+
cy.log('Ensuring the search dialog closes once you have selected an item')
600+
cy.get('[data-cy="search-results-locations"] [data-cy="search-result-entry"]')
601+
.as('locationSearchResults')
602+
.first()
603+
.invoke('text')
604+
.then((text) => text.trim())
605+
.should('contains', '1530 Payerne')
606+
607+
cy.log('Clicking the result, will hide the dropdown of the search result')
608+
cy.get('@locationSearchResults').should('be.visible')
609+
cy.get('@locationSearchResults').first().click()
610+
cy.get('@locationSearchResults').should('not.be.visible')
611611
})
612612

613613
it('handle swisssearch and crosshair together correctly', () => {

0 commit comments

Comments
 (0)