2026-05-04 16:09:01 +08:00
|
|
|
import { Test, TestingModule } from '@nestjs/testing';
|
|
|
|
|
import { INestApplication } from '@nestjs/common';
|
|
|
|
|
import request from 'supertest';
|
feat: M1-01~03 — AI Gateway deepening, Vector module, Task Queue deepening
M1-01 AI Gateway:
- DB-driven ModelRoute/ProviderConfig/FallbackEvent tables
- ModelRouter rewrite with loadFromDb() hot-reload
- Fallback event recording + AIUsageRecorded event publishing
- Admin AAPI: routes CRUD, provider enable/disable, fallback events log
M1-02 Vector & Retrieval:
- VectorService with Qdrant client (upsert/delete/search/rerank)
- Admin AAPI: collection status, vector count, reindex trigger
M1-03 Task Queue:
- 16 task types with default retry/timeout configs
- Task stats dashboard, worker status panel, batch retry endpoint
M0 audit fixes:
- ApiMetric retention policy (30-day cleanup)
- Content Safety integration in Files module
- Queue registration centralized (domain-events)
- SECRET_MASTER_KEY production validation
E2E tests:
- M0: 28 smoke tests covering all 14 M0 issues
- M1: 16 tests covering M1-01/02/03
- Mock infrastructure: prisma, ioredis, jose, bullmq, qdrant
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-24 10:18:07 +08:00
|
|
|
import { AppModule } from '../src/app.module';
|
2026-05-04 16:09:01 +08:00
|
|
|
|
|
|
|
|
describe('AppController (e2e)', () => {
|
feat: M1-01~03 — AI Gateway deepening, Vector module, Task Queue deepening
M1-01 AI Gateway:
- DB-driven ModelRoute/ProviderConfig/FallbackEvent tables
- ModelRouter rewrite with loadFromDb() hot-reload
- Fallback event recording + AIUsageRecorded event publishing
- Admin AAPI: routes CRUD, provider enable/disable, fallback events log
M1-02 Vector & Retrieval:
- VectorService with Qdrant client (upsert/delete/search/rerank)
- Admin AAPI: collection status, vector count, reindex trigger
M1-03 Task Queue:
- 16 task types with default retry/timeout configs
- Task stats dashboard, worker status panel, batch retry endpoint
M0 audit fixes:
- ApiMetric retention policy (30-day cleanup)
- Content Safety integration in Files module
- Queue registration centralized (domain-events)
- SECRET_MASTER_KEY production validation
E2E tests:
- M0: 28 smoke tests covering all 14 M0 issues
- M1: 16 tests covering M1-01/02/03
- Mock infrastructure: prisma, ioredis, jose, bullmq, qdrant
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-24 10:18:07 +08:00
|
|
|
let app: INestApplication;
|
2026-05-04 16:09:01 +08:00
|
|
|
|
feat: M1-01~03 — AI Gateway deepening, Vector module, Task Queue deepening
M1-01 AI Gateway:
- DB-driven ModelRoute/ProviderConfig/FallbackEvent tables
- ModelRouter rewrite with loadFromDb() hot-reload
- Fallback event recording + AIUsageRecorded event publishing
- Admin AAPI: routes CRUD, provider enable/disable, fallback events log
M1-02 Vector & Retrieval:
- VectorService with Qdrant client (upsert/delete/search/rerank)
- Admin AAPI: collection status, vector count, reindex trigger
M1-03 Task Queue:
- 16 task types with default retry/timeout configs
- Task stats dashboard, worker status panel, batch retry endpoint
M0 audit fixes:
- ApiMetric retention policy (30-day cleanup)
- Content Safety integration in Files module
- Queue registration centralized (domain-events)
- SECRET_MASTER_KEY production validation
E2E tests:
- M0: 28 smoke tests covering all 14 M0 issues
- M1: 16 tests covering M1-01/02/03
- Mock infrastructure: prisma, ioredis, jose, bullmq, qdrant
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-24 10:18:07 +08:00
|
|
|
beforeAll(async () => {
|
2026-05-04 16:09:01 +08:00
|
|
|
const moduleFixture: TestingModule = await Test.createTestingModule({
|
|
|
|
|
imports: [AppModule],
|
|
|
|
|
}).compile();
|
|
|
|
|
app = moduleFixture.createNestApplication();
|
feat: M1-01~03 — AI Gateway deepening, Vector module, Task Queue deepening
M1-01 AI Gateway:
- DB-driven ModelRoute/ProviderConfig/FallbackEvent tables
- ModelRouter rewrite with loadFromDb() hot-reload
- Fallback event recording + AIUsageRecorded event publishing
- Admin AAPI: routes CRUD, provider enable/disable, fallback events log
M1-02 Vector & Retrieval:
- VectorService with Qdrant client (upsert/delete/search/rerank)
- Admin AAPI: collection status, vector count, reindex trigger
M1-03 Task Queue:
- 16 task types with default retry/timeout configs
- Task stats dashboard, worker status panel, batch retry endpoint
M0 audit fixes:
- ApiMetric retention policy (30-day cleanup)
- Content Safety integration in Files module
- Queue registration centralized (domain-events)
- SECRET_MASTER_KEY production validation
E2E tests:
- M0: 28 smoke tests covering all 14 M0 issues
- M1: 16 tests covering M1-01/02/03
- Mock infrastructure: prisma, ioredis, jose, bullmq, qdrant
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-24 10:18:07 +08:00
|
|
|
app.setGlobalPrefix('api');
|
2026-05-04 16:09:01 +08:00
|
|
|
await app.init();
|
|
|
|
|
});
|
|
|
|
|
|
feat: M1-01~03 — AI Gateway deepening, Vector module, Task Queue deepening
M1-01 AI Gateway:
- DB-driven ModelRoute/ProviderConfig/FallbackEvent tables
- ModelRouter rewrite with loadFromDb() hot-reload
- Fallback event recording + AIUsageRecorded event publishing
- Admin AAPI: routes CRUD, provider enable/disable, fallback events log
M1-02 Vector & Retrieval:
- VectorService with Qdrant client (upsert/delete/search/rerank)
- Admin AAPI: collection status, vector count, reindex trigger
M1-03 Task Queue:
- 16 task types with default retry/timeout configs
- Task stats dashboard, worker status panel, batch retry endpoint
M0 audit fixes:
- ApiMetric retention policy (30-day cleanup)
- Content Safety integration in Files module
- Queue registration centralized (domain-events)
- SECRET_MASTER_KEY production validation
E2E tests:
- M0: 28 smoke tests covering all 14 M0 issues
- M1: 16 tests covering M1-01/02/03
- Mock infrastructure: prisma, ioredis, jose, bullmq, qdrant
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-24 10:18:07 +08:00
|
|
|
afterAll(async () => {
|
|
|
|
|
await app?.close();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('GET /api → 200 with standard response', async () => {
|
|
|
|
|
const res = await request(app.getHttpServer())
|
|
|
|
|
.get('/api')
|
|
|
|
|
.expect(200);
|
|
|
|
|
expect(res.body).toHaveProperty('success', true);
|
|
|
|
|
expect(res.body).toHaveProperty('data');
|
|
|
|
|
expect(res.body).toHaveProperty('timestamp');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('GET /api → returns x-trace-id header', async () => {
|
|
|
|
|
const res = await request(app.getHttpServer()).get('/api');
|
|
|
|
|
expect(res.headers).toHaveProperty('x-trace-id');
|
2026-05-04 16:09:01 +08:00
|
|
|
});
|
|
|
|
|
|
feat: M1-01~03 — AI Gateway deepening, Vector module, Task Queue deepening
M1-01 AI Gateway:
- DB-driven ModelRoute/ProviderConfig/FallbackEvent tables
- ModelRouter rewrite with loadFromDb() hot-reload
- Fallback event recording + AIUsageRecorded event publishing
- Admin AAPI: routes CRUD, provider enable/disable, fallback events log
M1-02 Vector & Retrieval:
- VectorService with Qdrant client (upsert/delete/search/rerank)
- Admin AAPI: collection status, vector count, reindex trigger
M1-03 Task Queue:
- 16 task types with default retry/timeout configs
- Task stats dashboard, worker status panel, batch retry endpoint
M0 audit fixes:
- ApiMetric retention policy (30-day cleanup)
- Content Safety integration in Files module
- Queue registration centralized (domain-events)
- SECRET_MASTER_KEY production validation
E2E tests:
- M0: 28 smoke tests covering all 14 M0 issues
- M1: 16 tests covering M1-01/02/03
- Mock infrastructure: prisma, ioredis, jose, bullmq, qdrant
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-24 10:18:07 +08:00
|
|
|
it('POST /api/not-found → 404', async () => {
|
|
|
|
|
const res = await request(app.getHttpServer())
|
|
|
|
|
.post('/api/not-found')
|
|
|
|
|
.expect(404);
|
|
|
|
|
expect(res.body.success).toBe(false);
|
2026-05-04 16:09:01 +08:00
|
|
|
});
|
|
|
|
|
});
|