Files
gold_land_user/scripts/docker-trial-smoke.ps1
safavimohadeseh78andCursor e3f0457dc9
Frontend CI / unit (test, type-check, build) (push) Successful in 1m11s
Frontend CI / browser E2E (frontend + pinned backend) (push) Failing after 2m48s
feat: complete server-backed six-lesson app and trial tooling
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-10-12 14:40:37 +03:30

61 lines
2.2 KiB
PowerShell

# Ephemeral trial stack smoke test — does not use production volumes or .env.docker.
param(
[int]$Port = 18080
)
$ErrorActionPreference = 'Stop'
$frontendRoot = Split-Path -Parent $PSScriptRoot
$project = "cgltrial$(Get-Random)"
$secret = ('trial-{0}' -f ('x' * 40))
$cors = "http://127.0.0.1:$Port"
$envFile = Join-Path $env:TEMP "cgl-trial-$project.env"
@"
JWT_SECRET=$secret
CORS_ORIGIN=$cors
VITE_API_URL=/api
FRONTEND_PORT=$Port
"@ | Set-Content -Path $envFile -Encoding utf8
Push-Location $frontendRoot
try {
docker compose -p $project --env-file $envFile config | Out-Null
docker compose -p $project --env-file $envFile build
docker compose -p $project --env-file $envFile up -d
$deadline = (Get-Date).AddMinutes(3)
do {
Start-Sleep -Seconds 3
try {
$h = Invoke-WebRequest -Uri "http://127.0.0.1:$Port/health/ready" -UseBasicParsing
if ($h.StatusCode -eq 200) { break }
} catch { }
} while ((Get-Date) -lt $deadline)
$ready = Invoke-WebRequest -Uri "http://127.0.0.1:$Port/health/ready" -UseBasicParsing
if ($ready.StatusCode -ne 200) { throw 'readiness failed' }
$user = "trial_$([guid]::NewGuid().ToString('N').Substring(0,8))"
$body = @{ username = $user; password = 'pass1234'; name = 'Trial' } | ConvertTo-Json
$reg = Invoke-WebRequest -Uri "http://127.0.0.1:$Port/api/auth/register" -Method POST -Body $body -ContentType 'application/json; charset=utf-8' -UseBasicParsing
$token = ($reg.Content | ConvertFrom-Json).token
$me = Invoke-WebRequest -Uri "http://127.0.0.1:$Port/api/me" -Headers @{ Authorization = "Bearer $token" } -UseBasicParsing
if ($me.StatusCode -ne 200) { throw 'GET /api/me failed' }
$spa = Invoke-WebRequest -Uri "http://127.0.0.1:$Port/map" -UseBasicParsing
if ($spa.Content -notmatch 'html') { throw 'SPA route failed' }
$backendPorts = docker compose -p $project ps --format json | ConvertFrom-Json
foreach ($svc in $backendPorts) {
if ($svc.Service -eq 'backend' -and $svc.Publishers) {
throw 'backend must not publish host ports'
}
}
Write-Host 'docker-trial-smoke: OK'
}
finally {
docker compose -p $project --env-file $envFile down -v --remove-orphans 2>$null
Remove-Item $envFile -Force -ErrorAction SilentlyContinue
Pop-Location
}