Skip to content

[#777] Add Unit Tests for Discord Service#781

Merged
Mosas2000 merged 1 commit into
StellaBridge:mainfrom
ToryMic:fix/777-add-unit-tests-for-discord-service
Jun 29, 2026
Merged

[#777] Add Unit Tests for Discord Service#781
Mosas2000 merged 1 commit into
StellaBridge:mainfrom
ToryMic:fix/777-add-unit-tests-for-discord-service

Conversation

@ToryMic

@ToryMic ToryMic commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds a comprehensive unit test suite for DiscordService (backend/tests/services/discord.service.test.ts).

Test Coverage — 45 tests, all passing ✅

Suite Tests
Service Lifecycle 6 — constructor, start(), stop(), event handlers
subscribeToAlerts 3 — DB insert shape, defaults, in-memory map
unsubscribeFromAlerts 2 — DB update, map removal
sendAlert 6 — routing, multi-channel, null channel, per-failure resilience, severity filter
Alert Embed Creation 4 — colour per severity, metadata fields, key formatting
Permission Checking 3 — null member, granted, denied
Slash Command Handlers 10 — all 6 commands × happy + error paths
Slash Command Registration 3 — count, names, execute functions present
getActiveSubscriptions 3 — DB query shape, JSON_CONTAINS filter, row mapping
Error Handling 3 — partial failure, error logging, start() rejection

Approach

  • discord.js fully mocked — no real Discord connections
  • Database mocked via the existing getDatabase() pattern used across the test suite
  • Config and logger mocked consistently with other service tests
  • All async paths (success + failure) covered

Closes #777

Add comprehensive unit test suite for the DiscordService covering:
- Service lifecycle (start, stop, constructor)
- subscribeToAlerts: DB insert, defaults, in-memory map
- unsubscribeFromAlerts: DB update, map removal
- sendAlert: channel routing, severity filtering, multi-channel, error resilience
- Alert embed creation: colours per severity, metadata fields, formatting
- Permission checking: ManageChannels enforcement
- All 6 slash command handlers: /status, /asset, /bridge, /pool, /subscribe, /unsubscribe
- Slash command registration: count, names, execute functions
- getActiveSubscriptions: DB query shape, JSON_CONTAINS filter, row mapping
- Error handling: partial failures, logging, start() rejection

Closes StellaBridge#777
@drips-wave

drips-wave Bot commented Jun 28, 2026

Copy link
Copy Markdown

@ToryMic Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@Mosas2000 Mosas2000 merged commit c43478e into StellaBridge:main Jun 29, 2026
16 of 18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Unit Tests for Discord Service

3 participants