Files
gridpilot.gg/plans/team-logos-force-reseed-fix-plan.md
2025-12-31 15:39:28 +01:00

53 lines
1.9 KiB
Markdown

# Team logos wrong after force reseed: TDD plan
## Observed runtime failure
- Browser console: Internal server error.
- Team images still not shown.
## Hypothesis
The current force-reseed cleanup in [`SeedRacingData.clearExistingRacingData()`](adapters/bootstrap/SeedRacingData.ts:479) still leaves inconsistent DB state (or errors during deletion), so seeding or the teams endpoint fails.
## Approach (TDD)
### 1) Reproduce via HTTP
- Use curl against `/teams/all` and capture:
- HTTP status
- response body
- server logs correlating to request
### 2) Capture docker logs around bootstrap
- Start/ensure dev stack is up via [`docker-compose.dev.yml`](docker-compose.dev.yml:1).
- Collect:
- API logs from container startup through seeding
- DB logs if errors/constraint violations occur
### 3) Add regression test (make it fail first)
- Add an API e2e/integration test that:
1. Runs with postgres persistence and force reseed on.
2. Calls `/teams/all`.
3. Asserts every team returns a generated logo URL:
- `logoUrl` matches `/media/teams/{id}/logo` (or resolver output for generated ref)
- must not be `/media/default/logo.png`
Candidate location: existing media module tests under [`apps/api/src/domain/media`](apps/api/src/domain/media/MediaModule.test.ts:1) or a new teams controller test.
### 4) Diagnose failing test
- If 500:
- Identify stack trace and failing query.
- Confirm whether failures occur during reseed or request handling.
- If 200 but wrong URLs:
- Query DB for `racing_teams.logoRef` and verify it is generated.
### 5) Minimal fix
Prefer fixing cleanup by:
- Deleting in correct order to satisfy FKs.
- Ensuring `racing_teams` + dependent tables are cleared.
- Avoiding partial deletes that can leave orphaned rows.
### 6) Verification
- Run eslint, tsc, tests.
- Manual verification:
- `curl http://localhost:3001/teams/all` returns `logoUrl: /media/teams/{id}/logo`.
- Requesting one returned URL is `200 OK`.