mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-02-18 00:17:39 +01:00
Implements end-to-end testing infrastructure for the Pulse update flow, validating the entire path from UI to backend with controllable test scenarios. ## What's Included ### Test Infrastructure - Mock GitHub release server (Go) with controllable failure modes - Docker Compose test environment (isolated services) - Playwright test framework with TypeScript - 60+ test cases across 6 test suites - Helper library with 20+ reusable test utilities ### Test Scenarios 1. Happy Path (8 tests) - Valid checksums, successful update flow - Modal appears exactly once - Complete end-to-end validation 2. Bad Checksums (8 tests) - Server rejects invalid checksums - Error shown ONCE (not twice) - fixes v4.28.0 issue type - User-friendly error messages 3. Rate Limiting (9 tests) - Multiple rapid requests throttled gracefully - Proper rate limit headers - Clear error messages 4. Network Failure (10 tests) - Exponential backoff retry logic - Timeout handling - Graceful degradation 5. Stale Release (10 tests) - Backend refuses flagged releases - Informative error messages - Proper rejection logging 6. Frontend Validation (15 tests) - UpdateProgressModal appears exactly once - No duplicate modals on error - User-friendly error messages - Proper accessibility attributes ### CI/CD Integration - GitHub Actions workflow (.github/workflows/test-updates.yml) - Runs on PRs touching update-related code - Separate test runs for each scenario - Regression test to verify v4.28.0 issue prevention - Automatic artifact uploads ### Documentation - README.md: Architecture and overview - QUICK_START.md: Getting started guide - IMPLEMENTATION_SUMMARY.md: Complete implementation details - Helper scripts for setup and test execution ## Success Criteria Met ✅ Tests run in CI on every PR touching update code ✅ All scenarios pass reliably ✅ Tests catch v4.28.0 checksum issue type automatically ✅ Frontend UX regressions are blocked ## Usage ```bash cd tests/integration ./scripts/setup.sh # One-time setup npm test # Run all tests ``` See QUICK_START.md for detailed instructions. Addresses requirements from issue for comprehensive update flow testing with specific focus on preventing duplicate error modals and ensuring checksum validation works correctly.
111 lines
2.8 KiB
Bash
Executable File
111 lines
2.8 KiB
Bash
Executable File
#!/bin/bash
|
|
#
|
|
# Setup script for Pulse update integration tests
|
|
# Prepares the test environment and installs dependencies
|
|
#
|
|
|
|
set -e
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
TEST_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
|
|
|
|
echo "==================================="
|
|
echo "Pulse Update Integration Test Setup"
|
|
echo "==================================="
|
|
echo ""
|
|
|
|
# Check prerequisites
|
|
echo "Checking prerequisites..."
|
|
|
|
# Check Docker
|
|
if ! command -v docker &> /dev/null; then
|
|
echo "❌ Docker is not installed. Please install Docker first."
|
|
exit 1
|
|
fi
|
|
echo "✅ Docker is available"
|
|
|
|
# Check Docker Compose
|
|
if ! command -v docker-compose &> /dev/null && ! docker compose version &> /dev/null; then
|
|
echo "❌ Docker Compose is not installed. Please install Docker Compose first."
|
|
exit 1
|
|
fi
|
|
echo "✅ Docker Compose is available"
|
|
|
|
# Check Node.js
|
|
if ! command -v node &> /dev/null; then
|
|
echo "❌ Node.js is not installed. Please install Node.js 18+ first."
|
|
exit 1
|
|
fi
|
|
|
|
NODE_VERSION=$(node -v | cut -d'v' -f2 | cut -d'.' -f1)
|
|
if [ "$NODE_VERSION" -lt 18 ]; then
|
|
echo "❌ Node.js version 18 or higher is required (found: $(node -v))"
|
|
exit 1
|
|
fi
|
|
echo "✅ Node.js $(node -v) is available"
|
|
|
|
# Check Go
|
|
if ! command -v go &> /dev/null; then
|
|
echo "⚠️ Go is not installed. Mock server build may fail."
|
|
else
|
|
echo "✅ Go $(go version | awk '{print $3}') is available"
|
|
fi
|
|
|
|
echo ""
|
|
echo "Installing npm dependencies..."
|
|
cd "$TEST_ROOT"
|
|
|
|
if [ -f "package-lock.json" ]; then
|
|
npm ci
|
|
else
|
|
npm install
|
|
fi
|
|
|
|
echo ""
|
|
echo "Installing Playwright browsers..."
|
|
npx playwright install chromium
|
|
npx playwright install-deps chromium
|
|
|
|
echo ""
|
|
echo "Building mock GitHub server..."
|
|
cd "$TEST_ROOT/mock-github-server"
|
|
|
|
if [ -f "go.mod" ]; then
|
|
go mod download
|
|
echo "✅ Go dependencies downloaded"
|
|
fi
|
|
|
|
echo ""
|
|
echo "Building Docker images..."
|
|
cd "$TEST_ROOT"
|
|
|
|
# Build mock GitHub server image
|
|
docker build -t pulse-mock-github:test ./mock-github-server
|
|
echo "✅ Mock GitHub server image built"
|
|
|
|
# Build Pulse test image (from root of repo)
|
|
cd "$TEST_ROOT/../.."
|
|
if [ -f "Dockerfile" ]; then
|
|
docker build -t pulse:test -f Dockerfile .
|
|
echo "✅ Pulse test image built"
|
|
else
|
|
echo "⚠️ Pulse Dockerfile not found. Using published image instead."
|
|
fi
|
|
|
|
echo ""
|
|
echo "==================================="
|
|
echo "✅ Setup complete!"
|
|
echo "==================================="
|
|
echo ""
|
|
echo "Next steps:"
|
|
echo " 1. Run all tests: npm test"
|
|
echo " 2. Run specific test: npx playwright test tests/01-happy-path.spec.ts"
|
|
echo " 3. View UI: npm run test:ui"
|
|
echo " 4. Debug mode: npm run test:debug"
|
|
echo ""
|
|
echo "Docker commands:"
|
|
echo " Start services: npm run docker:up"
|
|
echo " Stop services: npm run docker:down"
|
|
echo " View logs: npm run docker:logs"
|
|
echo ""
|