Skip to content

Commit 12572a4

Browse files
committed
update test-coverage.md with latest test additions
Added documentation for: - dedicated-servers.service (22 tests) - hasura.service (30 tests) - hasura.controller (12 tests) - match-relay.service (8 -> 52 tests) - matchmaking-lobby.service (15 -> 36 tests) Fixed coverage threshold from 40% to actual 10%.
1 parent de165c2 commit 12572a4

1 file changed

Lines changed: 54 additions & 9 deletions

File tree

test-coverage.md

Lines changed: 54 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
## Overview
44

55
- **Framework:** Jest + ts-jest
6-
- **Coverage threshold:** 40% global minimum (branches, functions, lines, statements)
6+
- **Coverage threshold:** 10% global minimum (branches, functions, lines, statements)
77
- **Test command:** `npx jest --no-cache --coverage`
88
- **E2E command:** `npx jest --config test/jest-e2e.json --no-cache`
99

@@ -106,13 +106,22 @@ Tests the core matchmaking algorithm with Elo-based team balancing and multi-reg
106106
- **addLobbyToQueue:** adds lobby to rank and queue sorted sets for each region, does not add when lobby details not found
107107
- **releaseLobbyAndRequeue:** releases lock and re-adds lobby to all regional queues
108108

109-
#### `src/matchmaking/matchmaking-lobby.service.spec.ts` — Lobby Verification (15 tests)
110-
Tests lobby verification logic including captain checks, team size validation, and player eligibility.
109+
#### `src/matchmaking/matchmaking-lobby.service.spec.ts` — Lobby Management & Verification (36 tests)
110+
Tests lobby verification, details management, queue operations, and player notifications.
111111
- **Captain check:** throws when user is not the captain, accepts when user is the captain
112112
- **Competitive team sizes:** accepts 1-5 players, accepts exactly 10 players, rejects 6-9 players
113113
- **Wingman team sizes:** accepts 1-2 players, accepts exactly 4 players, rejects 3 players
114114
- **Duel team sizes:** accepts 1 player, accepts exactly 2 players
115115
- **Player verification:** rejects banned player, rejects player with matchmaking cooldown, rejects player already in another match, rejects player already in a different queue, accepts player in same lobby
116+
- **getPlayerLobby:** returns solo player lobby when no lobby exists, returns lobby with multiple players for valid UUID, falls back to solo when lobby query returns null
117+
- **setLobbyDetails:** stores correct ELO data and avgRank in Redis, defaults ELO to 5000 for missing data, uses match type to look up correct ELO field
118+
- **removeLobbyDetails:** does nothing when details don't exist, removes details and notifies all players
119+
- **getLobbyDetails:** returns undefined when no data in Redis, returns parsed details with 1-based region positions
120+
- **setMatchConformationIdForLobby / removeConfirmationIdFromLobby:** stores and removes confirmation ID in Redis hash
121+
- **removeLobbyFromQueue:** returns false when lobby not found, removes from queue and rank sorted sets per region
122+
- **sendQueueDetailsToLobby:** returns early when details don't exist, publishes details without confirmation data
123+
- **sendQueueDetailsToAllUsers:** queries correct cache key, sends details to all lobbies
124+
- **sendQueueDetailsToPlayer:** does nothing when no queue details exist
116125

