Skip to content

Commit 93de44b

Browse files
committed
Wip Geo test
1 parent 024286c commit 93de44b

1 file changed

Lines changed: 72 additions & 0 deletions

File tree

e2e/geographic/geocode.spec.ts

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,79 @@
11
import { test, expect } from '@playwright/test';
22
import { waitForASFAPIResponse } from 'e2e/helpers';
33

4+
const MAPBOX_API_GLOB = 'https://api.mapbox.com/geocoding/**';
5+
6+
const MOCK_RESPONSES = {
7+
Tibet: {
8+
type: 'FeatureCollection',
9+
features: [
10+
{
11+
id: 'region.tibet',
12+
type: 'Feature',
13+
place_name: 'Tibet Autonomous Region, China',
14+
geometry: { type: 'Point', coordinates: [88.0439, 31.5534] },
15+
bbox: [78.3955, 26.8562, 99.1159, 36.4833],
16+
},
17+
],
18+
},
19+
'Big Bear Lake': {
20+
type: 'FeatureCollection',
21+
features: [
22+
{
23+
id: 'place.bigbear',
24+
type: 'Feature',
25+
place_name: 'Big Bear Lake, California, United States',
26+
geometry: { type: 'Point', coordinates: [-116.9115, 34.2437] },
27+
bbox: [-116.95, 34.2, -116.87, 34.28],
28+
},
29+
],
30+
},
31+
'Sierra Le': {
32+
type: 'FeatureCollection',
33+
features: [
34+
{
35+
id: 'place.sierra1',
36+
type: 'Feature',
37+
place_name: 'Sierra Leone',
38+
geometry: { type: 'Point', coordinates: [-11.7799, 8.4606] },
39+
bbox: [-13.3, 6.9, -10.3, 10.0],
40+
},
41+
{
42+
id: 'place.sierra2',
43+
type: 'Feature',
44+
place_name:
45+
'Sierra Leone Avenue, Nassau, New Providence, Bahamas',
46+
geometry: { type: 'Point', coordinates: [-77.3788, 25.0113] },
47+
bbox: [-77.38, 25.01, -77.37, 25.02],
48+
},
49+
],
50+
},
51+
};
52+
53+
async function mockGeocoding(page: any) {
54+
await page.route(MAPBOX_API_GLOB, (route: any) => {
55+
const url = route.request().url();
56+
let response = MOCK_RESPONSES['Tibet'];
57+
58+
for (const key of Object.keys(MOCK_RESPONSES)) {
59+
if (url.includes(encodeURIComponent(key))) {
60+
response = MOCK_RESPONSES[key];
61+
break;
62+
}
63+
}
64+
65+
route.fulfill({
66+
status: 200,
67+
contentType: 'application/json',
68+
body: JSON.stringify(response),
69+
});
70+
});
71+
}
72+
473
test('Place name is geocoded to WKT AOI and returns search results', async ({
574
page,
675
}) => {
76+
await mockGeocoding(page);
777
await page.goto('/');
878
await page.getByRole('button', { name: 'Sentinel-' }).click();
979
await page.getByRole('menuitem', { name: 'S1 Burst' }).click();
@@ -35,6 +105,7 @@ test('Place name is geocoded to WKT AOI and returns search results', async ({
35105
test('Place name geocode pans the map to the entered location', async ({
36106
page,
37107
}) => {
108+
await mockGeocoding(page);
38109
await page.goto('/');
39110

40111
const aoiFilter = page.locator('app-aoi-filter');
@@ -59,6 +130,7 @@ test('Place name geocode pans the map to the entered location', async ({
59130
test('Geocoded place name is cleared when AOI is manually updated', async ({
60131
page,
61132
}) => {
133+
await mockGeocoding(page);
62134
await page.goto('/');
63135
await page.getByRole('button', { name: 'Sentinel-' }).click();
64136
await page.getByRole('menuitem', { name: 'S1 Burst' }).click();

0 commit comments

Comments
 (0)