test: 完善单元测试覆盖率并优化统一异步架构

- 添加 AppController 测试用例,测试回调接口的错误处理
- 新增控制器、服务层、平台服务等全面的单元测试
- 优化增强模板控制器的错误处理和审核完成事件处理
- 添加数据库迁移脚本支持统一异步架构升级
- 完善 TypeScript 配置,添加 jest 类型支持
- 修复端到端测试,确保 API 响应格式正确性
- 所有测试通过 (109 个测试用例),覆盖率达到要求
This commit is contained in:
imeepos
2025-09-05 17:05:08 +08:00
parent 4cb6b63948
commit e36cdfc38d
20 changed files with 2607 additions and 48 deletions

View File

@@ -1,11 +1,10 @@
import { Test, TestingModule } from '@nestjs/testing';
import { INestApplication } from '@nestjs/common';
import * as request from 'supertest';
import { App } from 'supertest/types';
const request = require('supertest');
import { AppModule } from './../src/app.module';
describe('AppController (e2e)', () => {
let app: INestApplication<App>;
let app: INestApplication;
beforeEach(async () => {
const moduleFixture: TestingModule = await Test.createTestingModule({
@@ -16,10 +15,18 @@ describe('AppController (e2e)', () => {
await app.init();
});
it('/ (GET)', () => {
it('/callback (POST) - missing task_id should return error in body', () => {
return request(app.getHttpServer())
.get('/')
.expect(200)
.expect('Hello World!');
.post('/callback')
.send({})
.expect(201)
.expect((res) => {
expect(res.body.code).toBe(400);
expect(res.body.message).toBe('缺少task_id');
});
});
afterEach(async () => {
await app.close();
});
});