fix: setup robust unit testing foundation - #937
Conversation
👷 Deploy request for fixmybharat pending review.Visit the deploys page to approve it
|
🙏 Thank you for your contribution, @rohitkumarnaidu!PR Details:
Quality Checklist:
Review Process:
Note: The maintainers will monitor code quality and ensure the overall project flow isn't broken. |
📝 WalkthroughWalkthrough
ChangesCore validation and shutdown
Estimated code review effort: 2 (Simple) | ~15 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (4 passed)
✨ 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.
Actionable comments posted: 2
🤖 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 `@tests/dailyRefinement.test.ts`:
- Line 47: Update the analyzer shutdown around analyzer.close in the test setup
so the Promise rejects when SQLite reports a close error instead of always
resolving. Move the shutdown into a finally block or shared teardown that runs
after both successful and failed test execution, ensuring the database is always
closed and existing test behavior is preserved.
- Line 28: Update the stmt.finalize callback in the test fixture setup to retain
its finalization error, close the database, and pass either the finalization
error or the database close error to done. Ensure setup cannot report success
when statement finalization or database closing fails.
🪄 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: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 631261b4-3822-4bc5-9a4e-27a02a49621f
📒 Files selected for processing (2)
services/trendAnalyzer.tstests/dailyRefinement.test.ts
There was a problem hiding this comment.
All reported issues were addressed across 2 files
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
…ence index, and adaptive weights
There was a problem hiding this comment.
🧹 Nitpick comments (1)
tests/adaptiveWeights.test.ts (1)
28-34: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winAdd equality-boundary assertions to the threshold tests.
Both suites exercise values on either side of strict comparisons but skip equality itself.
tests/adaptiveWeights.test.ts#L28-L34: test exactly 10% and assert that the category is not boosted.tests/intelligenceIndex.test.ts#L32-L48: test exactly 50 and 200 issues with no score adjustment.🤖 Prompt for 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. In `@tests/adaptiveWeights.test.ts` around lines 28 - 34, The threshold tests omit equality-boundary coverage. In tests/adaptiveWeights.test.ts lines 28-34, extend the AdaptiveWeights.optimizeWeights tests to use exactly 10% volume and assert the category is not boosted; in tests/intelligenceIndex.test.ts lines 32-48, add cases for exactly 50 and exactly 200 issues and assert that neither boundary changes the score.
🤖 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.
Nitpick comments:
In `@tests/adaptiveWeights.test.ts`:
- Around line 28-34: The threshold tests omit equality-boundary coverage. In
tests/adaptiveWeights.test.ts lines 28-34, extend the
AdaptiveWeights.optimizeWeights tests to use exactly 10% volume and assert the
category is not boosted; in tests/intelligenceIndex.test.ts lines 32-48, add
cases for exactly 50 and exactly 200 issues and assert that neither boundary
changes the score.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: e16eb500-9e4a-44e7-973d-0b4ed7cdd95a
📒 Files selected for processing (3)
tests/adaptiveWeights.test.tstests/intelligenceIndex.test.tstests/priorityEngine.test.ts
🔍 Quality Reminder |
Resolves #925
Changes
Summary by cubic
Fixes the Windows SQLite file lock (EBUSY) in daily refinement tests and adds core unit tests for
PriorityEngine,IntelligenceIndex, andAdaptiveWeightswith equality-boundary checks for duplicate thresholds.TrendAnalyzer.closenow accepts a callback and tests ensure proper cleanup and error propagation sonpm testexits cleanly (addresses #925).TrendAnalyzer.close(callback?)to pass the callback to the DB’sclose.dailyRefinement.test.ts, close the DB afterstmt.finalize, pass any finalize/close error todone, and awaitanalyzer.closevia a Promise in a try/finally.Written for commit 389ae46. Summary will update on new commits.
Summary by CodeRabbit
Bug Fixes
Tests