name: Test

on:
  push:
    branches: [main, dev]
  pull_request:
    branches: [main, dev]

jobs:
  backend-tests:
    name: Backend Tests
    runs-on: ubuntu-latest
    continue-on-error: true  # Don't block PRs

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

      - name: Set up Go
        uses: actions/setup-go@v5
        with:
          go-version: '1.23'

      - name: Download dependencies
        run: go mod download

      - name: Run tests
        run: go test -v ./...

      - name: Generate coverage
        run: go test -coverprofile=coverage.out ./...
        continue-on-error: true

  frontend-tests:
    name: Frontend Tests
    runs-on: ubuntu-latest
    continue-on-error: true  # Don't block PRs

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

      - name: Set up Node.js
        uses: actions/setup-node@v4
        with:
          node-version: '20'
          cache: 'npm'
          cache-dependency-path: web/package-lock.json

      - name: Install dependencies
        run: cd web && npm ci

      - name: Run tests
        run: cd web && npm run test
