1.9 KiB
1.9 KiB
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() 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/alland 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. - 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:
- Runs with postgres persistence and force reseed on.
- Calls
/teams/all. - Asserts every team returns a generated logo URL:
logoUrlmatches/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 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.logoRefand verify it is generated.
- Query DB for
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/allreturnslogoUrl: /media/teams/{id}/logo.- Requesting one returned URL is
200 OK.