Skip to content

Commit ac8dd1d

Browse files
nanotaboadaclaude
andcommitted
fix(tests): address CodeRabbit review findings on PR #557
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 20bab63 commit ac8dd1d

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

CHANGELOG.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,11 @@ This project uses football/soccer terminology for release names:
6060

6161
- Player dataset normalised to November 2022 World Cup snapshot: Enzo Fernández (SL Benfica / Liga Portugal), Mac Allister (Brighton & Hove Albion), Messi (Paris Saint-Germain / Ligue 1), Di María `abbrPosition``RW`
6262
- Player UUIDs replaced with deterministic UUID v5 values (namespace `f201b13e-c670-473d-885d-e2be219f74c8`, formula `{firstName}-{lastName}`)
63-
- Test fixture for Create/Delete replaced: Paredes (squad 5) → Lo Celso (squad 27)
64-
- Test fixture for Update added: Emiliano Martínez (squad 23) — `firstName` `'Damián'``'Emiliano'`, `middleName` cleared
65-
- `playerStub.all` expanded to 26 players; `playerStub.update` added
63+
- Test fixtures renamed for clarity: `playerStub.nonexistent` (Lo Celso, squad 27 — not seeded, used for POST/DELETE) and `playerStub.existing` (Emiliano Martínez, squad 23 — always seeded, used for PUT)
64+
- `playerStub.all` expanded to 26 players
6665
- `PUT describe` in tests: removed `beforeEach`, added `afterEach` to restore Martínez; all tests retargeted to squad 23
6766
- `rest/players.rest` variables updated: `@newSquadNumber = 27`, `@existingSquadNumber = 23`
67+
- Docker: run `docker compose down -v` before `docker compose up` to pick up the rebuilt seeded DB from `storage/players-sqlite3.db` (see #551)
6868

6969
### Removed
7070

rest/players.rest

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ Content-Type: application/json
154154

155155
{
156156
"firstName": "Emiliano",
157+
"middleName": null,
157158
"lastName": "Martínez",
158159
"dateOfBirth": "1992-09-02T00:00:00.000Z",
159160
"squadNumber": 23,

tests/player-test.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,13 +138,13 @@ describe('Integration Tests', () => {
138138
});
139139
});
140140
describe('POST', () => {
141-
it('Request POST /players within rate limit → Response processed', async () => {
141+
it('Request POST /players within rate limit → Response status 201 Created', async () => {
142142
// Arrange
143143
const body = playerStub.nonexistent;
144144
// Act
145145
const response = await request(app).post('/players').send(body);
146146
// Assert
147-
expect([201, 409]).toContain(response.status);
147+
expect(response.status).toBe(201);
148148
});
149149
((Number.parseInt(process.env.RATE_LIMIT_MAX_STRICT || '20', 10) >= 20) ? it.skip : it)('Request POST /players exceed rate limit → Response status 429 Too Many Requests', async () => {
150150
// This test is skipped by default as it requires making 20+ requests
@@ -273,9 +273,12 @@ describe('Integration Tests', () => {
273273
});
274274
describe('PUT', () => {
275275
afterEach(async () => {
276-
await request(app)
276+
const response = await request(app)
277277
.put(`${path}/squadNumber/${playerStub.existing.squadNumber}`)
278278
.send(playerStub.findBySquadNumber(playerStub.existing.squadNumber)); // restores original seeded data
279+
if (response.status !== 204) {
280+
throw new Error(`Restore failed with status ${response.status}`);
281+
}
279282
});
280283

281284
it('Request PUT /players/squadNumber/{squadNumber} within rate limit → Response status 204 No Content', async () => {

0 commit comments

Comments
 (0)