name: E2E Tests

on:
  push:
    branches: [ "main", "test/**"]
  workflow_dispatch:

jobs:
  selenium-tests:
    runs-on: ubuntu-latest

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

      - name: Setup .NET
        uses: actions/setup-dotnet@v4
        with:
          dotnet-version: '10.0.x'

      - name: Install Chromium and ChromeDriver
        run: |
          sudo apt-get update
          sudo apt-get install -y chromium-browser chromium-chromedriver

      # Verify the installation
      - name: Verify Chromium and ChromeDriver
        run: |
          chromium-browser --version
          /usr/bin/chromedriver --version

      - name: Restore dependencies
        run: dotnet restore src/

      - name: Build solution
        run: dotnet build src/ --configuration Release --no-restore

      - name: Run Selenium tests
        env:
          DOTNET_ENVIRONMENT: Development
        run: dotnet test src/

      - name: Upload test results
        uses: actions/upload-artifact@v4
        with:
          name: selenium-test-results
          path: "**/TestResults/*.trx"