diff --git a/backend/eslint.config.js b/backend/eslint.config.js index 19671e83..76cb27e9 100644 --- a/backend/eslint.config.js +++ b/backend/eslint.config.js @@ -28,4 +28,10 @@ export default defineConfig([ 'no-useless-escape': 'warn', }, }, + { + files: ['test/**/*.ts'], + rules: { + '@typescript-eslint/no-explicit-any': 'off', + }, + }, ]) \ No newline at end of file diff --git a/backend/test/routes/files.test.ts b/backend/test/routes/files.test.ts index 301dc3b5..23aaa5ad 100644 --- a/backend/test/routes/files.test.ts +++ b/backend/test/routes/files.test.ts @@ -4,7 +4,7 @@ import { Hono } from 'hono' import type { ReadStream } from 'fs' import * as fileService from '../../src/services/files' import * as archiveService from '../../src/services/archive' -import type { FileInfo, ChunkedFileInfo, PatchOperation } from '@opencode-manager/shared' +import type { FileInfo, ChunkedFileInfo } from '@opencode-manager/shared' interface FileUploadResult { name: string @@ -47,7 +47,6 @@ vi.mock('../../src/services/archive', () => ({ })) const getFile = fileService.getFile as MockedFunction -const getRawFileContent = fileService.getRawFileContent as MockedFunction const getFileRange = fileService.getFileRange as MockedFunction const uploadFile = fileService.uploadFile as MockedFunction const createFileOrFolder = fileService.createFileOrFolder as MockedFunction @@ -58,7 +57,6 @@ const applyFilePatches = fileService.applyFilePatches as MockedFunction const getArchiveSize = archiveService.getArchiveSize as MockedFunction const getArchiveStream = archiveService.getArchiveStream as MockedFunction -const deleteArchive = archiveService.deleteArchive as MockedFunction describe('File Routes', () => { let app: Hono @@ -81,7 +79,7 @@ describe('File Routes', () => { getArchiveSize.mockResolvedValue(1024) getArchiveStream.mockReturnValue(mockStream) - const response = await app.request('/api/files/test-repo/src/download-zip') + await app.request('/api/files/test-repo/src/download-zip') expect(createDirectoryArchive).toHaveBeenCalledWith('test-repo/src', undefined, { includeGit: false, @@ -497,15 +495,6 @@ describe('File Routes', () => { }) describe('Path Traversal Protection', () => { - const mockFileInfo: FileInfo = { - name: 'test.txt', - path: 'safe-path/test.txt', - isDirectory: false, - size: 100, - mimeType: 'text/plain', - content: '', - lastModified: new Date(), - } it('should reject path with ../ segments via service error', async () => { const error = { message: 'Path traversal detected', statusCode: 403 } diff --git a/backend/test/routes/tts.test.ts b/backend/test/routes/tts.test.ts index 7504e7a0..2b3e561d 100644 --- a/backend/test/routes/tts.test.ts +++ b/backend/test/routes/tts.test.ts @@ -1,6 +1,5 @@ import { describe, it, expect, vi, beforeEach } from 'vitest' import * as fs from 'fs/promises' -import { logger } from '../../src/utils/logger' vi.mock('fs/promises', () => ({ mkdir: vi.fn(), @@ -27,7 +26,6 @@ vi.mock('../../src/utils/logger', () => ({ const mockMkdir = fs.mkdir as any const mockReadFile = fs.readFile as any -const mockWriteFile = fs.writeFile as any const mockReaddir = fs.readdir as any const mockStat = fs.stat as any const mockUnlink = fs.unlink as any @@ -36,29 +34,12 @@ import { createTTSRoutes, cleanupExpiredCache, getCacheStats, generateCacheKey, describe('TTS Routes', () => { let mockDb: any - let ttsApp: any - let mockSettingsService: any beforeEach(() => { vi.clearAllMocks() mockDb = {} as any - mockSettingsService = { - getSettings: vi.fn().mockReturnValue({ - preferences: { - tts: { - enabled: true, - apiKey: 'test-key', - endpoint: 'https://api.openai.com/v1/audio/speech', - voice: 'alloy', - model: 'tts-1', - speed: 1.0, - }, - }, - }), - } - - ttsApp = createTTSRoutes(mockDb) + createTTSRoutes(mockDb) }) describe('generateCacheKey', () => { diff --git a/backend/test/services/git/GitLogService.test.ts b/backend/test/services/git/GitLogService.test.ts index 8fb96751..defc3730 100644 --- a/backend/test/services/git/GitLogService.test.ts +++ b/backend/test/services/git/GitLogService.test.ts @@ -1,4 +1,3 @@ -/* eslint-disable @typescript-eslint/no-explicit-any */ import { describe, it, expect, vi, beforeEach, type MockedFunction } from 'vitest' vi.mock('bun:sqlite', () => ({ diff --git a/backend/test/utils/helpers.test.ts b/backend/test/utils/helpers.test.ts index 55d30295..8a9ead66 100644 --- a/backend/test/utils/helpers.test.ts +++ b/backend/test/utils/helpers.test.ts @@ -3,28 +3,24 @@ import { describe, it, expect } from 'vitest' describe('Process Helper Functions', () => { describe('mapProcessState', () => { it('should map "running" state correctly', () => { - const state = 'running' const mapped = 'running' as const expect(mapped).toBe('running') }) it('should map "stopped" state to "stopped"', () => { - const state = 'stopped' const mapped = 'stopped' as const expect(mapped).toBe('stopped') }) it('should map "starting" state to "starting"', () => { - const state = 'starting' const mapped = 'starting' as const expect(mapped).toBe('starting') }) it('should map unknown states to "error"', () => { - const state = 'unknown' const mapped = 'error' as const expect(mapped).toBe('error') @@ -62,28 +58,24 @@ describe('Process Helper Functions', () => { describe('validateRepoUrl', () => { it('should accept valid GitHub HTTPS URLs', () => { - const url = 'https://github.com/user/repo' const isValid = true expect(isValid).toBe(true) }) it('should accept valid GitHub SSH URLs', () => { - const url = 'git@github.com:user/repo.git' const isValid = true expect(isValid).toBe(true) }) it('should reject invalid URLs', () => { - const url = 'not-a-url' const isValid = false expect(isValid).toBe(false) }) it('should accept GitLab URLs', () => { - const url = 'https://gitlab.com/user/repo' const isValid = true expect(isValid).toBe(true) @@ -92,11 +84,6 @@ describe('Process Helper Functions', () => { describe('sanitizeEnvVars', () => { it('should filter out undefined values', () => { - const env = { - DEFINED: 'value', - UNDEFINED: undefined - } - const sanitized = ['DEFINED=value'] expect(sanitized).not.toContain('UNDEFINED')