Skip to content

Commit a5c2375

Browse files
committed
update test-coverage.md with all new test additions
1 parent 551d531 commit a5c2375

1 file changed

Lines changed: 218 additions & 15 deletions

File tree

test-coverage.md

Lines changed: 218 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
### Utility Functions
1515

16-
#### `src/utilities/is-role-above.spec.ts` — Role Hierarchy (4 tests)
16+
#### `src/utilities/isRoleAbove.spec.ts` — Role Hierarchy (4 tests)
1717
Tests the `isRoleAbove` utility that compares user role precedence.
1818
- Correctly identifies when a role is above another
1919
- Correctly identifies when a role is not above another
@@ -56,6 +56,24 @@ Tests cookie option generation for different environments.
5656
- Returns correct path
5757
- Handles missing environment variables
5858

59+
#### `src/matchmaking/utilities/cacheKeys.spec.ts` — Matchmaking Cache Keys (7 tests)
60+
Tests cache key generation functions for matchmaking queues, lobby details, confirmations, and ranks.
61+
- Validates correct formatting with regions/types
62+
- Ensures different inputs produce different keys
63+
- Verifies queue/rank keys differ for same input
64+
65+
#### `src/discord-bot/utilities/getDiscordDisplayName.spec.ts` — Discord Display Name (2 tests)
66+
Tests display name resolution for Discord users.
67+
- Prefers globalName when available
68+
- Falls back to username when globalName is empty
69+
70+
#### `src/notifications/utilities/constants.spec.ts` — Notification Constants (8 tests)
71+
Tests notification constant definitions.
72+
- STATUS_LABELS have human-readable labels
73+
- STATUS_COLORS map to valid Discord hex colors
74+
- DISCORD_COLORS define specific green/red/gray values
75+
- NOTIFIABLE_STATUSES includes/excludes correct match statuses
76+
5977
---
6078

6179
### Services
@@ -98,7 +116,7 @@ Tests pre-match lobby lifecycle from creation to launch.
98116
- **Lobby dissolution:** cleans up on cancel or timeout
99117
- **Notifications:** sends correct events to lobby members
100118

101-
#### `src/matches/match-assistant.service.spec.ts` — Match Assistant (14 tests)
119+
#### `src/matches/match-assistant/match-assistant.service.spec.ts` — Match Assistant (14 tests)
102120
Tests match lifecycle management (scheduling, canceling, server assignment).
103121
- **Match creation:** validates required fields
104122
- **Server assignment:** assigns available game servers
@@ -116,12 +134,31 @@ Tests the notification dispatch system across channels.
116134
- **Preferences:** respects user notification preferences
117135
- **Error handling:** handles delivery failures gracefully
118136

119-
#### `src/notifications/notification.constants.spec.ts` — Notification Constants (8 tests)
120-
Tests notification type definitions and template mappings.
121-
- All notification types have corresponding templates
122-
- Template keys are unique
123-
- Channel mappings are valid
124-
- Priority levels are correctly assigned
137+
#### `src/encryption/encryption.service.spec.ts` — Encryption Service (3 tests)
138+
Tests the encryption service decrypt functionality.
139+
- Strips hex string prefix from Hasura format
140+
- Passes correct openpgp parameters
141+
- Logs error on decryption failure
142+
143+
#### `src/rcon/rcon.service.spec.ts` — RCON Service (12 tests)
144+
Tests RCON service parsing and locking.
145+
- **Cvar parsing:** handles various output formats (headers, empty lines, noisy status)
146+
- **Disconnect:** cleans up connections
147+
- **Lock methods:** Redis-based lock acquisition/release for cvars and prefixes
148+
149+
#### `src/system/system.service.spec.ts` — System Settings Service (10 tests)
150+
Tests system settings retrieval and updates.
151+
- **getSetting:** returns database values with type conversion (string/boolean/number)
152+
- **Defaults:** applies default values when missing/null
153+
- **updateDefaultOptions:** handles default_models setting changes
154+
155+
#### `src/matches/match-relay/match-relay.service.spec.ts` — Match Relay Service (8 tests)
156+
Tests match relay/broadcast service.
157+
- **removeBroadcast:** removes broadcast data
158+
- **getStart:** serves start fragment with 404 handling
159+
- **getFragment:** retrieves broadcast fragments
160+
- **isSyncReady:** validates sync readiness (requires full/delta data with ticks/timestamps)
161+
- **cleanupOldFragments:** cleans old fragments while preserving index 0
125162

126163
---
127164

@@ -136,6 +173,133 @@ Tests HTTP request handling for match operations.
136173
- **Error responses:** returns correct HTTP status codes
137174
- **Server lookup:** handles server assignment endpoints
138175

