name: Check Tests
permissions:
  contents: read

# 基本測試 - 在 Ubuntu runner 上運行（有限的工具集）
# 完整 Docker E2E 測試請參見: docker-e2e-tests.yml

on:
  push:
    branches: ["main"]
  pull_request:
    branches: ["main"]
  workflow_dispatch:

concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true

jobs:
  test:
    name: Run tests
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v4

      - name: Set up Bun
        uses: oven-sh/setup-bun@v2
        with:
          bun-version: 1.2.2

      # 安裝 E2E 測試所需的轉換工具
      - name: Install conversion tools for E2E tests
        run: |
          sudo apt-get update
          sudo apt-get install -y pandoc imagemagick

      - name: Install dependencies
        run: bun install

      - name: Run unit and mock tests
        run: bun test tests/e2e/converters.mock.test.ts tests/e2e/api.e2e.test.ts

      - name: Run available E2E tests
        run: bun test tests/e2e/converters.e2e.test.ts --timeout 120000
        continue-on-error: true

      - name: Test summary
        run: |
          echo "## 🧪 Test Summary" >> $GITHUB_STEP_SUMMARY
          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
