소스 검색

chore: fix lint errors in test files after rebase

- Prefix unused variables with underscore
- Remove unused imports

Co-Authored-By: Claude Opus 4.5 <[email protected]>
ding113 1 개월 전
부모
커밋
c9f6affe37

+ 1 - 1
tests/api/api-actions-integrity.test.ts

@@ -10,7 +10,7 @@
  *   bun run test:api
  */
 
-import { describe, expect, test, beforeAll } from "vitest";
+import { beforeAll, describe, expect, test } from "vitest";
 import { callActionsRoute } from "../test-utils";
 
 type OpenAPIDocument = {

+ 2 - 2
tests/api/keys-actions.test.ts

@@ -22,7 +22,7 @@
  * - 错误处理
  */
 
-import { describe, expect, test, beforeEach } from "vitest";
+import { beforeEach, describe, expect, test } from "vitest";
 import { callActionsRoute } from "../test-utils";
 
 const ADMIN_TOKEN = process.env.TEST_ADMIN_TOKEN || "test-admin-token";
@@ -360,7 +360,7 @@ describe.skip("Key 管理 - 编辑 Key (editKey)", () => {
     }
 
     // 创建测试 Key
-    const { data: keyData } = await callKeysApi("addKey", {
+    const { data: _keyData } = await callKeysApi("addKey", {
       userId: testUserId,
       name: `待编辑Key_${Date.now()}`,
     });

+ 2 - 2
tests/api/providers-actions.test.ts

@@ -24,7 +24,7 @@
  * - 熔断器状态管理
  */
 
-import { describe, expect, test, beforeEach } from "vitest";
+import { beforeEach, describe, expect, test } from "vitest";
 import { callActionsRoute } from "../test-utils";
 
 const ADMIN_TOKEN = process.env.TEST_ADMIN_TOKEN || "test-admin-token";
@@ -252,7 +252,7 @@ describe.skip("供应商管理 - 编辑供应商 (editProvider)", () => {
 
   beforeEach(async () => {
     // 创建测试供应商
-    const { data } = await callProvidersApi("addProvider", {
+    const { data: _data } = await callProvidersApi("addProvider", {
       name: `待编辑供应商_${Date.now()}`,
       url: "https://api.anthropic.com",
       key: "sk-test-key",

+ 1 - 1
tests/api/users-actions.test.ts

@@ -32,7 +32,7 @@
  * - 错误处理
  */
 
-import { describe, expect, test, beforeEach } from "vitest";
+import { beforeEach, describe, expect, test } from "vitest";
 import { callActionsRoute } from "../test-utils";
 
 // 测试用管理员 Token(实际使用时需要有效的 token)

+ 3 - 3
tests/cleanup-utils.ts

@@ -4,9 +4,9 @@
  * 用途:在测试后自动清理创建的测试数据
  */
 
+import { and, isNull, like, or, sql } from "drizzle-orm";
 import { db } from "@/drizzle/db";
-import { users, keys } from "@/drizzle/schema";
-import { sql, and, like, or, isNull } from "drizzle-orm";
+import { users } from "@/drizzle/schema";
 
 /**
  * 清理所有测试用户及其关联数据
@@ -61,7 +61,7 @@ export async function cleanupTestUsers(options?: {
     `);
 
     // 3. 软删除测试用户
-    const deletedUsers = await db.execute(sql`
+    const _deletedUsers = await db.execute(sql`
       UPDATE users
       SET deleted_at = NOW(), updated_at = NOW()
       WHERE id = ANY(${testUserIds})

+ 2 - 2
tests/e2e/api-complete.test.ts

@@ -13,7 +13,7 @@
  * 🧹 清理:测试完成后自动清理数据
  */
 
-import { describe, expect, test, beforeAll, afterAll } from "vitest";
+import { afterAll, describe, expect, test } from "vitest";
 
 // ==================== 配置 ====================
 
@@ -60,7 +60,7 @@ afterAll(async () => {
   for (const userId of testData.userIds) {
     try {
       await callApi("users", "removeUser", { userId });
-    } catch (e) {
+    } catch (_e) {
       // 忽略清理错误
     }
   }

+ 5 - 5
tests/e2e/users-keys-complete.test.ts

@@ -22,7 +22,7 @@
  * - 使用 afterAll 钩子确保清理执行
  */
 
-import { describe, expect, test, beforeAll, afterAll } from "vitest";
+import { afterAll, beforeAll, describe, expect, test } from "vitest";
 
 // ==================== 配置 ====================
 
@@ -168,7 +168,7 @@ afterAll(async () => {
   for (const userId of testData.userIds) {
     try {
       await callApi("users", "removeUser", { userId });
-    } catch (error) {
+    } catch (_error) {
       console.warn(`⚠️  清理用户 ${userId} 失败`);
     }
   }
@@ -260,7 +260,7 @@ describe("用户和 Key 管理 - 完整 E2E 测试", () => {
 
   describe("【用户管理】编辑和状态管理", () => {
     test("2.1 应该成功编辑用户信息", async () => {
-      const result = await expectSuccess("users", "editUser", {
+      const _result = await expectSuccess("users", "editUser", {
         userId: testUser1Id,
         name: `E2E用户1_已编辑_${Date.now()}`,
         note: "已修改",
@@ -383,7 +383,7 @@ describe("用户和 Key 管理 - 完整 E2E 测试", () => {
       testData.userIds.push(tempUserId);
 
       // 创建额外的 Key
-      const keyResult = await expectSuccess("keys", "addKey", {
+      const _keyResult = await expectSuccess("keys", "addKey", {
         userId: tempUserId,
         name: `临时Key_${Date.now()}`,
       });
@@ -561,7 +561,7 @@ describe("用户和 Key 管理 - 完整 E2E 测试", () => {
       const createdKeys = [];
 
       for (let i = 1; i <= 3; i++) {
-        const keyResult = await expectSuccess("keys", "addKey", {
+        const _keyResult = await expectSuccess("keys", "addKey", {
           userId,
           name: `测试Key${i}_${Date.now()}`,
         });

+ 1 - 1
tests/setup.ts

@@ -4,8 +4,8 @@
  * 在所有测试运行前执行的全局配置
  */
 
-import { beforeAll, afterAll } from "vitest";
 import { config } from "dotenv";
+import { afterAll, beforeAll } from "vitest";
 
 // ==================== 加载环境变量 ====================