PR Checks / Frontend Typecheck + Tests (pull_request) Successful in 1m11s
PR Checks / Backend Smoke (pull_request) Successful in 9s
PR Checks / Build Backend (no push) (pull_request) Successful in 18s
PR Checks / Build Frontend (no push) (pull_request) Successful in 1m18s
PR Checks / Build Pipeline (no push) (pull_request) Successful in 11s
PR Checks / AI Code Review (Claude) (pull_request) Successful in 1m2s
`backend/migration.py` and `scripts/migrate_csv_to_db.py` import `School`, `SchoolResult`, `init_db` and `set_db_schema_version` — names that no longer exist. `scripts/geocode_schools.py` imports the same removed ORM model. None of the three can be imported against the current backend, so they were not dormant utilities anyone could fall back on; they were files that would fail on the first line. `backend/version.py` existed only to hand `SCHEMA_VERSION` to that importer, and the FastAPI lifespan performs no version-triggered import. Three symbols go with them, each confirmed to have no caller: the unvectorised `haversine_distance`, superseded by the inline NumPy calculation in search; `fetcher`, an SWR helper for a dependency this project does not install; and `kmToMiles`. `calculateDistance` stays — CutoffMapPanel uses it. Two comments pointed at `migrate_csv_to_db.py --drop` to explain why Payload owns its own schema. The reason survives the script: blog content must stay clear of the school marts and Airflow's metadata. Reworded rather than deleted, so the constraint keeps its justification. docs/LEGACY_CODE.md records what was removed and where to find it in history. It also records what was deliberately *not* removed, which is the more useful half: unused UI components awaiting a design decision, manual data utilities whose operators a repository search cannot see, and fallbacks that look obsolete but are load-bearing — `data_loader.py`'s older-mart branches, the generated GIAS dictionary copies, and the `legacy`-named dbt models that annual DAG selectors explicitly include. A zero-import count is evidence, not a verdict. The scripts that fetch DfE CSVs are marked historical and kept, pending confirmation that nobody runs them by hand. Checked: 190 backend tests, 429 frontend tests, `tsc --noEmit` clean. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016y2J6bs8gbuSJbH18w7Tan
45 lines
1.6 KiB
TypeScript
45 lines
1.6 KiB
TypeScript
/**
|
|
* Guards the one thing about Payload's mounting that fails silently.
|
|
*
|
|
* payload.config.ts itself cannot be imported here — Payload is ESM-only and
|
|
* next/jest will not transform it — so this asserts the shared constants and
|
|
* that the config actually wires them in, by reading its source. The live
|
|
* proof that /api still reaches FastAPI is the e2e journeys, which call
|
|
* /api/schools against the running app.
|
|
*/
|
|
import fs from 'fs';
|
|
import path from 'path';
|
|
import { PAYLOAD_API_ROUTE, PAYLOAD_ADMIN_ROUTE } from '@/lib/payloadRoutes';
|
|
|
|
const CONFIG = fs.readFileSync(
|
|
path.join(__dirname, '..', '..', 'payload.config.ts'),
|
|
'utf8',
|
|
);
|
|
|
|
describe('payload mount points', () => {
|
|
it('serves the CMS API from /cms-api, never /api', () => {
|
|
// /api is the FastAPI proxy's catch-all. Payload's default would be
|
|
// swallowed by it and forwarded to the backend, silently.
|
|
expect(PAYLOAD_API_ROUTE).toBe('/cms-api');
|
|
expect(PAYLOAD_API_ROUTE).not.toBe('/api');
|
|
});
|
|
|
|
it('serves the admin panel from /admin', () => {
|
|
expect(PAYLOAD_ADMIN_ROUTE).toBe('/admin');
|
|
});
|
|
|
|
it('wires both constants into the Payload config', () => {
|
|
expect(CONFIG).toContain('PAYLOAD_API_ROUTE');
|
|
expect(CONFIG).toContain('PAYLOAD_ADMIN_ROUTE');
|
|
});
|
|
|
|
it('never hardcodes a routes block that could drift from the constants', () => {
|
|
expect(CONFIG).not.toMatch(/routes:\s*\{[^}]*api:\s*['"]/);
|
|
});
|
|
|
|
it('isolates CMS tables in their own postgres schema', () => {
|
|
// Blog content must stay separate from school marts and Airflow metadata.
|
|
expect(CONFIG).toMatch(/schemaName:\s*['"]payload['"]/);
|
|
});
|
|
});
|