godcrm/backend/routes/v3/__tests__/schema.test.ts
GOD CRM Release f89e074dd1
Some checks failed
CI / Lint / Typecheck / Test / Build (push) Has been cancelled
CI / PostgreSQL Integration Tests (push) Has been cancelled
GOD CRM — public scrubbed snapshot
Governed substrate for autonomous agents: scoped identity (passports),
audited actions, MCP workspace. Infra IPs and secrets redacted for public release.
2026-08-10 04:01:45 +03:00

77 lines
2.6 KiB
TypeScript

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');
});
});
});