name: Run e2e tests
on:
  workflow_dispatch:
  # pull_request:
  #   branches:
  #     - main

jobs:
  test:
    timeout-minutes: 30
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
        with:
          persist-credentials: false

      - name: Setup pnpm
        uses: pnpm/action-setup@0977fd99725f1db4007ccb2928dbb4e90d06cc86 # v6.0.10
        with:
          package_json_file: ./e2e/package.json

      - name: Set up Docker
        uses: docker/setup-docker-action@77e84dbf09b47d1e29270283c22f16145aa85ca1 # v5.4.0

      - name: Install dependencies
        run: pnpm ci
        working-directory: e2e

      - name: Install Playwright Browsers
        run: pnpm exec playwright install --with-deps
        working-directory: e2e

      - name: Run Playwright tests
        run: pnpm test
        working-directory: e2e

      - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
        if: ${{ !cancelled() }}
        with:
          name: playwright-report
          path: e2e/playwright-report/
          retention-days: 5
