import { describe, it, expect, beforeAll, afterAll } from 'vitest'; import request from 'supertest'; import express from 'express'; import schemaRoutes from '../schema.js'; // Mock auth middleware const mockAuth = (req: any, res: any, next: any) => { req.user = { id: 1, role: 'admin' }; next(); }; describe.skip('Schema Routes', () => { let app: express.Application; beforeAll(() => { app = express(); app.use(express.json()); app.use(mockAuth); app.use('/api/v3', schemaRoutes); }); describe.skip('GET /api/v3/spaces/:spaceId/schema', () => { it('should return 404 for non-existent space', async () => { const response = await request(app).get('/api/v3/spaces/999999/schema'); expect(response.status).toBe(404); expect(response.body.success).toBe(false); }); }); describe.skip('PUT /api/v3/spaces/:spaceId/schema/layout', () => { it('should return 404 for non-existent space', async () => { const response = await request(app) .put('/api/v3/spaces/999999/schema/layout') .send({ nodes: [] }); expect(response.status).toBe(404); expect(response.body.success).toBe(false); }); }); describe.skip('POST /api/v3/spaces/:spaceId/schema/tables', () => { it('should return 400 for invalid project', async () => { const response = await request(app) .post('/api/v3/spaces/1/schema/tables') .send({ name: 'test_table', displayName: 'Test Table', projectId: 999999, }); expect(response.status).toBe(400); expect(response.body.error.code).toBe('INVALID_PROJECT'); }); }); /** * BUG-202601-001: POST /relations uses `name` instead of `column_name` * The table_columns table has field `column_name`, but schema.js queries `name` */ describe.skip('POST /api/v3/relations - BUG-202601-001', () => { it('should use column_name field to find columns (not name)', async () => { // This test verifies that the SQL query uses column_name, not name // The schema has: table_columns.column_name, not table_columns.name const response = await request(app) .post('/api/v3/relations') .send({ sourceTableId: 999999, // Non-existent to trigger NOT_FOUND sourceColumn: 'test_column', targetTableId: 999999, targetColumn: 'id', }); // Should return 404 NOT_FOUND for tables (before even checking columns) expect(response.status).toBe(404); expect(response.body.success).toBe(false); expect(response.body.error.code).toBe('NOT_FOUND'); }); }); });