name: Unit tests
on:
  pull_request:
    push:
      branches:
        - main
        
jobs:
  # jest_tests:
  #   name: Run tests with Jest
  #   runs-on: ubuntu-latest
  #   if: ${{ false }}  # disable since there are no jest test yet
  #   steps:
  #   - uses: actions/checkout@v3
  #   - uses: actions/setup-node@v3
  #     with:
  #       node-version: 18
  #       cache: 'yarn'
  #   - name: Install dependencies
  #     run: yarn install --frozen-lockfile
  #   - name: Run tests
  #     run: yarn test:jest

  pw_tests:
    name: Run components visual tests with PlayWright
    runs-on: ubuntu-latest
    container:
      image: mcr.microsoft.com/playwright:v1.28.0-focal

    steps:
      - run: apt-get update && apt-get install git-lfs
      - uses: actions/checkout@v3
        with:
          lfs: 'true'
      - uses: actions/setup-node@v3
        with:
          node-version: 18
          cache: 'yarn'
      - name: Install dependencies
        run: yarn install --frozen-lockfile
      - name: Run your tests
        run: HOME=/root yarn test:pw
      - name: Upload test results
        if: always()
        uses: actions/upload-artifact@v2
        with:
          name: playwright-report
          path: playwright-report