test: reiniciar schema_migrations en tests para forzar migraciones

Co-authored-by: aider (openrouter/openai/gpt-5) <aider@aider.chat>
pull/1/head
borja 2 months ago
parent 70688df948
commit 5bb3b6d64c

@ -28,6 +28,8 @@ describe('Database', () => {
testDb.exec('DROP TABLE IF EXISTS group_members');
testDb.exec('DROP TABLE IF EXISTS groups');
testDb.exec('DROP TABLE IF EXISTS users');
// También reiniciar histórico de migraciones para forzar recreación de tablas
testDb.exec('DROP TABLE IF EXISTS schema_migrations');
// Initialize schema on the test database instance
initializeDatabase(testDb);
});
@ -41,9 +43,9 @@ describe('Database', () => {
// Order matters if foreign keys are involved during creation, though SQLite is flexible
const expectedTables = ['users', 'groups', 'group_members', 'tasks', 'task_assignments', 'response_queue'];
const userTables = tables.filter(t => !t.startsWith('sqlite_'));
// Check if all expected tables exist, order might vary slightly depending on execution
expect(userTables).toHaveLength(expectedTables.length);
// Filtrar tablas internas y de control de migraciones
const userTables = tables.filter(t => !t.startsWith('sqlite_') && t !== 'schema_migrations');
// Check if all expected tables exist (pueden existir tablas adicionales válidas como user_preferences)
expectedTables.forEach(table => expect(userTables).toContain(table));
});
});

@ -647,7 +647,8 @@ describe('WebhookServer', () => {
expect(response.status).toBe(200);
expect(SimulatedResponseQueue.getQueue().length).toBe(0);
// Reinitialize database for subsequent tests
// Reinitialize database for subsequent tests (force full migration)
testDb.exec('DROP TABLE IF EXISTS schema_migrations');
initializeDatabase(testDb);
});

@ -101,7 +101,8 @@ describe('ResponseQueue (persistent add)', () => {
.rejects
.toBeTruthy();
// Restaurar esquema para no afectar otros tests
// Restaurar esquema para no afectar otros tests (forzar recreación de tablas)
testDb.exec('DROP TABLE IF EXISTS schema_migrations');
initializeDatabase(testDb);
});
});

Loading…
Cancel
Save