Treasury & Bank Transfer Management System — سامانه مدیریت خزانهداری و حوالههای بانکی
test: verify real packaged Windows TreasuryFlow process, readiness and disabled bank
davoodmehraban89 committed
Oct 16, 2026 at 21:26 UTC
5afcff9a1a70e41878cc598050ce251fb4e39af7
1 file changed
+47
scripts/windows-vm-treasury-smoke.ps1
new
+47
@@ -0,0 +1,47 @@
1
+param([Parameter(Mandatory=$true)][string]$SourceRoot)
2
+$ErrorActionPreference='Stop'
3
+$dir=Join-Path $env:RUNNER_TEMP 'treasuryflow-vm-evidence'
4
+New-Item -ItemType Directory -Path $dir -Force|Out-Null
5
+$report=[ordered]@{
6
+ sourceVersion=$env:LAB_VERSION; portableExeFound=$false; windowsProcessStarted=$false;
7
+ httpReady=$false; bankAdapterDisabled=$false; userInterfaceHtmlLoaded=$false;
8
+ outcome='NOT_RUN'
9
+}
10
+$p=$null
11
+try{
12
+ $exe=@(Get-ChildItem (Join-Path $SourceRoot 'release') -Filter 'TreasuryFlow-*-Windows-x64.exe' -File |
13
+ Where-Object {$_.Name -notlike '*Setup*'} | Sort-Object LastWriteTime -Descending)
14
+ if($exe.Count -lt 1){throw 'PORTABLE_EXE_NOT_FOUND'}
15
+ $report.portableExeFound=$true
16
+ $report.exeSha256=(Get-FileHash $exe[0].FullName -Algorithm SHA256).Hash
17
+ $env:BANK_ADAPTER_MODE='disabled'
18
+ $env:TREASURYFLOW_DATA_FILE=Join-Path $dir 'vm-test-only.sqlite'
19
+ $p=Start-Process -FilePath $exe[0].FullName -PassThru
20
+ $report.windowsProcessStarted=$true
21
+ for($i=0;$i -lt 90;$i++){
22
+ Start-Sleep -Milliseconds 700
23
+ if($p.HasExited){throw 'WINDOWS_DESKTOP_PROCESS_EXITED_EARLY'}
24
+ try{
25
+ $ready=Invoke-RestMethod 'http://127.0.0.1:3210/api/ready' -TimeoutSec 2
26
+ if($ready.status -eq 'ready'){
27
+ $report.httpReady=$true
28
+ $report.bankAdapterDisabled=($ready.bankAdapter -eq 'disabled')
29
+ break
30
+ }
31
+ }catch{}
32
+ }
33
+ if(!$report.httpReady){throw 'PACKAGED_HTTP_READY_TIMEOUT'}
34
+ if(!$report.bankAdapterDisabled){throw 'BANK_NOT_DISABLED'}
35
+ $html=Invoke-WebRequest 'http://127.0.0.1:3210' -TimeoutSec 15
36
+ $report.userInterfaceHtmlLoaded=($html.StatusCode -eq 200 -and $html.Content -match 'TreasuryFlow')
37
+ if(!$report.userInterfaceHtmlLoaded){throw 'PACKAGED_UI_HTML_FAILED'}
38
+ $report.outcome='PACKAGED_PROCESS_AND_HTTP_PASS'
39
+ 'Real packaged Windows process + local HTTP readiness + homepage: PASS.' >> $env:GITHUB_STEP_SUMMARY
40
+}catch{
41
+ $report.outcome='FAIL'
42
+ $report.reason=$_.Exception.Message
43
+ throw
44
+}finally{
45
+ if($p -and !$p.HasExited){try{& taskkill.exe /T /F /PID $p.Id | Out-Null}catch{}}
46
+ $report|ConvertTo-Json -Depth 3|Set-Content (Join-Path $dir 'runtime.json') -Encoding UTF8
47
+}