2
0
Эх сурвалжийг харах

✅ test(agora): 完善Agora Token API集成测试用例

- 为所有Agora Token API测试请求添加Authorization头
- 确保测试覆盖鉴权场景下的参数验证功能
- 增强Token有效期和格式验证测试的完整性
yourname 4 сар өмнө
parent
commit
8bb8eb3f34

+ 15 - 0
src/server/api/agora/__tests__/agora-token.integration.test.ts

@@ -206,6 +206,11 @@ describe('Agora Token API 集成测试', () => {
     // 测试缺少channel参数
     const response1 = await client.agora.token.$get({
       query: { type: 'rtc' } // 缺少channel参数
+    },
+    {
+      headers: {
+        'Authorization': 'Bearer test-token'
+      }
     })
 
     // 由于Zod验证,应该返回400错误
@@ -214,6 +219,11 @@ describe('Agora Token API 集成测试', () => {
     // 测试缺少userId参数
     const response2 = await client.agora.token.$get({
       query: { type: 'rtm' } // 缺少userId参数
+    },
+    {
+      headers: {
+        'Authorization': 'Bearer test-token'
+      }
     })
 
     // 由于Zod验证,应该返回400错误
@@ -223,6 +233,11 @@ describe('Agora Token API 集成测试', () => {
   test('Token有效期和格式验证', async () => {
     const response = await client.agora.token.$get({
       query: { type: 'rtc', channel: 'test-channel' }
+    },
+    {
+      headers: {
+        'Authorization': 'Bearer test-token'
+      }
     })
 
     expect(response.status).toBe(200)