Refactor search route/loading
* Fetch results asynchronously after app launch * Hide sidebar and search results when new search is issued
This commit is contained in:
@@ -140,12 +140,14 @@ module('Acceptance | map search reset', function (hooks) {
|
||||
bubbles: true,
|
||||
});
|
||||
|
||||
// Wait for transition to index
|
||||
// Wait for transition or UI update
|
||||
await new Promise((r) => setTimeout(r, 500));
|
||||
assert.strictEqual(
|
||||
currentURL(),
|
||||
'/',
|
||||
'Should have transitioned to index (closed sidebar)'
|
||||
|
||||
// Sidebar should be hidden, but we should stay on the search route
|
||||
assert.dom('.sidebar').doesNotExist('Sidebar should be closed');
|
||||
assert.ok(
|
||||
currentURL().includes('category=coffee'),
|
||||
'Should have stayed on the search route with markers intact'
|
||||
);
|
||||
|
||||
// Second Click (Start new search)
|
||||
|
||||
@@ -95,8 +95,8 @@ module('Acceptance | navigation', function (hooks) {
|
||||
// Click the Close (X) button
|
||||
await click('.close-btn');
|
||||
|
||||
assert.strictEqual(currentURL(), '/', 'Returned to index');
|
||||
assert.false(mapUi.returnToSearch, 'Flag is reset after closing sidebar');
|
||||
assert.dom('.sidebar').doesNotExist('Sidebar should be closed');
|
||||
assert.ok(currentURL().includes('/place/'), 'Remains on place route');
|
||||
});
|
||||
|
||||
test('navigating directly to place and back closes sidebar', async function (assert) {
|
||||
|
||||
@@ -67,6 +67,7 @@ module('Acceptance | search loading', function (hooks) {
|
||||
);
|
||||
|
||||
await searchPromise;
|
||||
await new Promise((r) => setTimeout(r, 250));
|
||||
assert.strictEqual(
|
||||
mapUi.loadingState,
|
||||
null,
|
||||
@@ -84,6 +85,7 @@ module('Acceptance | search loading', function (hooks) {
|
||||
);
|
||||
|
||||
await catPromise;
|
||||
await new Promise((r) => setTimeout(r, 250));
|
||||
assert.strictEqual(
|
||||
mapUi.loadingState,
|
||||
null,
|
||||
|
||||
@@ -36,6 +36,8 @@ module('Unit | Route | place', function (hooks) {
|
||||
selectPlaceCalled = true;
|
||||
}
|
||||
stopSearch() {}
|
||||
showSidebar() {}
|
||||
hideSidebar() {}
|
||||
}
|
||||
|
||||
this.owner.register('service:osm', OsmStub);
|
||||
@@ -76,6 +78,8 @@ module('Unit | Route | place', function (hooks) {
|
||||
class MapUiStub extends Service {
|
||||
selectPlace() {}
|
||||
stopSearch() {}
|
||||
showSidebar() {}
|
||||
hideSidebar() {}
|
||||
}
|
||||
|
||||
this.owner.register('service:osm', OsmStub);
|
||||
@@ -110,6 +114,8 @@ module('Unit | Route | place', function (hooks) {
|
||||
class MapUiStub extends Service {
|
||||
selectPlace() {}
|
||||
stopSearch() {}
|
||||
showSidebar() {}
|
||||
hideSidebar() {}
|
||||
}
|
||||
|
||||
this.owner.register('service:osm', OsmStub);
|
||||
@@ -155,6 +161,8 @@ module('Unit | Route | place', function (hooks) {
|
||||
assert.ok(options.preventZoom, 'Prevented zoom on update');
|
||||
}
|
||||
stopSearch() {}
|
||||
showSidebar() {}
|
||||
hideSidebar() {}
|
||||
}
|
||||
|
||||
this.owner.register('service:storage', StorageStub);
|
||||
|
||||
Reference in New Issue
Block a user