fix: upgrade Docker to Node 22, add vote persistence diagnostics and e2e tests
- Bump Dockerfile base image from node:18-alpine to node:22-alpine to fix build failure (better-sqlite3@12.8.0 requires Node 20+) - Add post-transaction verification logging in POST /api/votes/live to detect live_votes insertion failures in production - Add direct DB assertion to regression test for live_votes population - Add end-to-end integration tests covering the full vote flow: POST vote -> GET /api/sessions/:id/votes -> GET /api/votes -> direct DB Made-with: Cursor
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
FROM node:18-alpine
|
||||
FROM node:22-alpine
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
|
||||
@@ -231,6 +231,16 @@ router.post('/live', authenticateToken, (req, res) => {
|
||||
|
||||
processVote();
|
||||
|
||||
// Verify the live_votes row was persisted (diagnostic for production debugging)
|
||||
const voteCheck = db.prepare(
|
||||
'SELECT id FROM live_votes WHERE session_id = ? AND game_id = ? AND username = ? AND timestamp = ?'
|
||||
).get(activeSession.id, matchedGame.game_id, username, timestamp);
|
||||
if (!voteCheck) {
|
||||
console.error('[votes] CRITICAL: live_votes INSERT committed but row not found', {
|
||||
session_id: activeSession.id, game_id: matchedGame.game_id, username, timestamp,
|
||||
});
|
||||
}
|
||||
|
||||
// Get updated game stats
|
||||
const updatedGame = db.prepare(`
|
||||
SELECT id, title, upvotes, downvotes, popularity_score
|
||||
|
||||
Reference in New Issue
Block a user