117126
#### `src/matches/match-assistant/match-assistant.service.spec.ts` — Match Assistant (16 tests)
118127
Tests match lifecycle management (scheduling, canceling, server assignment, maps).
@@ -126,6 +135,29 @@ Tests match lifecycle management (scheduling, canceling, server assignment, maps
126135
- **isDedicatedServerAvailable:** throws when match has no server
127136
- **getAvailableMaps:** filters out banned and picked maps, throws when map pool not found
128137

138+
#### `src/dedicated-servers/dedicated-servers.service.spec.ts` — Dedicated Server Management (22 tests)
139+
Tests K8s deployment lifecycle, game server configuration, RCON ping, and Redis stats.
140+
- **removeDedicatedServer:** deletes K8s deployment, cleans Redis stats, updates Hasura; swallows 404 errors; rethrows non-404 errors
141+
- **getGameType (private):** returns 0 for Ranked/Casual/Competitive/Wingman, 1 for Deathmatch/ArmsRace, 3 for Retake/Custom
142+
- **getGameMode (private):** returns 1 for Ranked/Competitive, 0 for ArmsRace/Casual/Retake/Custom, 2 for Wingman/Deathmatch
143+
- **getWarGameType (private):** returns 12 for Retake, 0 for all others
144+
- **getDedicatedServerDeploymentName (private):** returns `dedicated-server-{serverId}` format
145+
- **getAllDedicatedServerStats:** returns empty array for no data/null, parses valid server data, filters malformed JSON, returns empty on Redis error
146+
- **restartDedicatedServer:** delegates to systemService.restartDeployment with correct namespace
147+
- **pingDedicatedServer:** marks server connected when not already, stores stats in Redis with TTL, handles csgo text-based status parsing, disconnects RCON after ping
148+
149+
#### `src/hasura/hasura.service.spec.ts` — Hasura GraphQL & Migration Service (30 tests)
150+
Tests GraphQL client wrapper, secret validation, cache key helpers, SQL digest, migrations, and settings.
151+
- **PLAYER_NAME_CACHE_KEY / PLAYER_ROLE_CACHE_KEY:** correct format for string and bigint inputs
152+
- **checkSecret:** matches configured secret, rejects mismatches, handles empty strings
153+
- **calcSqlDigest:** SHA-256 for string and array inputs, consistent hashing, different inputs produce different digests
154+
- **getHasuraHeaders:** returns role/id headers, uses correct cache key with TTL
155+
- **query:** delegates to GraphQL client, extracts first error message from response errors, rethrows non-response errors
156+
- **mutation:** delegates to GraphQL client, extracts first error message, rethrows non-response errors
157+
- **getSetting:** returns hash from postgres, returns undefined when no row, wraps errors with context
158+
- **setSetting:** upserts hash via postgres, wraps errors with context
159+
- **apply:** recurses directories, skips when digest matches, applies when digest differs, applies when no prior setting exists, throws with file context on failure
160+
129161
#### `src/notifications/notifications.service.spec.ts` — Match Status Notifications (8 tests)
130162
Tests match status notification dispatch with Discord webhook support.
131163
- **Non-notifiable status:** skips statuses not in NOTIFIABLE_STATUSES
@@ -152,13 +184,19 @@ Tests system settings retrieval and updates.
152184
- **Defaults:** applies default values when missing/null
153185
- **updateDefaultOptions:** handles default_models setting changes
154186

155-
#### `src/matches/match-relay/match-relay.service.spec.ts` — Match Relay Service (8 tests)
156-
Tests match relay/broadcast service.
187+
#### `src/matches/match-relay/match-relay.service.spec.ts` — Match Relay / GOTV Broadcast Service (52 tests)
188+
Tests GOTV relay broadcast management including fragment storage, sync info, and data streaming.
157189
- **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
190+
- **getStart:** signup_fragment mismatch returns 404, gzipped start blob served with Content-Encoding header
191+
- **getFragment:** broadcast not found returns 404, fragment not found returns 404, delta field served with gzip encoding
192+
- **getSyncInfo:** broadcast not found, start with no data, start missing entirely, no sync-ready fragment returns 405, valid sync JSON without/with fragment param, clamping to signup_fragment, skipping non-sync-ready fragments, Expires header
193+
- **postField:** new broadcast creation, fragment clearing on steamId/masterCookie mismatch, start field forces fragmentIndex=0, 205 for full/delta without start, gzip success/failure paths, signup_fragment initialization, query param copying, cleanupOldFragments called after store
194+
- **isSyncReady:** validates sync readiness (requires full/delta data with ticks/timestamps), delta.tick as alternative, false for empty objects
195+
- **cleanupOldFragments:** no-op when broadcast missing, preserves fragments without timestamp, keeps recent fragments
196+
- **getMatchBroadcastEndTick:** empty map, highest endtick by descending key, skips fragments without endtick
197+
- **getLastFragment:** empty map, highest key selection, single element
198+
- **serveBlob:** undefined fragment, missing field, non-gzipped blob, gzipped blob with encoding, gipped=false omits encoding
199+
- **relayError:** X-Reason header and response end
162200

163201
---
164202

@@ -202,6 +240,13 @@ Tests authentication endpoints and session management.
202240
- **logout:** destroys session and deletes Redis latency key, handles missing session
203241
- **createApiKey:** throws BadRequestException when label is empty, returns key
204242

243+
#### `src/hasura/hasura.controller.spec.ts` — Hasura Webhook Controller (12 tests)
244+
Tests Hasura auth webhook, action dispatch, and event handling.
245+
- **hasura() GET:** returns guest headers when no user, returns user headers for authenticated user via hasuraService
246+
- **actions() POST:** successful action resolution and response, 401 for unauthorized "me" action without user, 400 on handler throw with error message, 400 with string fallback error, injects user and session into input
247+
- **events() POST:** successful event resolution, null old/new data coerced to empty objects, error logging without rethrowing
248+
- **getResolver (private):** throws on unregistered action, caches resolved handler on repeat calls
249+
205250
#### `src/system/system.controller.spec.ts` — System Controller (13 tests)
206251
Tests system controller endpoints and event handlers.
207252
- **updateServices:** delegates to system.updateServices

0 commit comments

Comments
 (0)