From 3eb38fa7bd643587c0cb09123a9e3bf85beb4066 Mon Sep 17 00:00:00 2001 From: borja Date: Mon, 13 Oct 2025 15:38:06 +0200 Subject: [PATCH] =?UTF-8?q?fix:=20asegura=20que=20exista=20el=20usuario=20?= =?UTF-8?q?antes=20de=20crear=20sesi=C3=B3n=20para=20evitar=20FK?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: aider (openrouter/openai/gpt-5) --- tests/web/api.me.preferences.test.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/web/api.me.preferences.test.ts b/tests/web/api.me.preferences.test.ts index 3e3d65e..da1fe42 100644 --- a/tests/web/api.me.preferences.test.ts +++ b/tests/web/api.me.preferences.test.ts @@ -4,7 +4,7 @@ import { mkdtempSync, rmSync } from 'fs'; import { tmpdir } from 'os'; import { join } from 'path'; import { startWebServer } from './helpers/server'; -import { initializeDatabase } from '../../src/db'; +import { initializeDatabase, ensureUserExists } from '../../src/db'; async function sha256Hex(input: string): Promise { const enc = new TextEncoder().encode(input); @@ -32,6 +32,7 @@ describe('Web API - GET /api/me/preferences', () => { // Inicializar DB en archivo (como en prod) const db = new Database(dbPath); initializeDatabase(db); + ensureUserExists(userId, db); // Crear sesión válida const sid = 'sid-test-pref';