Skip to content

test(bot): add handler coverage for audit and member events - #384

Merged
LucasSantana-Dev merged 1 commit into
mainfrom
test/handler-coverage
Mar 30, 2026
Merged

LucasSantana-Dev merged 1 commit into
mainfrom
test/handler-coverage

Conversation

@LucasSantana-Dev

@LucasSantana-Dev LucasSantana-Dev commented Mar 30, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • Add comprehensive test suite for auditHandler.ts (26 tests, 77.4% coverage)
  • Add comprehensive test suite for memberHandler.ts (21 tests, 95.8% coverage)
  • Test all event handlers: message delete/update, ban/unban, channel create/delete, member join/leave
  • Cover error handling branches and edge cases

Test Coverage

  • auditHandler.ts: 77.4% line coverage (26 tests)
    • Message delete/update events
    • Ban/unban events with audit log integration
    • Channel create/delete events
    • Error handling in all event wrappers
  • memberHandler.ts: 95.8% line coverage (21 tests)
    • Member join events with welcome messages
    • Member leave events with leave messages
    • Channel fallback logic (specified → system → first text)
    • Embed and text message variants
    • Error conditions

Testing Patterns

  • Jest 30 mock patterns with proper Discord.js interaction mocks
  • Service layer mocking for autoMessageService and featureToggleService
  • Audit log mocking with first() method
  • Channel cache mocking with custom find() implementation

Generated with Claude Code

Summary by CodeRabbit

  • Tests
    • Added comprehensive test coverage for audit event handling, including message operations, guild bans, and channel management.
    • Added comprehensive test coverage for member event handling, including welcome and farewell messaging functionality.

@vercel

vercel Bot commented Mar 30, 2026 •

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
lucky Ready Ready Preview, Comment Mar 30, 2026 7:50pm

Request Review

@coderabbitai

coderabbitai Bot commented Mar 30, 2026 •

Copy link
Copy Markdown

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: c31a002b-a089-475d-b0c9-ec336c43efce

📥 Commits

Reviewing files that changed from the base of the PR and between 53c6663 and a90e02f.

📒 Files selected for processing (2)
  • packages/bot/src/handlers/auditHandler.spec.ts
  • packages/bot/src/handlers/memberHandler.spec.ts

📝 Walkthrough

Walkthrough

Added two comprehensive Jest test suites for Discord event handlers: auditHandler.spec.ts testing audit log event handlers (MessageDelete, MessageUpdate, GuildBanAdd, GuildBanRemove, ChannelCreate, ChannelDelete), and memberHandler.spec.ts testing member event handlers (GuildMemberAdd, GuildMemberRemove). Both suites mock dependencies and validate conditional logging behavior, error handling, and payload structure.

Changes

Cohort / File(s) Summary
Handler Test Suites
packages/bot/src/handlers/auditHandler.spec.ts, packages/bot/src/handlers/memberHandler.spec.ts
Added comprehensive Jest test suites for audit and member event handlers, including mocked dependencies, event handler registration verification, conditional logic validation (feature toggles, channel/guild presence), payload structure assertions, placeholder replacement verification, error handling paths, and edge case coverage.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested labels

size/l

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch test/handler-coverage

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
15.5% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

@LucasSantana-Dev
LucasSantana-Dev merged commit 356c451 into main Mar 30, 2026
10 of 12 checks passed
@coderabbitai coderabbitai Bot added the size/l label Mar 30, 2026
@sonarqubecloud

Copy link
Copy Markdown

This branch was successfully deployed

1 active deployment
Preview — a90e02fe Deployed Mar 30, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant