name: Playwright Tests

on:
  workflow_dispatch:
  workflow_call:

permissions:
  contents: read

jobs:
  test:
    runs-on: ubuntu-latest
    permissions:
      contents: read

    timeout-minutes: 60

    steps:
    - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
      with:
        persist-credentials: false
    - uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
      with:
        check-latest: true
        node-version: lts/*
    - name: Install dependencies
      run: npm i
    - name: Generate CSP
      run: node scripts/prepare-swagger-ui
    - name: Install Playwright Browsers
      run: npx playwright@1 install chromium --with-deps
    - name: Run Playwright tests
      run: npx playwright@1 test
