test: Phase 0 测试基础设施 — TestApp + MSW + 覆盖率工具 + CI
- TestApp struct 封装 TestDb + HealthState + tenant_id/operator_id - TestFixture 工厂方法: create_patient/create_doctor/create_schedule/create_appointment - 前端 MSW v2 handlers (auth) + server setup + vitest 集成 - vitest coverage v8 配置 + test:coverage script - GitHub Actions CI: backend (check + test + clippy) + frontend (tsc + test + build)
This commit is contained in:
30
apps/web/src/test/mocks/handlers.ts
Normal file
30
apps/web/src/test/mocks/handlers.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import { http, HttpResponse } from 'msw';
|
||||
|
||||
const TOKEN_EXPIRES = 3600;
|
||||
|
||||
export const authHandlers = [
|
||||
http.post('/api/v1/auth/login', () =>
|
||||
HttpResponse.json({
|
||||
success: true,
|
||||
data: {
|
||||
access_token: 'test-access-token',
|
||||
refresh_token: 'test-refresh-token',
|
||||
expires_in: TOKEN_EXPIRES,
|
||||
user: { id: 'test-user-id', username: 'admin', tenant_id: 'test-tenant-id' },
|
||||
},
|
||||
}),
|
||||
),
|
||||
|
||||
http.post('/api/v1/auth/refresh', () =>
|
||||
HttpResponse.json({
|
||||
success: true,
|
||||
data: {
|
||||
access_token: 'test-access-token-refreshed',
|
||||
refresh_token: 'test-refresh-token-refreshed',
|
||||
expires_in: TOKEN_EXPIRES,
|
||||
},
|
||||
}),
|
||||
),
|
||||
];
|
||||
|
||||
export const handlers = [...authHandlers];
|
||||
Reference in New Issue
Block a user