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,6 +1,6 @@
|
||||
const request = require('supertest');
|
||||
const { app } = require('../../backend/server');
|
||||
const { getAuthHeader, cleanDb, seedGame, seedSession, seedSessionGame } = require('../helpers/test-utils');
|
||||
const { getAuthHeader, cleanDb, seedGame, seedSession, seedSessionGame, db } = require('../helpers/test-utils');
|
||||
|
||||
describe('POST /api/votes/live (regression)', () => {
|
||||
let game, session, sessionGame;
|
||||
@@ -46,6 +46,12 @@ describe('POST /api/votes/live (regression)', () => {
|
||||
type: 'up',
|
||||
timestamp: '2026-03-15T20:05:00.000Z',
|
||||
});
|
||||
|
||||
const voteRow = db.prepare('SELECT * FROM live_votes WHERE username = ?').get('viewer1');
|
||||
expect(voteRow).toBeDefined();
|
||||
expect(voteRow.session_id).toBe(session.id);
|
||||
expect(voteRow.game_id).toBe(game.id);
|
||||
expect(voteRow.vote_type).toBe(1);
|
||||
});
|
||||
|
||||
test('increments downvotes and decrements popularity_score for downvote', async () => {
|
||||
|
||||
Reference in New Issue
Block a user