name: BrowserAgent Tests

on: [push]

jobs:
  test:
    name: Run Tests (Python ${{ matrix.python-version }})
    runs-on: ubuntu-latest

    strategy:
      matrix:
        python-version:
          - "3.10"

    steps:
      - name: Checkout Repository
        uses: actions/checkout@v4

      - name: Debug directory structure
        run: |
          # ✅ Show actual directory structure
          echo "Current directory: $(pwd)"
          ls -la

      - name: Setup Python ${{ matrix.python-version }}
        uses: actions/setup-python@v5
        with:
          python-version: ${{ matrix.python-version }}
          cache: pip

      - name: Install Dependencies
        run: |
          cd browser_use/agent_browser
          python -m pip install --upgrade pip
          pip install pytest pytest-asyncio
          pip install -r requirements.txt

      - name: Run Tests
        env:
          PYTHONPATH: ${{ github.workspace }}/browser_use/agent_browser
          DASHSCOPE_API_KEY: ${{ secrets.DASHSCOPE_API_KEY }}
        run: |
          # ✅ Ensure test-results directory exists
          mkdir -p test-results
          # ✅ Run tests with XML output
          python -m pytest tests/browser_agent_test.py -v