Repository navigation
feat(management): add test coverage for /customcommand (#823) - #928
Conversation
- 25 new tests covering all subcommands: create, edit, delete, list, info - Tests cover happy paths, error cases, and permission validation - create: duplicate check, name normalization, optional description - edit: response/description updates, missing command handling - delete: successful deletion, missing command handling - list: display all commands, empty state handling - info: detailed command info with optional fields - Error handling: service errors caught and logged gracefully Coverage increase: 2915 → 2940 tests (+25) CUSTOM_COMMANDS toggle already enabled in config
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Warning Rate limit exceeded
You’ve run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.
|
Failed to generate code suggestions for PR |
|
## Summary Added comprehensive test coverage for the `/customcommand` slash command handler, which was previously untested (374 LOC, 0 tests). The feature toggle `CUSTOM_COMMANDS` was already enabled in the codebase. ## Test Coverage 25 new tests covering: ### Create Subcommand (5 tests) - Happy path: creates command with name, response, optional description - Normalizes command name to lowercase - Rejects duplicate command names - Handles missing optional description ### Edit Subcommand (4 tests) - Edits response of existing command - Edits description of existing command - Rejects edit of non-existent command - Normalizes command name to lowercase ### Delete Subcommand (3 tests) - Deletes existing command - Rejects delete of non-existent command - Normalizes command name to lowercase ### List Subcommand (3 tests) - Lists all commands in guild - Shows empty state when no commands exist - Includes use count and description in list embed ### Info Subcommand (3 tests) - Displays detailed command info - Rejects info request for non-existent command - Includes optional fields (description, allowed roles, last used) ### Error Handling (3 tests) - Catches and logs service errors gracefully - Handles create/delete/list errors with user-friendly messages - Recovers from service failures ## Test Results - Bot test suite: 2940 tests passing (baseline 2915 → +25 new tests) - Shared test suite: 417 tests passing (pre-existing 3 failures unrelated to this change) - Coverage: All bot tests pass; no coverage drop below 65% threshold ## Files Changed - `packages/bot/src/functions/management/commands/customcommand.spec.ts` (766 new lines) ## Notes - Feature toggle `CUSTOM_COMMANDS` was already set to `enabled: true` in `packages/shared/src/config/featureToggles.ts` - Tests follow the same patterns as the recently-merged `/embed` command spec (PR #927) - Mock structure isolates command logic from service dependencies - No production code modified; tests validate existing implementation Closes #823
10 PRs accumulated since v2.13.0 (cut 2026-05-21, shipped same-day). ## Added - feat(bot): autoplay closed-loop telemetry writers (Phase B) #933 - feat(backend): /recommendations/history read path (Phase C) #935 - feat(download): cover + re-enable /download command #930 - feat(music): cover + re-enable collaborative playlist #929 - feat(management): /customcommand coverage #928 - feat(management): cover + re-enable /embed builder #927 - test(bot/recommendation): cover 4 untested handlers #926 ## Changed - refactor(bot): Cycle C closure of #889 — runtime cycles 2 to 1 #931 - refactor(bot/autoplay): Cycles A + B residuals — 4 to 2 #925 - chore(prisma): Recommendation model repurposed for telemetry #932 Roadmap status: Phase A+B+C of the autoplay recommendation roadmap shipped in this release. Phase D (session-coherence layer) gated on 7 days of production baseline -- revisit 2026-05-29. Also bundled via release-branch-autosync: fix(ci): v-prefix trivy-action tag (#934) -- unblocks production Docker image republishing.
v2.14.0 — 10 PRs since v2.13.0 (cut 2026-05-21). ## Highlights **Autoplay recommendation telemetry (3-phase roadmap, ADR \`2026-05-21-autoplay-recommendation-roadmap\`):** - Phase A (#932) — Prisma \`Recommendation\` model repurposed for closed-loop autoplay telemetry. New \`RecommendationSource\` enum, \`signals: Jsonb\`, \`discordUserId\`, aggregation index. - Phase B (#933) — non-throwing writers. Every autoplay pick writes a row; \`playerFinish\` and \`playerSkip\` flip the outcome flags using 30% / 5s thresholds (exported constants for tuning). - Phase C (#935) — read path. \`GET /api/guilds/:guildId/recommendations/history?days=<n>\` returns per-source acceptance rate + global summary aggregated over the window (default 7d, clamped [1, 30]). - **Phase D deferred.** Gated on 7 days of production baseline starting after this release deploys. If per-source acceptance \u2265 85%, Phase D becomes optional. Revisit 2026-05-29. **bot/autoplay circular-dependency closure (#889 done):** - #925 — Cycles A+B (queueMarkers, candidateContracts) — madge 4 → 2. - #931 — Cycle C (audioFeatures, vcWeights) — madge 2 → 1 (only the deferred type-only \`types/CustomClient\` cycle remains). Unblocks promoting \`madge.yml\` to a blocking CI gate. **Feature toggle re-enables (each with full test coverage):** - \`/download\` (#930), collaborative playlist (#929), \`/embed\` builder (#927). - Test-only coverage adds: \`/customcommand\` (#928), 4 recommendation handlers (#926). **Bundled via release-branch-autosync:** \`fix(ci): v-prefix trivy-action tag\` (#934) — unblocks production Docker image republishing on main. ## Verification - All 10 PRs passed CI (Quality Gates, SonarCloud, CodeQL, semgrep, knip, lint, madge, security) before merging to release/v2.14.0. - Bot suite: 3109+ tests passing across the autoplay + queue + replenisher + recommendation + trackHandlers surface. - Backend suite: 343+ integration tests passing including the new \`/recommendations/history\` route. - Shared suite: 12 new tests on \`recommendationTelemetryReadService\`. ## Deploy checklist After merge: 1. Tag \`v2.14.0\` on the merge commit. 2. Verify the Docker publish workflow succeeds on the merge commit (was the original failure mode pre-#934; now fixed). 3. Confirm homelab pulls the new images. 4. Begin 7-day baseline collection for the autoplay recommendation telemetry. ## Migrations One Prisma migration in this release: \`20260521000000_recommendation_telemetry_phase_a\`. Repurposes the unused \`recommendations\` table: - Drops \`algorithm: String\` (was scaffolded, never written by any service). - Adds \`recommendationSource\` enum + \`signals\` Jsonb + \`discordUserId\` + indexed by \`(guildId, source, createdAt)\`. - \`confidence\` made nullable. Safe to deploy: no production rows exist in the table prior to this release. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added recommendation history endpoint to retrieve past recommendations and acceptance rates by source * Telemetry recording now tracks recommendation outcomes (accepted/rejected) based on listening behavior * New feature toggles for Embed Builder and Collaborative Playlist support * **Chores** * Bumped all package versions to 2.14.0 * Updated database schema to support recommendation source tracking and telemetry * **Tests** * Added comprehensive test coverage for download and autoplay features, collaborative playlist, and recommendation handlers <!-- review_stack_entry_start --> [](https://app.coderabbit.ai/change-stack/LucasSantana-Dev/Lucky/pull/936?utm_source=github_walkthrough&utm_medium=github&utm_campaign=change_stack) <!-- review_stack_entry_end --> <!-- end of auto-generated comment: release notes by coderabbit.ai -->



Summary
Added comprehensive test coverage for the
/customcommandslash command handler, which was previously untested (374 LOC, 0 tests). The feature toggleCUSTOM_COMMANDSwas already enabled in the codebase.Test Coverage
25 new tests covering:
Create Subcommand (5 tests)
Edit Subcommand (4 tests)
Delete Subcommand (3 tests)
List Subcommand (3 tests)
Info Subcommand (3 tests)
Error Handling (3 tests)
Test Results
Files Changed
packages/bot/src/functions/management/commands/customcommand.spec.ts(766 new lines)Notes
CUSTOM_COMMANDSwas already set toenabled: trueinpackages/shared/src/config/featureToggles.ts/embedcommand spec (PR feat(management): cover and re-enable /embed builder (#824) #927)Closes #823