name: "Run e2e Playwright"
description: "Run e2e Playwright"

inputs:
  options:
    description: 'Options'
    required: true
  test-runner:
    description: 'Test runner'
    required: false
    default: 'Playwright'
  artifact-name:
    description: Name of the artifact cache
    required: true

runs:
  using: "composite"
  steps:

    - name: Setup and run with options
      shell: bash
      run: |
        npm start > /dev/null &\

        printf "Waiting for the application to be ready..."
        while ! curl -sf ${PLAYWRIGHT_E2E_HOST} > /dev/null; do
          printf "."
          sleep 1
        done
        printf "\nApplication is ready.\n"

        echo "Running playwright tests with options ${{ inputs.options }}"
        npx nx run ${{ inputs.options }}-e2e:e2e
