|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +# Setup script for Estate Management UI Playwright Tests |
| 4 | +# This script helps set up the test environment |
| 5 | + |
| 6 | +set -e |
| 7 | + |
| 8 | +echo "================================================" |
| 9 | +echo "Estate Management UI - Playwright Tests Setup" |
| 10 | +echo "================================================" |
| 11 | +echo "" |
| 12 | + |
| 13 | +# Check if .NET is installed |
| 14 | +if ! command -v dotnet &> /dev/null; then |
| 15 | + echo "ERROR: .NET SDK not found. Please install .NET 10.0 SDK or later." |
| 16 | + exit 1 |
| 17 | +fi |
| 18 | + |
| 19 | +echo "✓ .NET SDK found: $(dotnet --version)" |
| 20 | +echo "" |
| 21 | + |
| 22 | +# Check if Docker is installed and running |
| 23 | +if ! command -v docker &> /dev/null; then |
| 24 | + echo "ERROR: Docker not found. Please install Docker." |
| 25 | + exit 1 |
| 26 | +fi |
| 27 | + |
| 28 | +if ! docker ps &> /dev/null; then |
| 29 | + echo "ERROR: Docker daemon is not running. Please start Docker." |
| 30 | + exit 1 |
| 31 | +fi |
| 32 | + |
| 33 | +echo "✓ Docker found and running" |
| 34 | +echo "" |
| 35 | + |
| 36 | +# Check for required Docker images |
| 37 | +echo "Checking for required Docker images..." |
| 38 | + |
| 39 | +if docker images | grep -q "securityservice.*latest"; then |
| 40 | + echo "✓ securityservice:latest found" |
| 41 | +else |
| 42 | + echo "✗ securityservice:latest NOT found" |
| 43 | + echo " You need to build this image from the existing integration tests." |
| 44 | + MISSING_IMAGES=true |
| 45 | +fi |
| 46 | + |
| 47 | +if docker images | grep -q "estatemanagementui.*latest"; then |
| 48 | + echo "✓ estatemanagementui:latest found" |
| 49 | +else |
| 50 | + echo "✗ estatemanagementui:latest NOT found" |
| 51 | + echo " You can build this image by running:" |
| 52 | + echo " docker build -t estatemanagementui:latest -f EstateManagementUI.BlazorServer/Dockerfile ." |
| 53 | + MISSING_IMAGES=true |
| 54 | +fi |
| 55 | + |
| 56 | +if [ "$MISSING_IMAGES" = true ]; then |
| 57 | + echo "" |
| 58 | + echo "WARNING: Some required Docker images are missing." |
| 59 | + echo "Tests will fail without these images." |
| 60 | + echo "Please build the required images before running tests." |
| 61 | + echo "" |
| 62 | +fi |
| 63 | + |
| 64 | +# Restore NuGet packages |
| 65 | +echo "Restoring NuGet packages..." |
| 66 | +dotnet restore EstateManagementUI.PlaywrightTests/EstateManagementUI.PlaywrightTests.csproj |
| 67 | +echo "" |
| 68 | + |
| 69 | +# Build the test project |
| 70 | +echo "Building test project..." |
| 71 | +dotnet build EstateManagementUI.PlaywrightTests/EstateManagementUI.PlaywrightTests.csproj |
| 72 | +echo "" |
| 73 | + |
| 74 | +# Install Playwright browsers |
| 75 | +echo "Installing Playwright browsers..." |
| 76 | +if command -v pwsh &> /dev/null; then |
| 77 | + pwsh -c "playwright install chromium" |
| 78 | +elif command -v playwright &> /dev/null; then |
| 79 | + playwright install chromium |
| 80 | +else |
| 81 | + echo "ERROR: playwright command not found." |
| 82 | + echo "After building, you can install it with:" |
| 83 | + echo " dotnet tool install --global Microsoft.Playwright.CLI" |
| 84 | + echo " playwright install chromium" |
| 85 | + exit 1 |
| 86 | +fi |
| 87 | +echo "" |
| 88 | + |
| 89 | +echo "================================================" |
| 90 | +echo "Setup Complete!" |
| 91 | +echo "================================================" |
| 92 | +echo "" |
| 93 | +echo "To run the tests:" |
| 94 | +echo " cd EstateManagementUI.PlaywrightTests" |
| 95 | +echo " dotnet test" |
| 96 | +echo "" |
| 97 | +echo "To run tests in verbose mode:" |
| 98 | +echo " dotnet test --logger \"console;verbosity=detailed\"" |
| 99 | +echo "" |
0 commit comments