<# One-command smoke test for an extracted Luminary bundle on Windows. Run it from the extracted bundle folder (or pass -Bundle): powershell -ExecutionPolicy Bypass -File .\SMOKE-WINDOWS.ps1 It writes smoke-report.txt next to the bundle and prints the same lines. Exit code 0 means every check passed. What it covers without a human clicking: - OS version and architecture, and whether the WebView2 runtime is present - the bundle files the launcher needs, and -Verify's own result - a real server boot in desktop mode: /api/health local:true, /api/auth/me 200 without a cookie, /api/sync 200 - LuminaryWindow.exe launching, staying alive and owning a window titled Luminary (the native WebView2 path) - Stop actually stopping the server It is deliberately conservative: it uses a throwaway data folder under %TEMP% and a port that is unlikely to collide, so it never touches a real catalog. #> [CmdletBinding()] param( [string]$Bundle = (Split-Path -Parent $MyInvocation.MyCommand.Path), [int]$Port = 8912, [int]$WindowSeconds = 8 ) $ErrorActionPreference = 'Stop' $script:lines = @() $script:failed = 0 function Say([string]$text) { $script:lines += $text Write-Host $text } function Check([string]$name, [bool]$ok, [string]$detail = '') { if ($ok) { Say (" PASS {0}{1}" -f $name, $(if ($detail) { " — $detail" } else { '' })) } else { $script:failed += 1 Say (" FAIL {0}{1}" -f $name, $(if ($detail) { " — $detail" } else { '' })) } return $ok } function Get-WebView2Version { $keys = @( 'HKLM:\SOFTWARE\WOW6432Node\Microsoft\EdgeUpdate\Clients\{F3017226-FE2A-4295-8BDF-00C3A9A7E4C5}', 'HKLM:\SOFTWARE\Microsoft\EdgeUpdate\Clients\{F3017226-FE2A-4295-8BDF-00C3A9A7E4C5}', 'HKCU:\SOFTWARE\Microsoft\EdgeUpdate\Clients\{F3017226-FE2A-4295-8BDF-00C3A9A7E4C5}' ) foreach ($key in $keys) { try { $value = (Get-ItemProperty -Path $key -Name pv -ErrorAction Stop).pv if ($value) { return $value } } catch { } } return $null } $nodeExe = Join-Path $Bundle 'node.exe' $appDir = Join-Path $Bundle 'app' $entry = Join-Path $appDir 'server\index.mjs' $windowExe = Join-Path $Bundle 'LuminaryWindow.exe' $launcher = Join-Path $Bundle 'Luminary.ps1' $dataDir = Join-Path $env:TEMP ('luminary-smoke-{0}' -f [guid]::NewGuid().ToString('N')) $url = "http://127.0.0.1:$Port" $server = $null $window = $null Say 'Luminary Windows smoke test' Say (" bundle {0}" -f $Bundle) Say (" time {0}" -f (Get-Date).ToString('s')) try { $os = Get-CimInstance Win32_OperatingSystem Say '' Say 'Environment' Say (" OS {0} (build {1})" -f $os.Caption, $os.BuildNumber) Say (" arch {0}" -f $env:PROCESSOR_ARCHITECTURE) $webview2 = Get-WebView2Version Say (" webview {0}" -f $(if ($webview2) { "runtime $webview2" } else { 'NOT INSTALLED' })) Say '' Say 'Bundle' Check 'node.exe present' (Test-Path -LiteralPath $nodeExe) $nodeExe Check 'app\server\index.mjs present' (Test-Path -LiteralPath $entry) $entry Check 'Luminary.ps1 present' (Test-Path -LiteralPath $launcher) $launcher Check 'LuminaryWindow.exe present' (Test-Path -LiteralPath $windowExe) $windowExe if (Test-Path -LiteralPath $launcher) { $verify = Start-Process -FilePath 'powershell.exe' -ArgumentList @( '-NoProfile', '-ExecutionPolicy', 'Bypass', '-File', $launcher, '-Verify' ) -Wait -PassThru -WindowStyle Hidden Check '-Verify exits 0' ($verify.ExitCode -eq 0) ("exit {0}" -f $verify.ExitCode) } if (-not (Test-Path -LiteralPath $nodeExe)) { throw 'node.exe is missing, cannot start the server' } if (-not (Test-Path -LiteralPath $entry)) { throw 'app\server\index.mjs is missing, cannot start the server' } New-Item -ItemType Directory -Force -Path $dataDir | Out-Null $env:PORT = "$Port" $env:HOST = '127.0.0.1' $env:NODE_ENV = 'production' $env:LUMINARY_DATA = $dataDir $env:LUMINARY_LOCAL = '1' Say '' Say 'Server (desktop mode)' $server = Start-Process -FilePath $nodeExe -ArgumentList @('"' + $entry + '"') ` -WorkingDirectory $appDir -WindowStyle Hidden -PassThru ` -RedirectStandardOutput (Join-Path $dataDir 'out.log') ` -RedirectStandardError (Join-Path $dataDir 'err.log') $deadline = (Get-Date).AddSeconds(90) $health = $null while ((Get-Date) -lt $deadline) { try { $response = Invoke-WebRequest -UseBasicParsing -TimeoutSec 2 -Uri "$url/api/health" if ($response.StatusCode -eq 200) { $health = $response.Content | ConvertFrom-Json; break } } catch { } Start-Sleep -Milliseconds 500 } Check 'health answers' ($null -ne $health) if ($health) { Check 'local mode advertised' ($health.local -eq $true) ("local={0}" -f $health.local) Check 'no setup prompt' ($health.needsSetup -eq $false) Check 'registration closed' ($health.registrationOpen -eq $false) } try { $me = Invoke-WebRequest -UseBasicParsing -TimeoutSec 5 -Uri "$url/api/auth/me" $who = $me.Content | ConvertFrom-Json Check 'signed in without a cookie' ($me.StatusCode -eq 200) ("{0} ({1})" -f $who.user.email, $who.user.role) } catch { Check 'signed in without a cookie' $false $_.Exception.Message } try { $sync = Invoke-WebRequest -UseBasicParsing -TimeoutSec 15 -Uri "$url/api/sync" Check '/api/sync answers' ($sync.StatusCode -eq 200) } catch { Check '/api/sync answers' $false $_.Exception.Message } Say '' Say 'Window (WebView2)' if (-not (Test-Path -LiteralPath $windowExe)) { Say ' SKIP LuminaryWindow.exe is not in this bundle' } else { $window = Start-Process -FilePath $windowExe -ArgumentList @('--url', $url) -PassThru Start-Sleep -Seconds $WindowSeconds $window.Refresh() $alive = -not $window.HasExited Check 'window process alive' $alive $(if ($alive) { 'pid ' + $window.Id } else { 'exited early' }) if ($alive) { $title = $window.MainWindowTitle Check 'window titled Luminary' ($title -eq 'Luminary') ("title '{0}'" -f $title) } if (-not $window.HasExited) { Stop-Process -Id $window.Id -Force } } } catch { Say (" ERROR {0}" -f $_.Exception.Message) $script:failed += 1 } finally { if ($window -and -not $window.HasExited) { Stop-Process -Id $window.Id -Force -ErrorAction SilentlyContinue } if ($server -and -not $server.HasExited) { Stop-Process -Id $server.Id -Force -ErrorAction SilentlyContinue } Remove-Item -LiteralPath $dataDir -Recurse -Force -ErrorAction SilentlyContinue Say '' if ($script:failed -eq 0) { Say 'RESULT: PASS' } else { Say ("RESULT: FAIL ({0} check(s))" -f $script:failed) } try { $script:lines | Set-Content -LiteralPath (Join-Path $Bundle 'smoke-report.txt') -Encoding UTF8 } catch { } exit $(if ($script:failed -eq 0) { 0 } else { 1 }) }