fix: Gate E2E — Test.createTestingModule + DiscoveryModule
Some checks failed
Deploy API Server / build-and-unit (push) Successful in 33s
Deploy API Server / current-integration (push) Successful in 30s
Deploy API Server / backward-compat (push) Successful in 0s
Deploy API Server / m-ai-03-synthetic-e2e (push) Failing after 9s
Deploy API Server / deploy (push) Has been skipped
Some checks failed
Deploy API Server / build-and-unit (push) Successful in 33s
Deploy API Server / current-integration (push) Successful in 30s
Deploy API Server / backward-compat (push) Successful in 0s
Deploy API Server / m-ai-03-synthetic-e2e (push) Failing after 9s
Deploy API Server / deploy (push) Has been skipped
DiscoveryModule 来自 @nestjs/core,提供 ModulesContainer 和 Reflector。 解决了 AdminAuthGuard 和 DiscoveryService 的依赖解析问题。 Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
817b17bf9e
commit
c4d3b8342d
@ -1,5 +1,6 @@
|
|||||||
import { NestFactory } from '@nestjs/core';
|
import { Test, TestingModule } from '@nestjs/testing';
|
||||||
import { INestApplication } from '@nestjs/common';
|
import { INestApplication } from '@nestjs/common';
|
||||||
|
import { DiscoveryModule } from '@nestjs/core';
|
||||||
import { JwtService } from '@nestjs/jwt';
|
import { JwtService } from '@nestjs/jwt';
|
||||||
import request from 'supertest';
|
import request from 'supertest';
|
||||||
import { AppModule } from '../src/app.module';
|
import { AppModule } from '../src/app.module';
|
||||||
@ -40,15 +41,18 @@ describe('M-AI-03 GATE E2E (fail-closed)', () => {
|
|||||||
process.env.AI_JOB_SYNTHETIC_ENABLED = 'true';
|
process.env.AI_JOB_SYNTHETIC_ENABLED = 'true';
|
||||||
process.env.JWT_SECRET = 'gate-e2e-secret';
|
process.env.JWT_SECRET = 'gate-e2e-secret';
|
||||||
|
|
||||||
// NestFactory.create 提供所有 core providers (Reflector etc.)
|
// DiscoveryModule 提供 ModulesContainer + Reflector(TestingModule 不自动导入)
|
||||||
// 连接 Prisma + Redis — 失败则测试 fail-closed
|
const module: TestingModule = await Test.createTestingModule({
|
||||||
app = await NestFactory.create(AppModule);
|
imports: [AppModule, DiscoveryModule],
|
||||||
|
}).compile();
|
||||||
|
|
||||||
|
app = module.createNestApplication();
|
||||||
await app.init();
|
await app.init();
|
||||||
|
|
||||||
creationService = app.get(AiJobCreationService);
|
creationService = module.get(AiJobCreationService);
|
||||||
registry = app.get(JobDefinitionRegistry);
|
registry = module.get(JobDefinitionRegistry);
|
||||||
lifecycleRepo = app.get(AiJobLifecycleRepository);
|
lifecycleRepo = module.get(AiJobLifecycleRepository);
|
||||||
jwtService = app.get(JwtService);
|
jwtService = module.get(JwtService);
|
||||||
|
|
||||||
userToken = jwtService.sign({ sub: TEST_USER, email: 'gate@test.com', role: 'USER', type: 'user' });
|
userToken = jwtService.sign({ sub: TEST_USER, email: 'gate@test.com', role: 'USER', type: 'user' });
|
||||||
}, 30000);
|
}, 30000);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user