- Updated Docker configuration for production deployment - Added SilverPay integration settings - Configured for admin.thebankofdebbie.giize.com deployment - Includes all recent security fixes and improvements 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
236 lines
9.3 KiB
PowerShell
236 lines
9.3 KiB
PowerShell
# LittleShop Comprehensive E2E Test Script
|
|
# Tests all major functionality including SilverPay settings
|
|
|
|
Write-Host "==========================================" -ForegroundColor Cyan
|
|
Write-Host "LittleShop E2E Test Suite" -ForegroundColor Cyan
|
|
Write-Host "==========================================" -ForegroundColor Cyan
|
|
Write-Host ""
|
|
|
|
# Configuration
|
|
$BASE_URL = "http://localhost:5010"
|
|
$ADMIN_URL = "$BASE_URL/Admin"
|
|
$API_URL = "$BASE_URL/api"
|
|
|
|
# Test counters
|
|
$TotalTests = 0
|
|
$PassedTests = 0
|
|
$FailedTests = 0
|
|
$TestResults = @()
|
|
|
|
# Function to print test result
|
|
function Print-TestResult {
|
|
param(
|
|
[bool]$Success,
|
|
[string]$TestName,
|
|
[string]$Details = ""
|
|
)
|
|
|
|
$Script:TotalTests++
|
|
|
|
if ($Success) {
|
|
Write-Host "✅ PASS: $TestName" -ForegroundColor Green
|
|
if ($Details) { Write-Host " $Details" -ForegroundColor Gray }
|
|
$Script:PassedTests++
|
|
$Script:TestResults += @{Name=$TestName; Status="PASS"; Details=$Details}
|
|
} else {
|
|
Write-Host "❌ FAIL: $TestName" -ForegroundColor Red
|
|
if ($Details) { Write-Host " $Details" -ForegroundColor Yellow }
|
|
$Script:FailedTests++
|
|
$Script:TestResults += @{Name=$TestName; Status="FAIL"; Details=$Details}
|
|
}
|
|
}
|
|
|
|
# Function to test endpoint
|
|
function Test-Endpoint {
|
|
param(
|
|
[string]$Url,
|
|
[int]$ExpectedStatus,
|
|
[string]$Description
|
|
)
|
|
|
|
try {
|
|
$response = Invoke-WebRequest -Uri $Url -Method GET -UseBasicParsing -ErrorAction SilentlyContinue
|
|
$statusCode = $response.StatusCode
|
|
} catch {
|
|
$statusCode = $_.Exception.Response.StatusCode.value__
|
|
}
|
|
|
|
if ($statusCode -eq $ExpectedStatus) {
|
|
Print-TestResult -Success $true -TestName $Description -Details "Status: $statusCode"
|
|
} else {
|
|
Print-TestResult -Success $false -TestName $Description -Details "Expected: $ExpectedStatus, Got: $statusCode"
|
|
}
|
|
}
|
|
|
|
# Function to test API endpoint with JSON
|
|
function Test-ApiJson {
|
|
param(
|
|
[string]$Url,
|
|
[string]$Description
|
|
)
|
|
|
|
try {
|
|
$response = Invoke-RestMethod -Uri $Url -Method GET -ContentType "application/json" -ErrorAction Stop
|
|
Print-TestResult -Success $true -TestName $Description -Details "Valid JSON response"
|
|
} catch {
|
|
Print-TestResult -Success $false -TestName $Description -Details $_.Exception.Message
|
|
}
|
|
}
|
|
|
|
Write-Host "1. TESTING HEALTH & INFRASTRUCTURE" -ForegroundColor Yellow
|
|
Write-Host "-----------------------------------"
|
|
|
|
# First, check if the application is running
|
|
try {
|
|
$healthCheck = Invoke-WebRequest -Uri $BASE_URL -Method GET -UseBasicParsing -TimeoutSec 5 -ErrorAction Stop
|
|
Write-Host "✓ Application is running on $BASE_URL" -ForegroundColor Green
|
|
} catch {
|
|
Write-Host "⚠️ Application not running on $BASE_URL. Starting it now..." -ForegroundColor Yellow
|
|
# The app should already be running from your background process
|
|
}
|
|
|
|
Test-Endpoint -Url "$BASE_URL" -ExpectedStatus 200 -Description "Home page accessible"
|
|
Test-Endpoint -Url "$BASE_URL/health" -ExpectedStatus 200 -Description "Health check endpoint"
|
|
Test-Endpoint -Url "$ADMIN_URL/Account/Login" -ExpectedStatus 200 -Description "Admin login page"
|
|
|
|
Write-Host ""
|
|
Write-Host "2. TESTING PUBLIC API ENDPOINTS" -ForegroundColor Yellow
|
|
Write-Host "--------------------------------"
|
|
Test-ApiJson -Url "$API_URL/catalog/categories" -Description "Get categories API"
|
|
Test-ApiJson -Url "$API_URL/catalog/products" -Description "Get products API"
|
|
Test-Endpoint -Url "$API_URL/currencies" -ExpectedStatus 200 -Description "Get supported currencies"
|
|
|
|
Write-Host ""
|
|
Write-Host "3. TESTING ADMIN PANEL PAGES" -ForegroundColor Yellow
|
|
Write-Host "-----------------------------"
|
|
# These should redirect to login if not authenticated
|
|
Test-Endpoint -Url "$ADMIN_URL/Dashboard" -ExpectedStatus 302 -Description "Dashboard (redirects to login)"
|
|
Test-Endpoint -Url "$ADMIN_URL/Categories" -ExpectedStatus 302 -Description "Categories page"
|
|
Test-Endpoint -Url "$ADMIN_URL/Products" -ExpectedStatus 302 -Description "Products page"
|
|
Test-Endpoint -Url "$ADMIN_URL/Orders" -ExpectedStatus 302 -Description "Orders page"
|
|
Test-Endpoint -Url "$ADMIN_URL/SystemSettings" -ExpectedStatus 302 -Description "System Settings page"
|
|
|
|
Write-Host ""
|
|
Write-Host "4. TESTING AUTHENTICATION" -ForegroundColor Yellow
|
|
Write-Host "-------------------------"
|
|
|
|
# Test login with invalid credentials
|
|
try {
|
|
$loginData = @{
|
|
Username = "invalid"
|
|
Password = "invalid"
|
|
}
|
|
$response = Invoke-WebRequest -Uri "$ADMIN_URL/Account/Login" -Method POST -Body $loginData -ContentType "application/x-www-form-urlencoded" -SessionVariable session -ErrorAction Stop
|
|
Print-TestResult -Success $true -TestName "Login endpoint responsive"
|
|
} catch {
|
|
if ($_.Exception.Response.StatusCode.value__ -eq 400 -or $_.Exception.Response.StatusCode.value__ -eq 401) {
|
|
Print-TestResult -Success $true -TestName "Login rejects invalid credentials"
|
|
} else {
|
|
Print-TestResult -Success $false -TestName "Login endpoint issue" -Details $_.Exception.Message
|
|
}
|
|
}
|
|
|
|
Write-Host ""
|
|
Write-Host "5. TESTING ORDER CREATION API" -ForegroundColor Yellow
|
|
Write-Host "-----------------------------"
|
|
|
|
$orderData = @{
|
|
identityReference = "test-user-123"
|
|
items = @(
|
|
@{
|
|
productId = "00000000-0000-0000-0000-000000000001"
|
|
quantity = 1
|
|
}
|
|
)
|
|
shippingName = "Test User"
|
|
shippingAddress = "123 Test St"
|
|
shippingCity = "Test City"
|
|
shippingPostCode = "12345"
|
|
shippingCountry = "US"
|
|
notes = "E2E Test Order"
|
|
} | ConvertTo-Json
|
|
|
|
try {
|
|
$response = Invoke-RestMethod -Uri "$API_URL/orders" -Method POST -Body $orderData -ContentType "application/json" -ErrorAction Stop
|
|
Print-TestResult -Success $true -TestName "Order creation endpoint" -Details "Order created successfully"
|
|
} catch {
|
|
# Check if it's a validation error (which is expected without real products)
|
|
if ($_.Exception.Response.StatusCode.value__ -eq 400 -or $_.Exception.Response.StatusCode.value__ -eq 404) {
|
|
Print-TestResult -Success $true -TestName "Order creation endpoint responsive" -Details "Validation working correctly"
|
|
} else {
|
|
Print-TestResult -Success $false -TestName "Order creation failed" -Details $_.Exception.Message
|
|
}
|
|
}
|
|
|
|
Write-Host ""
|
|
Write-Host "6. TESTING SILVERPAY INTEGRATION" -ForegroundColor Yellow
|
|
Write-Host "---------------------------------"
|
|
Test-Endpoint -Url "$API_URL/silverpay/test" -ExpectedStatus 200 -Description "SilverPay test endpoint"
|
|
|
|
# Test SilverPay webhook endpoint
|
|
Test-Endpoint -Url "$API_URL/silverpay/webhook" -ExpectedStatus 405 -Description "SilverPay webhook (GET should fail)"
|
|
|
|
Write-Host ""
|
|
Write-Host "7. TESTING STATIC RESOURCES" -ForegroundColor Yellow
|
|
Write-Host "----------------------------"
|
|
Test-Endpoint -Url "$BASE_URL/css/site.css" -ExpectedStatus 200 -Description "CSS files"
|
|
Test-Endpoint -Url "$BASE_URL/js/site.js" -ExpectedStatus 200 -Description "JavaScript files"
|
|
Test-Endpoint -Url "$BASE_URL/favicon.ico" -ExpectedStatus 200 -Description "Favicon"
|
|
Test-Endpoint -Url "$BASE_URL/manifest.json" -ExpectedStatus 200 -Description "PWA Manifest"
|
|
|
|
Write-Host ""
|
|
Write-Host "8. TESTING ERROR HANDLING" -ForegroundColor Yellow
|
|
Write-Host "-------------------------"
|
|
Test-Endpoint -Url "$BASE_URL/nonexistent" -ExpectedStatus 404 -Description "404 error handling"
|
|
Test-Endpoint -Url "$API_URL/nonexistent" -ExpectedStatus 404 -Description "API 404 handling"
|
|
|
|
Write-Host ""
|
|
Write-Host "9. TESTING SILVERPAY SETTINGS PAGE" -ForegroundColor Yellow
|
|
Write-Host "----------------------------------"
|
|
|
|
# Test with admin authentication
|
|
$adminCreds = @{
|
|
Username = "admin"
|
|
Password = "admin"
|
|
}
|
|
|
|
try {
|
|
# Login as admin
|
|
$loginResponse = Invoke-WebRequest -Uri "$ADMIN_URL/Account/Login" -Method POST -Body $adminCreds -ContentType "application/x-www-form-urlencoded" -SessionVariable adminSession -ErrorAction Stop
|
|
|
|
# Test accessing settings page
|
|
$settingsResponse = Invoke-WebRequest -Uri "$ADMIN_URL/SystemSettings" -WebSession $adminSession -ErrorAction Stop
|
|
|
|
if ($settingsResponse.Content -like "*SilverPay Integration Settings*") {
|
|
Print-TestResult -Success $true -TestName "SilverPay settings page accessible" -Details "Page contains SilverPay configuration"
|
|
} else {
|
|
Print-TestResult -Success $false -TestName "SilverPay settings page" -Details "Page doesn't contain expected content"
|
|
}
|
|
} catch {
|
|
Print-TestResult -Success $false -TestName "Admin authentication test" -Details $_.Exception.Message
|
|
}
|
|
|
|
Write-Host ""
|
|
Write-Host "==========================================" -ForegroundColor Cyan
|
|
Write-Host "E2E TEST SUMMARY" -ForegroundColor Cyan
|
|
Write-Host "==========================================" -ForegroundColor Cyan
|
|
Write-Host "Total Tests: $TotalTests"
|
|
Write-Host "Passed: $PassedTests" -ForegroundColor Green
|
|
Write-Host "Failed: $FailedTests" -ForegroundColor Red
|
|
|
|
if ($FailedTests -eq 0) {
|
|
Write-Host ""
|
|
Write-Host "✅ ALL TESTS PASSED!" -ForegroundColor Green
|
|
exit 0
|
|
} else {
|
|
Write-Host ""
|
|
Write-Host "⚠️ Some tests failed. Review the results above." -ForegroundColor Yellow
|
|
|
|
# Show failed tests summary
|
|
Write-Host ""
|
|
Write-Host "Failed Tests:" -ForegroundColor Red
|
|
$TestResults | Where-Object { $_.Status -eq "FAIL" } | ForEach-Object {
|
|
Write-Host " - $($_.Name): $($_.Details)" -ForegroundColor Red
|
|
}
|
|
exit 1
|
|
} |