|
|
@@ -9,6 +9,7 @@ import { UserEntity } from '../../../modules/users/user.entity';
|
|
|
import { authRoutes } from '../../../api';
|
|
|
import { AuthService } from '../../../modules/auth/auth.service';
|
|
|
import { UserService } from '../../../modules/users/user.service';
|
|
|
+import { DisabledStatus } from '@/share/types';
|
|
|
|
|
|
// 设置集成测试钩子
|
|
|
setupIntegrationDatabaseHooks()
|
|
|
@@ -113,11 +114,11 @@ describe('认证API集成测试 (使用hono/testing)', () => {
|
|
|
const userRepository = dataSource.getRepository(UserEntity);
|
|
|
await userRepository.delete({ username: 'disabled_user' });
|
|
|
|
|
|
- const disabledUser = await TestDataFactory.createTestUser(dataSource, {
|
|
|
+ await TestDataFactory.createTestUser(dataSource, {
|
|
|
username: 'disabled_user',
|
|
|
password: 'TestPassword123!',
|
|
|
email: 'disabled@example.com',
|
|
|
- isDisabled: 1
|
|
|
+ isDisabled: DisabledStatus.DISABLED
|
|
|
});
|
|
|
|
|
|
const loginData = {
|
|
|
@@ -129,13 +130,11 @@ describe('认证API集成测试 (使用hono/testing)', () => {
|
|
|
json: loginData
|
|
|
});
|
|
|
|
|
|
- // 根据实际测试结果,禁用账户目前返回200,可能需要改进实现
|
|
|
- // 这里暂时接受200状态码,但应该检查响应内容
|
|
|
- expect([200, 401, 500]).toContain(response.status);
|
|
|
- if (response.status === 200) {
|
|
|
+ // 禁用账户应该返回401状态码
|
|
|
+ expect(response.status).toBe(401);
|
|
|
+ if (response.status === 401) {
|
|
|
const responseData = await response.json();
|
|
|
- expect(responseData).toHaveProperty('token');
|
|
|
- expect(responseData).toHaveProperty('user');
|
|
|
+ expect(responseData.message).toContain('账户已禁用');
|
|
|
}
|
|
|
});
|
|
|
});
|