name: E2E Tests

on:
  workflow_dispatch:
    inputs:
      skip_llm:
        description: "Skip LLM-dependent assertions (default: true)"
        type: boolean
        default: true

jobs:
  e2e:
    runs-on: ubuntu-latest
    timeout-minutes: 30
    env:
      PAPERCLIP_E2E_SKIP_LLM: ${{ inputs.skip_llm && 'true' || 'false' }}
      ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
    steps:
      - uses: actions/checkout@v4

      - uses: pnpm/action-setup@v4
        with:
          version: 9

      - uses: actions/setup-node@v4
        with:
          node-version: 20
          cache: pnpm

      - run: pnpm install --frozen-lockfile
      - run: pnpm build
      - run: npx playwright install --with-deps chromium

      - name: Run e2e tests
        run: pnpm run test:e2e

      - uses: actions/upload-artifact@v4
        if: always()
        with:
          name: playwright-report
          path: |
            tests/e2e/playwright-report/
            tests/e2e/test-results/
          retention-days: 14
