mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-15 15:52:21 +00:00
Street Level: a geocoder that throws fails show_street_level at its location stage
A provider that threw while geocoding (offline, an upstream down) escaped
the action as a bare error. show_street_level now reports it as its
location stage ("Could not arrive at …", the cause in detail), and nothing
is switched or looked up; fly_to_location itself is unchanged.
This commit is contained in:
1 parent
8334262109
commit
a8970c1f18
2 files changed
+41
-13
No files matched your search
+22
-13
@@ -3961,19 +3961,28 @@ async function requestStreetLevel(
|
|||||||
if (atViewCentre || (args.fly === false && hasCoordinates)) {
|
if (atViewCentre || (args.fly === false && hasCoordinates)) {
|
||||||
if (hasCoordinates) point = { lat: latitude, lon: longitude };
|
if (hasCoordinates) point = { lat: latitude, lon: longitude };
|
||||||
} else {
|
} else {
|
||||||
location = await runGevAction(
|
try {
|
||||||
'fly_to_location',
|
location = await runGevAction(
|
||||||
{
|
'fly_to_location',
|
||||||
...(entity
|
{
|
||||||
? { entity }
|
...(entity
|
||||||
: hasCoordinates
|
? { entity }
|
||||||
? { latitude, longitude }
|
: hasCoordinates
|
||||||
: { query }),
|
? { latitude, longitude }
|
||||||
viewMode: 'close',
|
: { query }),
|
||||||
waitForArrival: true,
|
viewMode: 'close',
|
||||||
},
|
waitForArrival: true,
|
||||||
runOptions,
|
},
|
||||||
);
|
runOptions,
|
||||||
|
);
|
||||||
|
} catch (error) {
|
||||||
|
// A geocoder that throws (offline, a provider down) is this stage's
|
||||||
|
// failure too, not an error past the action.
|
||||||
|
return fail('location', `Could not arrive at ${label}`, {
|
||||||
|
cancelled: !current(),
|
||||||
|
detail: String(error?.message || error),
|
||||||
|
});
|
||||||
|
}
|
||||||
if (location?.ok !== true || !current())
|
if (location?.ok !== true || !current())
|
||||||
return fail(
|
return fail(
|
||||||
'location',
|
'location',
|
||||||
|
|||||||
@@ -7005,6 +7005,25 @@ test('show_street_level tells a failed enable, a delisted source, a key refused
|
|||||||
assert.deepEqual(unconfigured.order, [], 'nothing changed');
|
assert.deepEqual(unconfigured.order, [], 'nothing changed');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('show_street_level reports a geocoder that throws as its location stage', async () => {
|
||||||
|
globalThis.window = globalThis.window || { clearTimeout, setTimeout, requestIdleCallback: null };
|
||||||
|
const h = createStreetLevelHarness({ enabled: true, activeStack: 'osm' });
|
||||||
|
const runner = createGevActionRunner({
|
||||||
|
viewer: createVoiceNavigationHarness().viewer,
|
||||||
|
styleManager: { mapStackController: { getActiveId: () => 'osm' }, setMapStack: async () => ({ ok: true }) },
|
||||||
|
dataManager: h.dataManager,
|
||||||
|
placeSearch: {
|
||||||
|
geocode: async () => {
|
||||||
|
throw new Error('geocoder unreachable');
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
const result = await runner('show_street_level', { query: 'Capitol Mall', provider: 'mapillary' });
|
||||||
|
assert.deepEqual([result.ok, result.stage], [false, 'location']);
|
||||||
|
assert.equal(result.error, 'Could not arrive at Capitol Mall');
|
||||||
|
assert.deepEqual(h.order.filter((step) => /^(params|open|arm)/.test(step)), [], 'nothing switched or looked up');
|
||||||
|
});
|
||||||
|
|
||||||
test('show_street_level reports a flight that lands without a position', async () => {
|
test('show_street_level reports a flight that lands without a position', async () => {
|
||||||
globalThis.window = globalThis.window || { clearTimeout, setTimeout, requestIdleCallback: null };
|
globalThis.window = globalThis.window || { clearTimeout, setTimeout, requestIdleCallback: null };
|
||||||
const hit = createStreetLevelHarness({ enabled: true, activeStack: 'osm' });
|
const hit = createStreetLevelHarness({ enabled: true, activeStack: 'osm' });
|
||||||
|
|||||||
Reference in new issue
Block a user