Ensure map marker clicks preserve search context

Fixes the back button just closing the sidebar and clearing the whole
search after having seleted a result via map marker
This commit is contained in:
2026-03-23 16:32:49 +04:00
parent 46605dbd32
commit 818ec35071
7 changed files with 45 additions and 25 deletions

View File

@@ -64,25 +64,24 @@ module('Acceptance | navigation', function (hooks) {
this.owner.register('service:storage', MockStorageService);
});
test('navigating from search results to place and back uses history', async function (assert) {
test('navigating from search results to place and back returns to search', async function (assert) {
const mapUi = this.owner.lookup('service:map-ui');
const backStub = sinon.stub(window.history, 'back');
try {
await visit('/search?lat=1&lon=1');
assert.strictEqual(currentURL(), '/search?lat=1&lon=1');
await visit('/search?lat=1&lon=1');
assert.strictEqual(currentURL(), '/search?lat=1&lon=1');
await click('.place-item');
assert.ok(currentURL().includes('/place/'), 'Navigated to place');
assert.true(mapUi.returnToSearch, 'Flag returnToSearch is set');
await click('.place-item');
assert.ok(currentURL().includes('/place/'), 'Navigated to place');
assert.true(mapUi.returnToSearch, 'Flag returnToSearch is set');
// Click the back button in the sidebar
await click('.back-btn');
// Click the back button in the sidebar
await click('.back-btn');
assert.true(backStub.calledOnce, 'window.history.back() was called');
} finally {
backStub.restore();
}
assert.strictEqual(
currentURL(),
'/search?lat=1&lon=1',
'Returned to search results'
);
});
test('closing the sidebar resets the returnToSearch flag', async function (assert) {