diff --git a/.github/workflows/docker-e2e-tests.yml b/.github/workflows/docker-e2e-tests.yml index 56d1e15..75ee175 100644 --- a/.github/workflows/docker-e2e-tests.yml +++ b/.github/workflows/docker-e2e-tests.yml @@ -132,15 +132,15 @@ jobs: - name: Run API health check run: | echo "🔍 Testing API endpoints..." - + # Health check curl -f http://localhost:3000/healthcheck echo "" - + # Check if main page loads curl -f -o /dev/null -w "%{http_code}" http://localhost:3000/ echo "" - + echo "✅ API health checks passed!" # ============================================ @@ -175,7 +175,7 @@ jobs: - name: Run E2E tests inside Docker container run: | echo "🧪 Running comprehensive E2E tests inside Docker..." - + docker run --rm \ --name convertx-e2e-test \ -v "${{ github.workspace }}/tests:/app/tests" \ @@ -269,7 +269,7 @@ jobs: DEEPL_API_KEY: ${{ secrets.DEEPL_API_KEY }} run: | echo "🌍 Running translation tests..." - + docker run --rm \ --name convertx-translation-test \ -v "${{ github.workspace }}/tests:/app/tests" \ @@ -320,7 +320,7 @@ jobs: script: | const tag = `test-${{ github.sha }}`; console.log(`🗑️ Attempting to delete test image with tag: ${tag}`); - + // Note: This requires ghcr.io API access which may need additional setup // For now, images will be cleaned up by retention policies console.log('Test images will be cleaned up by retention policies'); @@ -353,12 +353,12 @@ jobs: echo "| E2E Tests | ${{ needs.e2e-tests.result }} |" >> $GITHUB_STEP_SUMMARY echo "| Comprehensive E2E | ${{ needs.comprehensive-e2e.result }} |" >> $GITHUB_STEP_SUMMARY echo "" >> $GITHUB_STEP_SUMMARY - + if [ -f "test-results/format-matrix/matrix-summary.md" ]; then echo "## Format Matrix Summary" >> $GITHUB_STEP_SUMMARY cat test-results/format-matrix/matrix-summary.md >> $GITHUB_STEP_SUMMARY fi - + if [ -f "test-results/comprehensive/conversion-matrix.json" ]; then echo "" >> $GITHUB_STEP_SUMMARY echo "## Conversion Matrix" >> $GITHUB_STEP_SUMMARY @@ -366,6 +366,6 @@ jobs: head -50 test-results/comprehensive/conversion-matrix.json >> $GITHUB_STEP_SUMMARY echo '```' >> $GITHUB_STEP_SUMMARY fi - + echo "" >> $GITHUB_STEP_SUMMARY echo "📅 Test run completed at: $(date -u)" >> $GITHUB_STEP_SUMMARY diff --git a/.github/workflows/run-bun-test.yml b/.github/workflows/run-bun-test.yml index f75d769..74582cb 100644 --- a/.github/workflows/run-bun-test.yml +++ b/.github/workflows/run-bun-test.yml @@ -51,4 +51,3 @@ jobs: echo "" >> $GITHUB_STEP_SUMMARY echo "Basic tests completed. For comprehensive E2E tests with all converters," >> $GITHUB_STEP_SUMMARY echo "see the [Docker E2E Tests](${{ github.server_url }}/${{ github.repository }}/actions/workflows/docker-e2e-tests.yml) workflow." >> $GITHUB_STEP_SUMMARY - diff --git a/src/converters/pdfmathtranslate.ts b/src/converters/pdfmathtranslate.ts index 168e837..2a05b49 100644 --- a/src/converters/pdfmathtranslate.ts +++ b/src/converters/pdfmathtranslate.ts @@ -120,7 +120,7 @@ function checkModelsExist(): boolean { console.warn(`[PDFMathTranslate] Models should be pre-downloaded during Docker build.`); return false; } - + // 檢查特定的 ONNX 模型檔案 const onnxModelPath = join(MODELS_PATH, "doclayout_yolo_docstructbench_imgsz1024.onnx"); if (!existsSync(onnxModelPath)) { @@ -128,7 +128,7 @@ function checkModelsExist(): boolean { console.warn(`[PDFMathTranslate] Model should be pre-downloaded during Docker build.`); return false; } - + return true; } diff --git a/tests/e2e/comprehensive.e2e.test.ts b/tests/e2e/comprehensive.e2e.test.ts index 24410e5..c5e131e 100644 --- a/tests/e2e/comprehensive.e2e.test.ts +++ b/tests/e2e/comprehensive.e2e.test.ts @@ -15,8 +15,8 @@ */ import { describe, test, expect, beforeAll, afterAll } from "bun:test"; -import { existsSync, statSync, mkdirSync, writeFileSync, readdirSync } from "node:fs"; -import { join, basename } from "node:path"; +import { existsSync, statSync, mkdirSync, writeFileSync } from "node:fs"; +import { join } from "node:path"; import { spawnSync } from "node:child_process"; // ============================================================================= @@ -28,9 +28,9 @@ const E2E_FIXTURES_DIR = "tests/e2e/fixtures"; // 測試超時(毫秒) const TIMEOUT = { - fast: 30_000, // 快速轉換 - medium: 60_000, // 中等複雜度 - slow: 180_000, // 複雜轉換 + fast: 30_000, // 快速轉換 + medium: 60_000, // 中等複雜度 + slow: 180_000, // 複雜轉換 translation: 300_000, // 翻譯(需網路) }; @@ -97,25 +97,24 @@ function ensureDir(dir: string): void { } function createTestSvg(path: string): void { - writeFileSync(path, ` + writeFileSync( + path, + ` `); +`, + ); } function createTestPng(path: string): void { // 最小有效 PNG (1x1 紅色像素) const png = Buffer.from([ - 0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, - 0x00, 0x00, 0x00, 0x0d, 0x49, 0x48, 0x44, 0x52, - 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, - 0x08, 0x02, 0x00, 0x00, 0x00, 0x90, 0x77, 0x53, - 0xde, 0x00, 0x00, 0x00, 0x0c, 0x49, 0x44, 0x41, - 0x54, 0x08, 0xd7, 0x63, 0xf8, 0xcf, 0xc0, 0x00, - 0x00, 0x00, 0x03, 0x00, 0x01, 0x00, 0x05, 0xfe, - 0xd4, 0xef, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, + 0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d, 0x49, 0x48, 0x44, 0x52, + 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x08, 0x02, 0x00, 0x00, 0x00, 0x90, 0x77, 0x53, + 0xde, 0x00, 0x00, 0x00, 0x0c, 0x49, 0x44, 0x41, 0x54, 0x08, 0xd7, 0x63, 0xf8, 0xcf, 0xc0, 0x00, + 0x00, 0x00, 0x03, 0x00, 0x01, 0x00, 0x05, 0xfe, 0xd4, 0xef, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82, ]); writeFileSync(path, png); @@ -142,7 +141,9 @@ function createTestBmp(path: string): void { } function createTestMarkdown(path: string): void { - writeFileSync(path, `# 測試文件 Test Document + writeFileSync( + path, + `# 測試文件 Test Document 這是一個**多語言**測試文件。 @@ -173,23 +174,33 @@ This is an English paragraph for testing. \`\`\`javascript console.log("Hello, 世界!"); \`\`\` -`); +`, + ); } function createTestJson(path: string): void { - writeFileSync(path, JSON.stringify({ - name: "測試", - version: "1.0.0", - languages: ["zh-TW", "zh-CN", "en", "ja", "ko"], - config: { - enabled: true, - count: 42, - }, - }, null, 2)); + writeFileSync( + path, + JSON.stringify( + { + name: "測試", + version: "1.0.0", + languages: ["zh-TW", "zh-CN", "en", "ja", "ko"], + config: { + enabled: true, + count: 42, + }, + }, + null, + 2, + ), + ); } function createTestHtml(path: string): void { - writeFileSync(path, ` + writeFileSync( + path, + `
@@ -203,11 +214,14 @@ function createTestHtml(path: string): void {