chore: 初始化TikTok短剧后端项目基础架构
创建了完整的NestJS项目结构,包含配置文件、核心模块、工具类、拦截器、过滤器等基础代码,实现了健康检查、用户认证、管理员RBAC、剧集管理、订单支付、媒体管理等核心功能的基础框架,配置了ESLint、TypeScript、Jest等开发工具链。
This commit is contained in:
77
test/playback-error.e2e-spec.ts
Normal file
77
test/playback-error.e2e-spec.ts
Normal file
@@ -0,0 +1,77 @@
|
||||
import { INestApplication } from '@nestjs/common';
|
||||
import { Test } from '@nestjs/testing';
|
||||
import * as request from 'supertest';
|
||||
import { AppModule } from '../src/app.module';
|
||||
import { bootstrapApp } from '../src/bootstrap';
|
||||
import { loginAdmin } from './test-helpers';
|
||||
|
||||
describe('Playback error logs', () => {
|
||||
let app: INestApplication;
|
||||
let adminToken: string;
|
||||
|
||||
beforeAll(async () => {
|
||||
const moduleRef = await Test.createTestingModule({
|
||||
imports: [AppModule],
|
||||
}).compile();
|
||||
|
||||
app = moduleRef.createNestApplication();
|
||||
bootstrapApp(app);
|
||||
await app.init();
|
||||
adminToken = await loginAdmin(app);
|
||||
});
|
||||
|
||||
afterAll(async () => {
|
||||
await app.close();
|
||||
});
|
||||
|
||||
it('accepts playback error reports and exposes them to admin logs', async () => {
|
||||
const requestId = 'aac95ef4-c546-427d-88c7-25b15b396b91';
|
||||
|
||||
const createResponse = await request(app.getHttpServer())
|
||||
.post('/api/app/v1/logs/playback-errors')
|
||||
.set('X-Request-Id', requestId)
|
||||
.send({
|
||||
requestId,
|
||||
dramaId: 1,
|
||||
episodeId: 10,
|
||||
playUrl: 'https://cdn.example.com/video.mp4',
|
||||
playerErrorCode: 'MEDIA_DECODE_ERROR',
|
||||
message: 'Video decode failed',
|
||||
progressSeconds: 128,
|
||||
networkType: 'wifi',
|
||||
device: {
|
||||
platform: 'ios',
|
||||
model: 'iPhone',
|
||||
systemVersion: '17.0',
|
||||
appVersion: '1.0.0',
|
||||
},
|
||||
occurredAt: '2026-06-30T00:00:00.000Z',
|
||||
})
|
||||
.expect(201);
|
||||
|
||||
expect(createResponse.body).toMatchObject({
|
||||
code: 0,
|
||||
data: {
|
||||
id: expect.any(Number),
|
||||
requestId,
|
||||
},
|
||||
message: 'success',
|
||||
requestId,
|
||||
});
|
||||
|
||||
const listResponse = await request(app.getHttpServer())
|
||||
.get('/api/admin/v1/logs/playback-errors')
|
||||
.set('Authorization', `Bearer ${adminToken}`)
|
||||
.expect(200);
|
||||
|
||||
expect(listResponse.body.data.list).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
requestId,
|
||||
playerErrorCode: 'MEDIA_DECODE_ERROR',
|
||||
progressSeconds: 128,
|
||||
}),
|
||||
]),
|
||||
);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user