File size: 2,087 Bytes
e8a6c67
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/**
 * Backend-data smoke for the four MapLibre tier sources. Verifies that
 * the FastAPI /api/layers/* endpoints respond, and prints feature counts
 * so we can tell if "synthetic-prior not rendering" is a registration
 * bug (the syn-stripe-45 image fails to load) or a data-coverage gap
 * (Prithvi water polygons only cover Hurricane Ida flooded areas, so
 * most NYC points return an empty FeatureCollection).
 *
 * Skipped automatically if the backend isn't reachable.
 */
import { test, expect } from '@playwright/test';

const POINTS = [
  { name: '80 Pioneer St (Red Hook)', lat: 40.6776, lon: -74.0096 },
  { name: 'Hollis (Queens)', lat: 40.7152, lon: -73.7569 },
  { name: 'Far Rockaway', lat: 40.6013, lon: -73.7568 }
];

test.describe('@layers backend data coverage', () => {
  for (const p of POINTS) {
    test(`feature counts at ${p.name}`, async ({ request }) => {
      const fetchFc = async (path: string) => {
        const r = await request.get(path);
        if (!r.ok()) return { features: -1 as number, status: r.status() };
        const j = await r.json();
        return { features: (j?.features?.length ?? 0) as number, status: r.status() };
      };

      const [sandy, dep, prithvi, floodnet] = await Promise.all([
        fetchFc(`/api/layers/sandy?lat=${p.lat}&lon=${p.lon}&r=1500`),
        fetchFc(`/api/layers/dep_extreme_2080?lat=${p.lat}&lon=${p.lon}&r=1500`),
        fetchFc(`/api/layers/prithvi_water?lat=${p.lat}&lon=${p.lon}&r=1500`),
        fetchFc(`/api/floodnet_near?lat=${p.lat}&lon=${p.lon}&r=1500`)
      ]);

      // eslint-disable-next-line no-console
      console.log(`[${p.name}] sandy=${sandy.features} dep=${dep.features} prithvi=${prithvi.features} floodnet=${floodnet.features}`);

      // Each endpoint should respond 200 (or be cleanly skipped on a
      // non-running backend). Coverage at any specific point is the
      // diagnostic — empty Prithvi at Red Hook is expected, not a bug.
      for (const fc of [sandy, dep, prithvi, floodnet]) {
        expect([200, -1]).toContain(fc.status);
      }
    });
  }
});