Repository navigation
test(bot): cover untested moderation and download commands - #1858
Conversation
Add comprehensive test coverage for high-risk moderation commands (ban, kick, mute, warn) and download command. Tests cover permission gates, user validation, DM sending, duration parsing, audit logging, error handling, and edge cases. All tests pass with green suite.
|
Warning Review limit reachedYou’ve reached a temporary PR review limit under our Fair Usage Limits Policy. Next review available in: 6 minutes Your organization has reached its usage spending cap. Adjust your spending cap in the billing tab. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (5)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
Failed to generate code suggestions for PR |
|
There was a problem hiding this comment.
All reported issues were addressed across 5 files
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
Kimi review (
|
There was a problem hiding this comment.
0 issues found across 1 file (changes from recent commits).
Auto-approved: Adds 70 tests for high-risk moderation and download commands. No source changes, only spec addition. Bounded and clearly beneficial.
Re-trigger cubic
|
## What Adds 70 tests (9 spec files) for the remaining untested general commands. Third and final coverage PR in the series (#1855 music+giveaway, #1858 moderation+download). | Command | Tests | Covers | |---------|-------|--------| | `ping` | 5 | latency calc, fetch handling, zero-latency edge | | `version` | 5 | env-var resolution, package.json + commit-SHA fallback, ephemeral | | `afk` | 10 | DM rejection, clear/set flows, error handling, logging | | `help` | 7 | embed gen, pagination, empty lists, errors | | `level` | 18 | reward add/remove, rank, leaderboard, setup config, errors | | `starboard` | 9 | setup (channel/emoji/threshold), disable, top entries, errors | | `roleconfig` | 5 | set/remove/list exclusive-role handlers, errors | | `reactionrole` | 6 | create/delete/list, guild requirement, errors | | `voterewards` | 5 | vote-info display, config, API error resilience | (`giveaway` excluded — already covered in #1855.) ## Why Closes the last known bot command coverage gap surfaced by the test-health audit — validation, config flows, guild-context gates, and error branches. ## Verification Spec-only diff (no source changed). Bot suite green: ``` Test Suites: 1 skipped, 229 passed, 229 of 230 total Tests: 1 skipped, 3019 passed, 3020 total ``` ## Series total #1855 + #1858 + this = **221 new tests**; music, giveaway, moderation, download, and general command groups now covered. <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Add tests across 9 specs to cover the remaining general commands (`ping`, `version`, `afk`, `help`, `level`, `starboard`, `roleconfig`, `reactionrole`, `voterewards`). Test-only change that closes the last coverage gap, with stronger `help` pagination (multi-page + counter), error-path logging assertions, verifies config, guild checks, embeds, failures, and mocks `global.fetch` in `voterewards` to avoid external calls. <sup>Written for commit f361b1e. Summary will update on new commits.</sup> <a href="https://cubic.dev/pr/LucasSantana-Dev/Lucky/pull/1859?utm_source=github" target="_blank" rel="noopener noreferrer" data-no-image-dialog="true"><picture><source media="(prefers-color-scheme: dark)" srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img alt="Review in cubic" src="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"></picture></a> <!-- End of auto-generated description by cubic. --> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Tests** * Added comprehensive automated coverage for AFK, help, level, ping, reaction role, role configuration, starboard, version, and vote rewards commands. * Verified command responses, validation, pagination, configuration flows, error handling, latency reporting, and fallback behavior. * Added coverage for empty states, missing guild context, service failures, and environment-based version information. <!-- end of auto-generated comment: release notes by coderabbit.ai -->



What
Adds 70 tests (5 spec files) for previously-untested HIGH-risk bot commands. Follow-up to #1855 (music+giveaway), same rigor.
moderation/commands/ban.spec.tsmoderation/commands/kick.spec.tsmoderation/commands/mute.spec.tsmoderation/commands/warn.spec.tsdownload/commands/download/command.spec.tsWhy
Moderation (ban/kick/mute/warn) and download commands had zero coverage — permission gates, target validation, and audit-log paths were unvalidated. These are destructive/sensitive flows.
Verification
Spec-only diff (no source changed). Bot suite green:
Coverage status after this + #1855
Music, giveaway, moderation, download now covered. Remaining lighter gaps: general commands (11/20) — a possible future follow-up.
Summary by cubic
Adds 70 Jest tests for high‑risk moderation commands (ban, kick, mute, warn) and the
downloadcommand; spec‑only with no source changes. Also removes an unused test import flagged by CodeQL.Coverage
videoformat, context (userId/guildId), file‑size edges (0/undefined/>1GB), ephemeral errors, and ordered replies.Refactors
Written for commit 59822e4. Summary will update on new commits.