Skip to content

v2.3.0: Consolidate modules, add handlers, improve tests and validation#231

Merged
htilly merged 2 commits intomasterfrom
develop
Jan 27, 2026
Merged

v2.3.0: Consolidate modules, add handlers, improve tests and validation#231
htilly merged 2 commits intomasterfrom
develop

Conversation

@htilly
Copy link
Owner

@htilly htilly commented Jan 27, 2026

Summary

  • Consolidate modules: Move all root JS files to lib/ folder for cleaner project structure
  • Extract add handlers: New lib/add-handlers.js with add/addalbum/addplaylist/append commands
  • Security fixes: Add Spotify null guards in search functions (Copilot suggestion)
  • Code quality: Replace .map() with .forEach() for side effects, fix duplicate playlist queueing bug
  • Dependency update: Bump posthog-node to 5.24.2
  • GitHub token config: Add githubToken to setconfig with sensitive value masking
  • Feature request: Improve error message with setup instructions

Test improvements

  • Add integration tests for addalbum and addplaylist with queue size verification
  • Fix test runner to detect threaded bot responses
  • Add rate-limit handling to avoid Slack API throttling
  • Add automatic retry with 10s backoff on test failure
  • NEW: Exact queue size verification (catches duplicate queueing bugs)
  • NEW: Three-level validation output (exact/warning/fail)
  • NEW: Search album/playlist before adding to verify expected track count
  • NEW: Show track count in searchalbum results

Workflow fixes

  • Pin Node.js to 20.20.0 (meets posthog-node engine requirement)
  • Fix Slack RTM → Socket Mode in AI generator prompt
  • Fix heredoc variable expansion in workflow

Changes

  • 25 files changed, +2224 -955 lines
  • 10 modules moved to lib/
  • 42 new unit tests for add-handlers
  • 8 new integration tests with queue size verification

- Add searchalbum track count display (e.g., "17 tracks")
- Add validators: queueSizeIncreaseExactly, extractAndStoreTrackCount, queueSizeIncreasedByStoredCount
- Verify add command increases queue by exactly 1
- Search album/playlist before adding to get expected track count
- Verify actual increase matches expected (catches duplicate queueing bugs)
- Add three-level output: exact (silent), within tolerance (warning), outside tolerance (fail)
- Show detailed baseline → actual numbers in warnings/errors
Copilot AI review requested due to automatic review settings January 27, 2026 18:03
@cursor
Copy link

cursor bot commented Jan 27, 2026

You have run out of free Bugbot PR reviews for this billing cycle. This will reset on February 11.

To receive reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR enhances the integration test suite with sophisticated queue size validation to detect duplicate queueing bugs, and adds track count display to album search results.

Changes:

  • Added three-level queue size validation (exact match, warning, fail) with tolerance handling for edge cases
  • Introduced track count extraction from search results and validation against actual queue changes
  • Enhanced searchalbum command to display track counts for each album result
  • Modified Spotify API integration to include totalTracks field in album search results

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
test/tools/integration-test-suite.mjs Added validators for exact queue size verification, track count extraction, and validation with configurable tolerance to catch duplicate queueing bugs
lib/spotify.js Added totalTracks field to album search results with null-safe default value
lib/command-handlers.js Updated searchalbum to display track counts alongside album names

Comment on lines +600 to +603
const tolerance = Math.floor(exactIncrease * 0.9);
if (actualIncrease >= tolerance && actualIncrease < exactIncrease) {
console.log(` ⚠️ WARNING: Queue increased by ${actualIncrease} (expected ${exactIncrease}, baseline: ${baseline} → ${size})`);
return true;
Copy link

Copilot AI Jan 27, 2026

Choose a reason for hiding this comment

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

The tolerance calculation can produce incorrect results for small values of exactIncrease. When exactIncrease is 1, tolerance becomes Math.floor(0.9) = 0, which means an actualIncrease of 0 would trigger a warning and pass instead of failing. For small exact values (1-2 tracks), the 90% tolerance doesn't make sense. Consider using a minimum absolute tolerance (e.g., Math.max(1, Math.floor(exactIncrease * 0.9))) or disabling tolerance for small values.

Suggested change
const tolerance = Math.floor(exactIncrease * 0.9);
if (actualIncrease >= tolerance && actualIncrease < exactIncrease) {
console.log(` ⚠️ WARNING: Queue increased by ${actualIncrease} (expected ${exactIncrease}, baseline: ${baseline}${size})`);
return true;
// Disable tolerance for very small expected increases (1-2 tracks),
// where a "90%" tolerance would allow clearly incorrect results (e.g., 0 of 1).
if (exactIncrease >= 3) {
const tolerance = Math.floor(exactIncrease * 0.9);
if (actualIncrease >= tolerance && actualIncrease < exactIncrease) {
console.log(` ⚠️ WARNING: Queue increased by ${actualIncrease} (expected ${exactIncrease}, baseline: ${baseline}${size})`);
return true;
}

Copilot uses AI. Check for mistakes.
Comment on lines +648 to +649
const trackInfo = albumResult.totalTracks ? ` (${albumResult.totalTracks} tracks)` : '';
message += `> *${albumResult.name}* by _${albumResult.artist}_${trackInfo}\n`;
Copy link

Copilot AI Jan 27, 2026

Choose a reason for hiding this comment

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

The track count display always uses "tracks" (plural) even when totalTracks is 1, which would show "(1 tracks)". For consistency with other parts of this file (see lines 437 and 606), consider using conditional pluralization: (${albumResult.totalTracks} ${albumResult.totalTracks === 1 ? 'track' : 'tracks'})

Suggested change
const trackInfo = albumResult.totalTracks ? ` (${albumResult.totalTracks} tracks)` : '';
message += `> *${albumResult.name}* by _${albumResult.artist}_${trackInfo}\n`;
const trackInfo = albumResult.totalTracks
? ` (${albumResult.totalTracks} ${albumResult.totalTracks === 1 ? 'track' : 'tracks'})`
: '';
message += `> *${albumResult.name}* by _${albumResult.artist_${trackInfo}\n`;

Copilot uses AI. Check for mistakes.
- Disable tolerance for small exact values (1-2 tracks) to prevent accepting 0 when expecting 1
- Fix pluralization in searchalbum: '1 track' instead of '1 tracks'
@htilly htilly merged commit af2bb0f into master Jan 27, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants