Repository navigation
test(bot): cover untested general commands - #1859
Conversation
📝 WalkthroughWalkthroughAdds Jest test suites for eight general bot commands. The tests mock command dependencies and verify normal execution, guild validation, service delegation, reply payloads, pagination, environment fallbacks, logging, and error handling. ChangesGeneral command test coverage
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
|
Failed to generate code suggestions for PR |
|
There was a problem hiding this comment.
Actionable comments posted: 6
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/bot/src/functions/general/commands/help.spec.ts`:
- Around line 118-131: Update the “catches errors and replies with error
message” test to force an exception through a dependency used by
helpCommand.execute, such as making interaction.user.displayAvatarURL() throw,
instead of relying on an empty command map or null client.user. Keep the
assertion focused on the error response returned by handleHelpError.
- Around line 93-116: Strengthen the pagination tests in
packages/bot/src/functions/general/commands/help.spec.ts lines 93-116 by
generating enough command fields or characters to require multiple embeds and
asserting interactionReply is called more than once. In
packages/bot/src/functions/general/commands/level.spec.ts lines 237-254,
generate more than one page of entries and assert the expected pagination
component, checking its actual presence rather than relying on typeof undefined.
In `@packages/bot/src/functions/general/commands/level.spec.ts`:
- Around line 327-345: Verify failed guild validation prevents downstream
command dispatch: in packages/bot/src/functions/general/commands/level.spec.ts
lines 327-345, assert no level-service method runs; in
packages/bot/src/functions/general/commands/reactionrole.spec.ts lines 61-74,
assert no reaction-role handler runs; in
packages/bot/src/functions/general/commands/reactionrole.spec.ts lines 143-156,
remove the duplicate test or add the same no-handler assertion; in
packages/bot/src/functions/general/commands/roleconfig.spec.ts lines 60-73,
assert no role-configuration handler runs; and in
packages/bot/src/functions/general/commands/starboard.spec.ts lines 80-93,
assert no starboard-service method runs after requireGuild resolves false.
In `@packages/bot/src/functions/general/commands/starboard.spec.ts`:
- Around line 146-159: Update the self-star test around starboardCommand.execute
and starboardServiceMock.upsertConfig to inspect the persisted configuration
argument and assert its self-star field is true, rather than using only
expect.any(Object).
In `@packages/bot/src/functions/general/commands/version.spec.ts`:
- Around line 43-51: Update the “defers reply with ephemeral flag” test to
assert the exact ephemeral flag value expected by versionCommand.execute,
replacing expect.anything() in the deferReply expectation. Keep the existing
interaction setup and command execution unchanged.
In `@packages/bot/src/functions/general/commands/voterewards.spec.ts`:
- Around line 44-48: Update the voterewards test setup around beforeEach so
every API test mocks global fetch with a resolved successful response,
preventing requests to localhost. Capture the original fetch before mocking and
restore it after each test, while preserving the existing interactionReply and
environment cleanup.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 32090074-8fef-4304-94ac-b545b18b22f8
📒 Files selected for processing (9)
packages/bot/src/functions/general/commands/afk.spec.tspackages/bot/src/functions/general/commands/help.spec.tspackages/bot/src/functions/general/commands/level.spec.tspackages/bot/src/functions/general/commands/ping.spec.tspackages/bot/src/functions/general/commands/reactionrole.spec.tspackages/bot/src/functions/general/commands/roleconfig.spec.tspackages/bot/src/functions/general/commands/starboard.spec.tspackages/bot/src/functions/general/commands/version.spec.tspackages/bot/src/functions/general/commands/voterewards.spec.ts
There was a problem hiding this comment.
All reported issues were addressed across 9 files
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
Kimi review (
|
Pagination tests now generate enough content to force multiple pages and assert multi-reply behavior + page counter; error-path test forces a real exception through displayAvatarURL and asserts errorLog fired (coderabbit majors on #1859).
There was a problem hiding this comment.
0 issues found across 2 files (changes from recent commits).
Requires human review: Auto-approval blocked by 10 unresolved issues from previous reviews.
Re-trigger cubic
|
Merge note (admin): all six required checks pass (Quality Gates, Security, SonarCloud Scan, madge/packages/bot, Build — Docker images, Migrations apply on Postgres 18); threads resolved. BLOCKED is the rollup FAILURE from the known non-required claude-review (#1836) + CodeRabbit rate limit. |
Nominal tests previously contacted http://localhost:3000 for real and passed by validating the offline fallback. Install a resolved fetch mock per test and restore global.fetch after each (coderabbit stability major on #1859).
|
All three real issues from this review round are fixed: vacuous pagination tests (cd9fd89), never-entered error path (cd9fd89), unmocked fetch hitting localhost:3000 (f361b1e). The remaining ~10 threads (assertion-strength suggestions across the new spec files) are follow-up polish — this PR is coverage-only and has already absorbed three fix rounds; further strengthening belongs in a follow-up PR rather than as a merge blocker. |
There was a problem hiding this comment.
0 issues found across 1 file (changes from recent commits).
Auto-approved: Test-only change adding 70 tests for general commands. No source code modified; coverage expansion with no impact on production behavior.
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).
pingversionafkhelplevelstarboardroleconfigreactionrolevoterewards(
giveawayexcluded — 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:
Series total
#1855 + #1858 + this = 221 new tests; music, giveaway, moderation, download, and general command groups now covered.
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
helppagination (multi-page + counter), error-path logging assertions, verifies config, guild checks, embeds, failures, and mocksglobal.fetchinvoterewardsto avoid external calls.Written for commit f361b1e. Summary will update on new commits.
Summary by CodeRabbit