|
|
@@ -3,7 +3,7 @@ import { testClient } from 'hono/testing';
|
|
|
import { authRoutes } from '../../src/routes';
|
|
|
import { IntegrationTestDatabase, setupIntegrationDatabaseHooksWithEntities } from '@d8d/shared-test-util';
|
|
|
import { Role, UserEntity } from '@d8d/user-module';
|
|
|
-import { redisUtil } from '@d8d/shared-utils';
|
|
|
+import { redisUtil, JWTUtil } from '@d8d/shared-utils';
|
|
|
import { File } from '@d8d/file-module';
|
|
|
|
|
|
// Mock MiniAuthService 的 decryptPhoneNumber 方法
|
|
|
@@ -55,8 +55,11 @@ describe('手机号解密API集成测试', () => {
|
|
|
await userRepository.save(testUser);
|
|
|
|
|
|
// 生成测试用户的token
|
|
|
- // 这里简化处理,实际项目中应该使用正确的JWT生成方法
|
|
|
- testToken = 'test_jwt_token';
|
|
|
+ testToken = JWTUtil.generateToken({
|
|
|
+ id: testUser.id,
|
|
|
+ username: testUser.username,
|
|
|
+ roles: [{name:'user'}]
|
|
|
+ });
|
|
|
|
|
|
// 使用 spyOn 来 mock getSessionKey 方法
|
|
|
getSessionKeySpy = vi.spyOn(redisUtil, 'getSessionKey').mockResolvedValue('mock-session-key');
|
|
|
@@ -85,6 +88,12 @@ describe('手机号解密API集成测试', () => {
|
|
|
}
|
|
|
});
|
|
|
|
|
|
+ console.debug('响应状态:', response.status);
|
|
|
+ if (response.status !== 200) {
|
|
|
+ const errorData = await response.json();
|
|
|
+ console.debug('错误响应:', errorData);
|
|
|
+ }
|
|
|
+
|
|
|
expect(response.status).toBe(200);
|
|
|
|
|
|
if (response.status === 200) {
|