Spaces:
Paused
Paused
| /** | |
| * Smoke Tests - validates core system functionality | |
| * Can be run via vitest | |
| */ | |
| import { describe, test, expect, beforeAll, afterAll } from 'vitest'; | |
| import { neo4jService } from '../database/Neo4jService'; | |
| import { checkPrismaConnection, prisma } from '../database/prisma'; | |
| let neo4jAvailable = false; | |
| let prismaAvailable = false; | |
| describe('Smoke Tests', () => { | |
| beforeAll(async () => { | |
| prismaAvailable = await checkPrismaConnection(); | |
| // Try Neo4j | |
| try { | |
| await neo4jService.connect(); | |
| neo4jAvailable = await neo4jService.healthCheck(); | |
| } catch { | |
| neo4jAvailable = false; | |
| } | |
| }); | |
| afterAll(async () => { | |
| if (neo4jAvailable) { | |
| await neo4jService.disconnect(); | |
| } | |
| if (prismaAvailable) { | |
| await prisma.$disconnect(); | |
| } | |
| }); | |
| test('Prisma database should be accessible', async () => { | |
| if (!prismaAvailable) { | |
| expect(true).toBe(true); // Skip gracefully | |
| return; | |
| } | |
| const result = await prisma.$queryRaw`SELECT 1 as test`; | |
| expect((result as any[])[0]?.test).toBe(1); | |
| }); | |
| test('Neo4j database should be accessible when available', async () => { | |
| if (!neo4jAvailable) { | |
| expect(true).toBe(true); // Skip gracefully - Neo4j is optional | |
| return; | |
| } | |
| const healthy = await neo4jService.healthCheck(); | |
| expect(healthy).toBe(true); | |
| }); | |
| test('Memory tables should exist', async () => { | |
| if (!prismaAvailable) { | |
| expect(true).toBe(true); // Skip gracefully | |
| return; | |
| } | |
| const tables = await prisma.$queryRaw<Array<{ table_name: string }>>` | |
| SELECT table_name FROM information_schema.tables WHERE table_schema='public' AND table_name LIKE 'memory_%' | |
| `; | |
| const existing = tables.map(t => t.table_name); | |
| const requiredTables = ['memory_entities', 'memory_relations', 'memory_tags']; | |
| const allExist = requiredTables.every(t => existing.includes(t)); | |
| expect(allExist).toBe(true); | |
| }); | |
| test('Vector documents table should exist', async () => { | |
| if (!prismaAvailable) { | |
| expect(true).toBe(true); // Skip gracefully | |
| return; | |
| } | |
| const result = await prisma.$queryRaw<Array<{ table_name: string }>>` | |
| SELECT table_name FROM information_schema.tables WHERE table_schema='public' AND table_name = 'vector_documents' | |
| `; | |
| expect(result.length).toBeGreaterThan(0); | |
| expect(result[0]?.table_name).toBe('vector_documents'); | |
| }); | |
| }); | |
| export { }; | |