name: Screenshot Tests

on:
  push:
    branches: [ master ]
  pull_request:
    branches: [ master ]

jobs:
  test:
    timeout-minutes: 60
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v7
    - uses: actions/setup-node@v7
      with:
        node-version: 24
        cache: 'npm'
    - name: Install dependencies
      run: npm ci
    - name: Build library and demo
      run: npm run build-demo
    - name: Install Playwright Browsers
      run: npx playwright install --with-deps chromium
    - name: Run Playwright tests
      run: npm run test:screenshots
    - uses: actions/upload-artifact@v7
      if: failure()
      with:
        name: test-results
        path: test-results/
        retention-days: 30
