| 12345678910111213141516171819202122232425262728293031323334353637383940 |
- /**
- * L1 冒烟测试:健康检查
- * 验证后端服务基础健康状态
- */
- import { test, expect } from '@playwright/test';
- import { apiGet, initApiClient, disposeApiClient } from '../helpers/api-client';
- test.describe('健康检查', () => {
- test.beforeAll(async () => {
- await initApiClient();
- });
- test.afterAll(async () => {
- await disposeApiClient();
- });
- test('S01: 服务健康检查 /health', async () => {
- const res = await apiGet('/health');
- expect(res.code).toBe(0);
- expect(res.data?.status).toBe('healthy');
- });
- test('S02: 数据库连接检查 /api/tts/test-db', async () => {
- const res = await apiGet('/api/tts/test-db');
- expect(res.code).toBe(0);
- expect(res.data?.connectionState).toBe('connected');
- });
- test('S03: 性能指标端点 /api/metrics', async () => {
- const res = await apiGet('/api/metrics');
- // metrics 可能返回非标准格式,只验证可达
- expect([0, 200]).toContain(res.code);
- });
- test('S04: 静态文件服务可用 /uploads', async () => {
- const { apiRaw } = require('../helpers/api-client');
- const raw = await apiRaw('GET', '/uploads/');
- expect([200, 404]).toContain(raw.status());
- });
- });
|