mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-20 18:22:25 +00:00
CCTV Street View fallback: catalog cameras only, at their catalog position, inside the Google budget
This commit is contained in:
1 parent
a33bc379cb
commit
7af0453f34
3 files changed
+46
-18
No files matched your search
@@ -528,3 +528,30 @@ test('a forwarded same-origin request reaches every CCTV route but not the Stree
|
||||
assert.equal(direct.body, 'street-view');
|
||||
assert.equal(streetViewCalls(), 1);
|
||||
});
|
||||
|
||||
test('the Street View fallback frames catalog cameras only, from the catalog position', async (t) => {
|
||||
const app = mount(t, ({ url }) =>
|
||||
url.startsWith('https://maps.googleapis.com/')
|
||||
? trackedUpstream({
|
||||
headers: { 'content-type': 'image/jpeg' },
|
||||
body: 'street-view',
|
||||
}).response
|
||||
: upstreamResponse({ status: 503 }),
|
||||
);
|
||||
process.env.GOOGLE_MAPS_SERVER_API_KEY = 'fixture-key';
|
||||
const streetView = () =>
|
||||
app.requests.filter(({ url }) =>
|
||||
url.startsWith('https://maps.googleapis.com/'),
|
||||
);
|
||||
|
||||
const unknown = await app.call('/frame/not-a-camera?lat=48.85&lon=2.29');
|
||||
assert.equal(unknown.headers['X-CCTV-Source'], 'synthetic');
|
||||
assert.deepEqual(streetView(), [], 'no Google call for an unknown id');
|
||||
|
||||
const steered = await app.call(
|
||||
`/frame/${STILL.id}?lat=48.85&lon=2.29&heading=90`,
|
||||
);
|
||||
assert.equal(steered.headers['X-CCTV-Source'], 'streetview');
|
||||
const location = new URL(streetView()[0].url).searchParams.get('location');
|
||||
assert.equal(location, `${STILL.lat},${STILL.lon}`);
|
||||
});
|
||||
Reference in new issue
Block a user