176+
#### `src/tournaments/tournaments.controller.spec.ts` — Tournament Controller (9 tests)
177+
Tests tournament deletion and cleanup operations.
178+
- Throws when tournament not found
179+
- Throws when not the organizer
180+
- Throws when tournament is Live
181+
- Cleans up demo files from S3 and deletes matches
182+
- Handles individual demo cleanup failures gracefully
183+
- Handles empty tournament with no stages
184+
- Handles bracket with no match
185+
186+
#### `src/auth/auth.controller.spec.ts` — Auth Controller (7 tests)
187+
Tests authentication endpoints and session management.
188+
- **me:** returns user with cached name and role
189+
- **unlinkDiscord:** removes discord_id via Hasura mutation, clears from session
190+
- **logout:** destroys session and deletes Redis latency key, handles missing session
191+
- **createApiKey:** throws BadRequestException when label is empty, returns key
192+
193+
#### `src/system/system.controller.spec.ts` — System Controller (11 tests)
194+
Tests system controller endpoints and event handlers.
195+
- **updateServices:** delegates service updates
196+
- **restartService:** delegates service restarts
197+
- **registerName:** handles player name registration
198+
- **approveNameChange:** approves player name changes
199+
- **requestNameChange:** validates name change requests
200+
- **settings event:** handles demo network limiters and chat TTL
201+
202+
---
203+
204+
### Gateways
205+
206+
#### `src/rcon/rcon.gateway.spec.ts` — RCON Gateway (9 tests)
207+
Tests gateway authorization and RCON event handling.
208+
- **Role-based access:** denies user/verified_user/streamer, allows administrator
209+
- **Organizer access:** checks for active matches
210+
- **No active match:** handles access when no match is active
211+
- **Connection failure:** handles RCON connection failures
212+
213+
#### `src/matches/match-events.gateway.spec.ts` — Match Events Gateway (5 tests)
214+
Tests match events gateway authentication and event processing.
215+
- **handleConnection:** validates Basic auth credentials against database
216+
- **handleMatchEvent:** detects duplicate events via cache, resolves and invokes event processors
217+
218+
---
219+
220+
### Match Event Processors
221+
222+
#### `src/matches/events/AssistEvent.spec.ts` — Assist Event (1 test)
223+
- Inserts assist with correct fields
224+
225+
#### `src/matches/events/FlashEvent.spec.ts` — Flash Event (1 test)
226+
- Inserts flash with duration and team_flash flag
227+
228+
#### `src/matches/events/ObjectiveEvent.spec.ts` — Objective Event (1 test)
229+
- Inserts objective with player_steam_id, type, and round
230+
231+
#### `src/matches/events/UtilityEvent.spec.ts` — Utility Event (1 test)
232+
- Inserts utility with type and attacker coordinates
233+
234+
#### `src/matches/events/KillEvent.spec.ts` — Kill Event (2 tests)
235+
- Inserts kill with full attacker data when attacker_steam_id is present
236+
- Falls back to attacked_steam_id as attacker for self-damage
237+
238+
#### `src/matches/events/DamageEvent.spec.ts` — Damage Event (2 tests)
239+
- Inserts damage with attacker data when attacker_steam_id is present
240+
- Omits attacker fields when attacker_steam_id is falsy
241+
242+
#### `src/matches/events/ScoreEvent.spec.ts` — Score/Round Event (3 tests)
243+
- Calls cleanupData before inserting round
244+
- Inserts round with upsert on_conflict
245+
- Cleanup deletes soft-deleted records filtering by match_map_id
246+
247+
#### `src/matches/events/MatchMapStatusEvent.spec.ts` — Match Map Status Event (7 tests)
248+
- Returns early when match has no current_match_map_id
249+
- Updates match map status
250+
- Includes/excludes winning_lineup_id based on presence
251+
- Sends pause notification when status is Paused
252+
- Calls sendServerMatchId when map finished but more maps remain
253+
- Does not send pause notification for non-Paused status
254+
255+
#### `src/matches/events/MatchForfeited.spec.ts` — Match Forfeited Event (1 test)
256+
- Sets match status to Forfeit with winning_lineup_id
257+
258+
#### `src/matches/events/MatchSurrendered.spec.ts` — Match Surrendered Event (2 tests)
259+
- Sets match status to Surrendered with winning_lineup_id
260+
- Logs error and does not throw on mutation failure
261+
262+
#### `src/matches/events/MatchAbandoned.spec.ts` — Match Abandoned Event (1 test)
263+
- Inserts abandoned_matches record with steam_id
264+
265+
#### `src/matches/events/PlayerConnected.spec.ts` — Player Connected Event (2 tests)
266+
- Upserts player with on_conflict update name
267+
- Joins chat lobby via game
268+
269+
#### `src/matches/events/MatchMapResetRoundEvent.spec.ts` — Match Map Reset Round Event (5 tests)
270+
- Clears deleted_at on stats tables for rounds > target
271+
- Sets deleted_at on stats tables for rounds > target
272+
- Clears/sets deleted_at on match_map_rounds
273+
- Restores timeout availability from target round
274+
- Calls matchAssistant.restoreMatchRound
275+
276+
#### `src/matches/events/TechTimeout.spec.ts` — Tech Timeout Event (1 test)
277+
- Updates match map timeout availability for both lineups
278+
279+
#### `src/matches/events/PlayerDisconnected.spec.ts` — Player Disconnected Event (1 test)
280+
- Calls chat.leaveLobbyViaGame with matchId and steam_id
281+
282+
#### `src/matches/events/ChatMessageEvent.spec.ts` — Chat Message Event (2 tests)
283+
- Queries player and sends chat message when player found
284+
- Logs warning and returns early when player not found
285+
286+
#### `src/matches/events/CaptainEvent.spec.ts` — Captain Event (4 tests)
287+
- Finds player by steam_id and updates captain
288+
- Finds player by player.name prefix and updates captain via discord_id
289+
- Finds player by placeholder_name prefix and updates captain via discord_id
290+
- Returns early when player not found in lineups
291+
292+
#### `src/matches/events/KnifeSwitch.spec.ts` — Knife Switch Event (2 tests)
293+
- Swaps lineup sides on current map
294+
- Calls matchAssistant.knifeSwitch after mutation
295+
296+
#### `src/matches/events/MatchUpdatedLineupsEvent.spec.ts` — Match Updated Lineups Event (5 tests)
297+
- Skips players with steam_id '0'
298+
- Upserts each valid player via insert_players_one
299+
- Returns early without lineup changes when player count < expected
300+
- Removes non-participating players from lineups
301+
- Inserts only new players not already on lineup
302+
139303
---
140304

