name: CI (browser)

on:
  push:
    branches:
      - '**'
    paths:
      - 'packages/engine.io-parser/**'
      - 'packages/engine.io-client/**'
      - 'packages/socket.io-parser/**'
      - 'packages/socket.io-client/**'

permissions:
  contents: read

jobs:
  test-browser:
    runs-on: ubuntu-latest
    timeout-minutes: 20

    steps:
      - name: Checkout repository
        uses: actions/checkout@v4

      - name: Use Node.js 20
        uses: actions/setup-node@v4
        with:
          node-version: 20

      - name: Install dependencies
        run: npm ci

      - name: Compile each package
        run: npm run compile --workspaces --if-present

      - name: Run tests
        run: npm test --workspace=socket.io-parser --workspace=socket.io-client
        env:
          BROWSERS: 1
          SAUCE_USERNAME: ${{ secrets.SAUCE_USERNAME }}
          SAUCE_ACCESS_KEY: ${{ secrets.SAUCE_ACCESS_KEY }}
