# See: https://circleci.com/docs/2.0/configuration-reference
version: 2.1

orbs:
  # See the orb documentation here: https://circleci.com/developer/orbs/orb/circleci/browser-tools
  browser-tools: circleci/browser-tools@1.5.3

jobs:
  build-and-test:
    # These next lines define a Docker executor: https://circleci.com/docs/2.0/executor-types/
    # https://circleci.com/developer/orbs/orb/circleci/browser-tools
    docker:
      - image: cimg/node:22.15.0-browsers
    steps:
      - browser-tools/install-firefox
      - checkout
      - run: git submodule sync
      - run: git submodule update --init
      - run:
          name: NPM Install
          command: npm install --force
      - run:
          name: Build Project
          command: npm run build
      - run:
          name: Launch Server
          command: npm run server
          background: true
      - run:
          name: Launch Web
          command: sleep 10 && firefox "http://127.0.0.1:5777/utest/"
          background: true
      - run:
          name: Run tests
          command: sleep 15 && npm run test

workflows:
  # Inside the workflow, you provide the jobs you want to run, e.g this workflow runs the build-and-test job above.
  # CircleCI will run this workflow on every commit.
  # https://circleci.com/docs/2.0/configuration-reference/#workflows
  TestRunner:
    jobs:
      - build-and-test:
          filters:
            branches:
              ignore:
                # runs the github action
                - release
