29 lines
1.0 KiB
TypeScript
29 lines
1.0 KiB
TypeScript
import { test, expect } from '@playwright/test';
|
|
|
|
test.describe('简单API测试', () => {
|
|
|
|
test('测试1: 后端健康检查', async ({ request }) => {
|
|
console.log('测试1: 检查后端健康状态');
|
|
const response = await request.get('http://localhost:8084/actuator/health');
|
|
console.log('响应状态:', response.status());
|
|
const body = await response.json();
|
|
console.log('响应体:', JSON.stringify(body, null, 2));
|
|
expect(response.status()).toBe(200);
|
|
expect(body.status).toBe('UP');
|
|
});
|
|
|
|
test('测试2: 登录API', async ({ request }) => {
|
|
console.log('测试2: 测试登录API');
|
|
const response = await request.post('http://localhost:8084/api/auth/login', {
|
|
data: {
|
|
username: 'admin',
|
|
password: 'password'
|
|
}
|
|
});
|
|
console.log('响应状态:', response.status());
|
|
const body = await response.json();
|
|
console.log('响应体:', JSON.stringify(body, null, 2));
|
|
expect(response.status()).toBe(200);
|
|
expect(body.token).toBeDefined();
|
|
});
|
|
}); |