Skip to content

test(bot): reduce recommendationEngine.spec.ts (29→14 tests) - #1035

Merged
LucasSantana-Dev merged 24 commits into
mainfrom
test/batch9-1032
May 24, 2026
Merged

LucasSantana-Dev merged 24 commits into
mainfrom
test/batch9-1032

Conversation

@LucasSantana-Dev

@LucasSantana-Dev LucasSantana-Dev commented May 24, 2026 •

Copy link
Copy Markdown
Owner

Prunes delegation-only tests, consolidates module-level flow tests. 52% reduction (29→14 tests).

Changes:

  • Merged empty/below-threshold checks for generateRecommendations
  • Consolidated exclude-by-id and exclude-by-url into test.each
  • Merged diversity-filter test with max-recommendations check
  • Merged generateUserPreferenceRecommendations into single test covering flow + exclusion + errors
  • Merged history-based tests to reduce duplication
  • Consolidated applySpanishLanguagePenalty tests
  • Merged blendRecommendations sort and max checks

All tests pass. Coverage gate verified.

Summary by CodeRabbit

Release Notes

No user-facing changes in this release. This pull request contains internal test improvements for the recommendation system.

Review Change Stack

@LucasSantana-Dev
LucasSantana-Dev enabled auto-merge (squash) May 24, 2026 06:48
@vercel

vercel Bot commented May 24, 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 May 24, 2026 8:51pm

Request Review

@coderabbitai

coderabbitai Bot commented May 24, 2026 •

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

Test suite for recommendationEngine is reorganized and expanded across five core functions. Coverage now validates empty/threshold filtering, parameterized exclusion patterns, diversity-filter integration, multi-track blending, optional seed-creation error handling, Spanish-language penalty application, and score-based sorting with maxRecommendations limits.

Changes

Recommendation Engine Test Coverage Expansion

Layer / File(s) Summary
generateRecommendations test coverage expansion
packages/bot/src/services/musicRecommendation/recommendationEngine.spec.ts
Tests for empty/threshold filtering, parameterized exclusion by id/url, and diversity-filter integration with max-recommendations limiting are added and reorganized. Scenarios validate empty results, below-threshold filtering, above-threshold scoring, exclusion paths, and final result length after diversity filtering.
generateUserPreferenceRecommendations test coverage expansion
packages/bot/src/services/musicRecommendation/recommendationEngine.spec.ts
Test coverage is expanded to validate multi-track recommendation generation, optional exclusion list behavior, and error handling when seed creation fails (expecting empty result and error logging).
generateHistoryBasedRecommendations test coverage expansion
packages/bot/src/services/musicRecommendation/recommendationEngine.spec.ts
Tests for empty-history setup, multi-track blending within length bounds, and single-track generation with exclusion handling are updated and consolidated to verify result length stays within expected bounds.
applySpanishLanguagePenalty test refactoring
packages/bot/src/services/musicRecommendation/recommendationEngine.spec.ts
Spanish-penalty test is reworked to use mixed track batches with explicit score assertions on both penalized and non-penalized tracks, and redundant empty-array and mixed-batch test cases are removed.
blendRecommendations sort and limit test coverage
packages/bot/src/services/musicRecommendation/recommendationEngine.spec.ts
New test cases verify score-based sorting with negative values and enforce maxRecommendations limit by testing oversized input lists, asserting non-increasing score order and output length respecting the cap.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • LucasSantana-Dev/Lucky#1001: Both PRs modify packages/bot/src/services/musicRecommendation/recommendationEngine.spec.ts to expand generateRecommendations and blendRecommendations test coverage, with overlapping changes to diversity-filter and sorting assertions.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly and clearly summarizes the main change: reducing test count in recommendationEngine.spec.ts from 29 to 14 tests, which is the primary objective of the pull request.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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/batch9-1032

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.

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

@github-actions

Copy link
Copy Markdown

Failed to generate code suggestions for PR

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 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/services/musicRecommendation/recommendationEngine.spec.ts`:
- Around line 91-115: The tests for generateRecommendations are currently
passing via error-path catches because applyDiversityFilterMock isn't stubbed
and slice can throw; update the spec to explicitly mock applyDiversityFilterMock
to return a non-throwing array (e.g., return the filtered array it should
produce) so the test exercises normal logic, and for the URL branch create
mockTrack instances where id is falsy (set id to undefined or null) so track.id
|| track.url selects the url; also ensure createTrackVectorMock and
calculateTrackSimilarityMock are set to values that keep similarity calculations
below/above threshold to validate the empty-result and exclusion behaviors for
generateRecommendations rather than relying on a caught exception.
🪄 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: 5bf2db4e-289e-4b85-8315-73b5302ce1f3

📥 Commits

Reviewing files that changed from the base of the PR and between 24e7bbe and f40631a.

📒 Files selected for processing (1)
  • packages/bot/src/services/musicRecommendation/recommendationEngine.spec.ts

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

@sonarqubecloud

Copy link
Copy Markdown

@LucasSantana-Dev
LucasSantana-Dev merged commit c31ce76 into main May 24, 2026
33 of 34 checks passed
@LucasSantana-Dev
LucasSantana-Dev deleted the test/batch9-1032 branch May 24, 2026 20:53
LucasSantana-Dev added a commit that referenced this pull request May 25, 2026
## Summary

- Bumps all package.json files from `2.14.1` → `2.15.0`
- Populates `CHANGELOG.md` with everything since v2.14.1
- Adds ADR `docs/decisions/2026-05-24-ci-runtime-baseline-accepted.md`
(CI runtime baseline: 3–4 min accepted, Jest sharding deferred)

### Changes included in this release

**Added**
- ServerLogs + ServerSettings UI pages (#965)
- AutoMessages executor wiring into execution service (#950)

**Changed**
- 4 UI redesigns: Admin, Config, Login, ServersPage, CustomCommands,
GuildAutomation, Spotify, LastFm (#967–#970)
- 5 refactors: AutoplayContext VO (#983),
GuildAutomationOrchestrator/Repository split (#982), MessagePipeline
chain (#981), ArtistSuggestionService (#980), recommendTracks entrypoint
(#979)

**Fixed** — deploy CI gap sweep (A–F)
- Gap A: hard-fail on OAuth 429 (#1045)
- Gap B: surface async deploy via commit statuses (#1046)
- Gap C: bot healthcheck polls Discord gateway, not Redis TCP (#1047)
- Gap D: post error status on lock contention (#1052)
- Gap E: add bot to required containers, remove dead unhealthy grep
(#1054)
- Gap F: wait for homelab-deploy completion on docker_rebuilt=true path
(#1056)
- lockfile-hash BuildKit cache key (#1016)
- squash-merged release branch archive (#946)

**Internal**
- Phase 4 test cleanup — 93 tests removed (#956–#1035)
- Pre-commit hooks: husky + lint-staged + tsc (#1007)
- madge gate promoted to blocking
- Dependabot routine bumps (#971–#977, #1042)

> **Note:** #1054 (Gap E) may still be in CI — merge this PR after #1054
lands.

This branch was successfully deployed

1 active deployment
Preview — 85d9695b Deployed May 24, 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.

2 participants