name: Test Codebase
on:
  pull_request:
    branches: [ main , develop]

permissions:
  contents: read

jobs:
  run_tests:
    name: Test Codebase
    runs-on: ubuntu-latest
    timeout-minutes: 5
    steps:
      - name: Checkout "${{ github.repository }}"
        uses: actions/checkout@v4

      - name: Set up Node v22
        uses: actions/setup-node@v4
        with:
          node-version: '22.5.1'

      - name: Install dependencies
        run:  |
          cd CoVAR-app && npm ci

      - name: Test Codebase
        run:  |
          cd CoVAR-app && npm run test


      - name: Jest Coverage Comment
        id: coverageComment
        uses: MishaKav/jest-coverage-comment@main
        with:
          hide-comment: true
          coverage-summary-path: ./CoVAR-app/coverage/coverage-summary.json

      - name: Check the output coverage
        run: |
          echo "Coverage Percentage - ${{ steps.coverageComment.outputs.coverage }}"
          echo "Coverage Color - ${{ steps.coverageComment.outputs.color }}"
          echo "Summary HTML - ${{ steps.coverageComment.outputs.summaryHtml }}"