name: Dashboard Selenium Tests

on:
  workflow_dispatch:
  schedule:
    - cron: "0 6 * * *"

jobs:
  selenium-run:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v2
      - name: Setting up Python
        uses: actions/setup-python@v2
        with:
          python-version: "3.10"
      - name: Installing all necessary packages
        run: pip install -r  packages/dashboard/tests/frontend_selenium/requirements.txt
      - name: Node install
        uses: actions/setup-node@v3
        with:
          node-version: 18
      - name: Yarn install
        run: yarn install
      - name: Build
        run: |
          lerna run build --no-private
          yarn workspace @threefold/dashboard build
      - name: Yarn serve
        run: yarn workspace @threefold/dashboard serve &
      - name: Wait on localhost
        uses: iFaxity/wait-on-action@v1
        with:
          resource: http://localhost:8080
      - name: Run tests
        working-directory: ./packages/dashboard/tests/frontend_selenium
        env:
          TFCHAIN_MNEMONICS: ${{ secrets.TFCHAIN_MNEMONICS }}
          TFCHAIN_NODE_MNEMONICS: ${{ secrets.TFCHAIN_NODE_MNEMONICS }}
          STELLAR_ADDRESS: ${{ secrets.STELLAR_ADDRESS }}
        run: python -m pytest -v
