+565
tests/integration/comment_vote_test.go
···
test(comments): add comprehensive comment voting integration tests
Add end-to-end integration tests validating comment voting functionality including
vote creation, count updates, and viewer state hydration.
Test coverage:
- TestCommentVote_CreateAndUpdate: Vote count increments and viewer state
- Upvote increments upvote_count and score
- Downvote increments downvote_count and decreases score
- Vote changes properly update counts (up→down, removal)
- TestCommentVote_ViewerState: Viewer-specific state in API responses
- Authenticated viewer sees their vote state (direction + voteUri)
- Authenticated viewer without vote sees null viewer state
- Unauthenticated requests have no viewer object
All tests use fixed timestamps (time.Date) instead of time.Now() to prevent race
conditions and flaky tests. This ensures deterministic test behavior across runs.
Test data setup:
- Uses Jetstream event consumers for realistic indexing flow
- Creates test users, communities, posts, comments, and votes
- Validates full round-trip: event → indexing → query API → response
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
···