# Workflow that runs frontend e2e tests with Playwright
name: Run Frontend E2E Tests

on:
  push:
    branches:
      - main
  pull_request:
    paths:
      - "frontend/**"
      - ".github/workflows/fe-e2e-tests.yml"

concurrency:
  group: ${{ github.workflow }}-${{ (github.head_ref && github.ref) || github.run_id }}
  cancel-in-progress: true

jobs:
  fe-e2e-test:
    name: FE E2E Tests
    runs-on: ubuntu-22.04
    strategy:
      matrix:
        node-version: [22]
      fail-fast: true
    steps:
      - name: Checkout
        uses: actions/checkout@v6
      - name: Set up Node.js
        uses: actions/setup-node@v6
        with:
          node-version: ${{ matrix.node-version }}
          cache: 'npm'
          cache-dependency-path: frontend/package-lock.json
      - name: Install dependencies
        working-directory: ./frontend
        run: npm ci
      - name: Install Playwright browsers
        working-directory: ./frontend
        run: npx playwright install --with-deps chromium
      - name: Run Playwright tests
        working-directory: ./frontend
        run: npx playwright test --project=chromium
      - name: Upload Playwright report
        uses: actions/upload-artifact@v7
        if: always()
        with:
          name: playwright-report
          path: frontend/playwright-report/
          retention-days: 30
