name: Tests

on:
  push:
    branches:
      - '**'
  pull_request:
  workflow_dispatch:

jobs:
  rust-tests:
    name: Tests Rust
    runs-on: ubuntu-22.04

    steps:
      - uses: actions/checkout@v4

      - name: Installer Rust
        uses: dtolnay/rust-toolchain@stable

      - name: Cache Rust
        uses: swatinem/rust-cache@v2
        with:
          workspaces: './src-tauri -> target'

      - name: Installer les dépendances système
        run: |
          sudo apt-get update
          sudo apt-get install -y \
            libwebkit2gtk-4.1-dev \
            libappindicator3-dev \
            librsvg2-dev \
            patchelf

      - name: Lancer les tests Rust
        working-directory: ./src-tauri
        run: cargo test --lib -- --nocapture

  frontend-tests:
    name: Tests Frontend
    runs-on: ubuntu-22.04

    steps:
      - uses: actions/checkout@v4

      - name: Installer Node.js
        uses: actions/setup-node@v4
        with:
          node-version: '24'
          cache: 'npm'

      - name: Installer les dépendances
        run: npm ci

      - name: Lancer les tests frontend
        run: npm test
