Files
CA/frontend/e2e/api.spec.ts
Akiba So fc468464b2 feat: Initial CBPOA commit — 武汉儿童呼吸疾病风险评估系统
Context: Build a spatial risk assessment system correlating air quality
data with children's respiratory disease incidence across Wuhan.

Approach: FastAPI backend serving PostGIS spatial queries, React
frontend with Deck.gl maps, and a PyTorch SpatialTemporalGCN pipeline
for multi-day (1d/3d/7d) risk prediction.

Changes:
- backend/ — FastAPI API with auth (JWT), alerts, risk analysis,
  geocoded case data, grid statistics, and report endpoints
- frontend/ — React dashboard with interactive risk maps, alert
  monitoring, district comparison charts, and timeline player
- models/ — SpatialTemporalGCN model with trained weights and ONNX
  export for inference
- scripts/ — ETL pipeline for weather + medical data, grid generation,
  feature engineering, training, and daily inference
- deploy/ — Docker Compose configs for backend, frontend, and MLflow
- docs/ — API docs, deployment guide, user guide, and code review

Impact: Enables spatial risk visualization, alert monitoring, and
ML-driven health risk forecasting for environmental health teams.
2026-06-05 02:13:49 +08:00

84 lines
2.7 KiB
TypeScript

import { test, expect } from '@playwright/test';
const API_BASE = 'http://localhost:8000';
test.describe('API Endpoints', () => {
test('health check', async ({ request }) => {
const response = await request.get(`${API_BASE}/health`);
expect(response.ok()).toBeTruthy();
expect(await response.json()).toHaveProperty('status');
});
test('historical aggregation API', async ({ request }) => {
const response = await request.get(
`${API_BASE}/api/history/aggregated?start_date=2022-12-01&end_date=2022-12-31`
);
expect(response.ok()).toBeTruthy();
const data = await response.json();
expect(data).toHaveProperty('aggregations');
expect(data).toHaveProperty('total_records');
});
test('grids geojson API', async ({ request }) => {
const response = await request.get(
`${API_BASE}/api/grids/geojson?date=2022-12-15`
);
expect(response.ok()).toBeTruthy();
const data = await response.json();
expect(data).toHaveProperty('type', 'FeatureCollection');
expect(data).toHaveProperty('features');
});
test('multi-day prediction API', async ({ request }) => {
const response = await request.post(`${API_BASE}/api/predict/multi-day`, {
data: { date: '2022-12-15', days: 3 },
headers: { 'Content-Type': 'application/json' },
});
expect(response.ok()).toBeTruthy();
const data = await response.json();
expect(data).toHaveProperty('predictions');
expect(data).toHaveProperty('date_range');
});
test('grid history API', async ({ request }) => {
const response = await request.get(
`${API_BASE}/api/grids/r100_c200/history?days=7`
);
expect(response.ok()).toBeTruthy();
const data = await response.json();
expect(data).toHaveProperty('grid_id');
expect(data).toHaveProperty('history');
});
});
test.describe('Frontend Pages', () => {
test.beforeEach(async ({ page }) => {
await page.goto('http://localhost:3000');
});
test('home page loads', async ({ page }) => {
await expect(page).toHaveTitle(/CBPOA|监测|预警/);
});
test('monitoring dashboard has timeline', async ({ page }) => {
await page.goto('http://localhost:3000/monitoring');
await expect(page.locator('text=累计病例')).toBeVisible({ timeout: 10000 });
});
test('no console errors on load', async ({ page }) => {
const errors: string[] = [];
page.on('console', (msg) => {
if (msg.type() === 'error') {
errors.push(msg.text());
}
});
await page.goto('http://localhost:3000');
await page.waitForTimeout(2000);
const filteredErrors = errors.filter(
(e) => !e.includes('favicon') && !e.includes('404')
);
expect(filteredErrors).toHaveLength(0);
});
});