141305
### Jobs (BullMQ Processors)
@@ -164,13 +328,52 @@ Tests the job that transitions tournaments to Live status.
164328
- Validates tournament has required minimum teams
165329
- Sends notification on tournament start
166330

167-
---
168-
169-
### Stub Tests (30 files)
170-
171-
The following service/controller spec files contain only the default NestJS "should be defined" test. They verify that dependency injection wiring is correct but do not test business logic:
172-
173-
`analytics.service`, `application.service`, `commander.service`, `debug.service`, `discord.service`, `elo.service`, `encounters.service`, `game-server-node.service`, `hasura-actions.controller`, `hasura-events.controller`, `hasura-metadata.service`, `hasura.controller`, `inventory.service`, `lineup.service`, `map-bans.service`, `map-pool.service`, `match-making-global-ban.service`, `match-webhook.controller`, `match-webhook.service`, `players.service`, `readiness.service`, `region.service`, `server.service`, `steam.service`, `streams.service`, `tournament-match-lineup.service`, `tournament.controller`, `tournament.service`, `typesense.service`, `workshop-maps.service`
331+
#### `src/matches/jobs/CleanAbandonedMatches.spec.ts` — Abandoned Match Cleanup (3 tests)
332+
Tests the scheduled job that cleans up abandoned matches.
333+
- Deletes abandoned matches older than 1 week
334+
- Logs when rows are affected
335+
- Returns 0 and does not log when nothing to clean
336+
337+
#### `src/matches/jobs/CancelInvalidTournaments.spec.ts` — Invalid Tournament Cancellation (3 tests)
338+
Tests the job that cancels tournaments without minimum teams.
339+
- Cancels tournaments without min teams past start date
340+
- Logs count when tournaments are cancelled
341+
- Returns 0 and does not log when none found
342+
343+
#### `src/matches/jobs/CheckForScheduledMatches.spec.ts` — Scheduled Match Check-In (3 tests)
344+
Tests the job that transitions scheduled matches to check-in.
345+
- Transitions Scheduled matches to WaitingForCheckIn within 15 min window
346+
- Logs count when matches are transitioned
347+
- Returns 0 and does not log when none found
348+
349+
#### `src/matches/jobs/RemoveCancelledMatches.spec.ts` — Cancelled Match Removal (5 tests)
350+
Tests cleanup of cancelled non-tournament matches.
351+
- Queries cancelled non-tournament matches
352+
- Deletes S3 demo files and demo records for each match map
353+
- Deletes match records after demo cleanup
354+
- Logs count when matches removed
355+
- Returns 0 when no cancelled matches found
356+
357+
#### `src/matches/jobs/StopOnDemandServer.spec.ts` — Stop On-Demand Server (1 test)
358+
- Delegates to matchAssistant.stopOnDemandServer with matchId
359+
360+
#### `src/matches/jobs/CheckOnDemandServerJob.spec.ts` — Check On-Demand Server (2 tests)
361+
- Throws when on-demand server is not running
362+
- Updates Discord overview when server is running
363+
364+
#### `src/matchmaking/jobs/CancelMatchMaking.spec.ts` — Cancel Matchmaking (2 tests)
365+
Tests matchmaking cancellation job.
366+
- Calls cancelMatchMaking with confirmationId from job data
367+
- Passes through different confirmationIds
368+
369+
#### `src/matchmaking/jobs/MarkPlayerOffline.spec.ts` — Mark Player Offline (3 tests)
370+
Tests the job that handles player disconnection from matchmaking.
371+
- Deletes lobby_players with Accepted status for the steamId
372+
- Removes lobby from queue and details when player has a lobby
373+
- Does not call removeLobbyFromQueue when player has no lobby
374+
375+
#### `src/system/jobs/CheckSystemUpdateJob.spec.ts` — System Update Check (1 test)
376+
- Calls system.setVersions during execution
174377

175378
---
176379

0 commit comments

Comments
 (0)