Skip to content

playwright base setup [WIP] #13

playwright base setup [WIP]

playwright base setup [WIP] #13

Workflow file for this run

name: 🎭 Playwright E2E Tests
on:
pull_request:
types: [opened, synchronize, reopened]
workflow_dispatch:
jobs:
e2e-tests:
name: πŸ§ͺ E2E Tests
timeout-minutes: 60
runs-on: ubuntu-22.04
env:
NODE_ENV: test
NEXTAUTH_SECRET: 'test-secret-for-ci-only'
NEXT_PUBLIC_EXAMPLE_VARIABLE: 'CI Test Variable'
PRIVATE_EXAMPLE_VARIABLE: 'Private CI Test Variable'
CI: true
steps:
- name: πŸ“₯ Checkout Repository
uses: actions/checkout@v4
- name: πŸ’» Node setup
uses: ./.github/actions/node-setup
- name: πŸ’Ύ Cache Playwright browsers
uses: actions/cache@v4
with:
path: ~/.cache/ms-playwright
key: ${{ runner.os }}-playwright-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-playwright-
- name: 🎭 E2E Setup
uses: ./.github/actions/e2e-setup
with:
browsers: 'chromium'
- name: πŸ—οΈ Build Frontend App
run: pnpm --filter @infinum/frontend build
shell: bash
- name: πŸš€ Start Frontend App (Background)
run: |
echo "πŸ”§ Environment variables:"
echo "NODE_ENV: $NODE_ENV"
echo "NEXTAUTH_SECRET: ${NEXTAUTH_SECRET:0:10}..."
echo ""
echo "πŸš€ Starting server..."
node apps/frontend/.next/standalone/apps/frontend/server.js &
SERVER_PID=$!
echo "FRONTEND_PID=$SERVER_PID" >> $GITHUB_ENV
echo "βœ… Server started with PID: $SERVER_PID"
sleep 2
echo "πŸ“Š Server process status:"
ps aux | grep $SERVER_PID || echo "❌ Server process not found"
shell: bash
env:
NODE_ENV: production
NEXTAUTH_SECRET: 'test-secret-for-ci-only'
NEXT_PUBLIC_EXAMPLE_VARIABLE: 'CI Test Variable'
PRIVATE_EXAMPLE_VARIABLE: 'Private CI Test Variable'
- name: ⏳ Wait for Frontend to be Ready
run: |
echo "⏳ Waiting for frontend to start on http://localhost:3000..."
ATTEMPT=0
MAX_ATTEMPTS=20
until curl -f http://localhost:3000 > /dev/null 2>&1; do
ATTEMPT=$((ATTEMPT + 1))
echo "πŸ”„ Attempt $ATTEMPT/$MAX_ATTEMPTS - waiting for frontend..."
if [ $ATTEMPT -eq $MAX_ATTEMPTS ]; then
echo "❌ Frontend failed to start after $MAX_ATTEMPTS attempts"
echo "πŸ“Š Current processes:"
ps aux | grep -E "(node|next)" | grep -v grep
echo "πŸ” Checking port 3000:"
netstat -tulpn | grep 3000 || echo "No process on port 3000"
exit 1
fi
sleep 3
done
echo "βœ… Frontend is ready!"
shell: bash
- name: πŸ” Detailed Health Check
run: |
echo "πŸ₯ Running detailed health check..."
echo "πŸ“‘ HTTP response:"
curl -f http://localhost:3000 -I | head -10
echo ""
echo "πŸ“„ Basic page content:"
curl -s http://localhost:3000 | head -20
echo ""
echo "πŸ”— Testing login page:"
curl -s http://localhost:3000/login | head -10 || echo "❌ Login page not accessible"
echo ""
echo "βœ… Health check completed!"
shell: bash
- name: πŸ§ͺ Run Playwright E2E Tests
run: |
echo "🎬 Starting Playwright E2E Tests..."
echo "================================================"
pnpm e2e
echo "================================================"
echo "βœ… E2E Tests completed!"
- name: πŸ›‘ Stop Frontend App
shell: bash
if: always()
run: |
if [ ! -z "$FRONTEND_PID" ]; then
kill $FRONTEND_PID || true
fi