Treasury & Bank Transfer Management System — سامانه مدیریت خزانه‌داری و حواله‌های بانکی

1 name: V6 combined Excel SQL lab and full native persistence UAT
2 on:
3 push:
4 paths:
5 - .github/workflows/v6-consolidated-native-uat-sql-excel-once.yml
6 workflow_dispatch:
7 permissions:
8 contents: read
9 jobs:
10 private-builder:
11 runs-on: windows-2022
12 timeout-minutes: 70
13 steps:
14 - name: Install Node 22
15 uses: actions/setup-node@v4
16 with:
17 node-version: '22'
18 - name: Verify private V6 builder from validated short staging path, no uploads
19 shell: pwsh
20 env:
21 TF_VALIDATION_READ_TOKEN: ${{ secrets.TF_VALIDATION_READ_TOKEN }}
22 run: |
23 $ErrorActionPreference='Stop'
24 if([string]::IsNullOrWhiteSpace($env:TF_VALIDATION_READ_TOKEN)){throw 'PRIVATE_READ_TOKEN_NOT_AVAILABLE'}
25 $env:GH_TOKEN=$env:TF_VALIDATION_READ_TOKEN
26 $private='davoodmehraban89/TreasuryFlow-Validation-Private'
27 $branch='0117960aeaec76eb164ca41e3f2be28d8921e98b'
28 $work=Join-Path $env:RUNNER_TEMP 'v6-protected-builder'
29 New-Item -ItemType Directory -Path $work -Force | Out-Null
30 $paths=@('qa/scripts/rebuild-v6-private-nonfinal-qa.ps1',
31 'qa/patches/v6-sql-assertion-fix.mjs',
32 'qa/patches/v6-add-readonly-sqlserver-adapter.mjs',
33 'qa/windows/v6-installed-native-gui-os-clipboard.mjs',
34 'qa/windows/v6-full-installed-gui-and-persistence.mjs',
35 'qa/windows/gui-readiness.mjs',
36 'qa/windows/synthetic-iban.mjs',
37 'qa/windows/v6-installed-excel-ui-negative-gate.mjs',
38 'qa/patches/v6-add-excel-isolated-preview.mjs',
39 'qa/tests/v6-excel-preview-validators.test.mjs',
40 'qa/windows/v6-native-excel-clipboard-acceptance.fragment.txt',
41 'qa/tests/v6-excel-security-and-fuzz.test.mjs',
42 'qa/patches/v6-add-synthetic-sql-lab-ui.mjs')
43 foreach($path in $paths){
44 $url="https://api.github.com/repos/$private/contents/${path}?ref=$branch"
45 $api=Invoke-RestMethod -Uri $url -Headers @{ Authorization="Bearer $env:TF_VALIDATION_READ_TOKEN"; Accept='application/vnd.github+json'; 'User-Agent'='TreasuryFlow-private-qa' }
46 if(!$api.content -or $api.encoding -ne 'base64'){throw 'PRIVATE_TEXT_FETCH_FAILED'}
47 $dest=Join-Path $work $path
48 New-Item -ItemType Directory -Path (Split-Path $dest -Parent) -Force | Out-Null
49 [IO.File]::WriteAllBytes($dest,[Convert]::FromBase64String(($api.content -replace '\s','')))
50 }
51 $archive=Join-Path $work 'TreasuryFlow_Validation_Staging_20261017.zip'
52 & gh release download validation-inputs-20261017 --repo $private --pattern TreasuryFlow_Validation_Staging_20261017.zip --dir $work *> (Join-Path $work 'release-fetch.log')
53 if($LASTEXITCODE -ne 0){throw 'PRIVATE_RELEASE_DOWNLOAD_FAILED'}
54 # The private read-only GitHub token is ONLY for fetching inputs.
55 # electron-builder can infer an unintended publish/update provider
56 # from GH_TOKEN after NSIS has otherwise successfully built.
57 Remove-Item Env:GH_TOKEN -ErrorAction SilentlyContinue
58 Remove-Item Env:GITHUB_TOKEN -ErrorAction SilentlyContinue
59 Remove-Item Env:TF_VALIDATION_READ_TOKEN -ErrorAction SilentlyContinue
60 Write-Host 'GATE_PASS_PRIVATE_DOWNLOAD_TOKEN_CLEARED_BEFORE_PACKAGING'
61 $destination=Join-Path $work 'run-once-candidate'
62 $privateLog=Join-Path $work 'full-builder-log-private.txt'
63 $errors=$null
64 $tokens=$null
65 [void][Management.Automation.Language.Parser]::ParseFile((Join-Path $work $paths[0]),[ref]$tokens,[ref]$errors)
66 if($errors.Count -gt 0){throw 'PRIVATE_BUILDER_POWERSHELL_PARSE_FAILED'}
67 & pwsh -NoProfile -File (Join-Path $work $paths[0]) -SourceArchive $archive -OutputRoot $destination -EnableExcelPreview -EnableSqlLab -UpgradeNextSecurity *> $privateLog
68 if($LASTEXITCODE -ne 0) {
69 $known='ORIGINAL_PRIVATE_SOURCE_HASH_MISMATCH|UNSAFE_ZIP_ENTRY_PATH|ARCHIVE_ENTRY_COUNT_LIMIT|ZIP_UNCOMPRESSED_SIZE_LIMIT|ZIP_SYMLINK_DISALLOWED|DUPLICATE_ZIP_ENTRY|EXTRACTED_REPARSE_POINT_DISALLOWED|OFFICIAL_XLSX_PACKAGE_LOCK_INTEGRITY_NOT_PINNED_TO_VERIFIED_ARCHIVE|SHEETJS_OFFICIAL_VENDOR_SHA256_MISMATCH|INITIAL_NPM_CI_FAILED|REMOVE_VULNERABLE_XLSX_FAILED|INSTALL_PINNED_OFFICIAL_XLSX_FAILED|PATCHED_LOCK_NPM_CI_FAILED|KNOWN_PRODUCTION_DEPENDENCY_ADVISORIES_REMAIN|V6_UNIT_REGRESSION_FAILED|V6_GATE_FAILED_[A-Z]+|V6_NSIS_BUILDER_FAILED|READ_ONLY_SQL_ADAPTER_PATCH_FAILED|SQL_EDITOR_TEST_PATCH_FAILED'
70 $nsisLog=Join-Path $destination 'private-local-logs/private-nsis.log'
71 if(Test-Path -LiteralPath $nsisLog){
72 $nsisText=Get-Content -LiteralPath $nsisLog -Raw
73 $knownClasses=[ordered]@{
74 NSIS_PROCESS='(?i)makensis|nsis'
75 NETWORK='(?i)ETIMEDOUT|ECONNRESET|socket hang up|download failed'
76 FILE_PATH='(?i)ENOENT|not found|cannot find module'
77 SIGNING='(?i)signing|certificate|winCodeSign'
78 ACCESS='(?i)EPERM|EACCES|access denied'
79 NATIVE_DEPENDENCY='(?i)node-gyp|npmRebuild|native dependency'
80 CONFIGURATION='(?i)configuration|invalid config|schema'
81 ASAR='(?i)asar|cannot pack'
82 WINDOWS_PATH_LENGTH='(?i)path too long|filename too long'
83 UNKNOWN_BUILDER_ERROR='(?i)error|failed|⨯'
84 }
85 $specificClasses=[ordered]@{
86 ASAR_ENTRY_MISSING='(?i)(?:Application entry file|main entry file|entry file.*does not exist)'
87 ELECTRON_MAIN_MISSING='(?i)(?:main\.cjs.*not found|main\.js.*not found|entrypoint.*missing)'
88 ELECTRON_APP_PACKAGE='(?i)(?:app\.asar.*does not exist|no app\.asar|invalid app package)'
89 FILE_ALREADY_EXISTS='(?i)(?:file already exists|EEXIST)'
90 PATH_IS_TOO_LONG='(?i)(?:ENAMETOOLONG|path too long|filename or extension is too long)'
91 UNRESOLVED_DEPENDENCY='(?i)(?:unresolved dependenc|missing dependenc|cannot resolve)'
92 APP_BUILDER_EXIT='(?i)(?:exit status [0-9]+|exit code [0-9]+|errorOut=)'
93 CODE_SIGN_FAILURE='(?i)(?:failed to sign|signing failed|signtool.*error)'
94 NSIS_MAKENSIS_FAILURE='(?i)(?:makensis.*failed|NSIS Error|failed to compile script)'
95 INTEGRITY_FAILURE='(?i)(?:integrity checksum failed|incorrect integrity|checksum mismatch)'
96 ZIP_FAILURE='(?i)(?:7zip.*error|failed to extract|archive corrupted)'
97 RUNNER_RESOURCE_FAILURE='(?i)(?:out of memory|ENOMEM|disk full|ENOSPC)'
98 WINDOWS_PROCESS_FAILURE='(?i)(?:spawn.*fail|The system cannot find|CreateProcess)'
99 PACKAGING_REBUILD_FAILURE='(?i)(?:failed to rebuild|rebuilding native|node-gyp failed)'
100 AFTER_PACK_HOOK_FAILURE='(?i)(?:afterPack.*fail|afterSign.*fail)'
101 PUBLISH_FAILURE='(?i)(?:publish.*fail|upload.*fail)'
102 }
103 foreach($name in $specificClasses.Keys){
104 Write-Host ('PRIVATE_QA_NSIS_SPECIFIC_'+$name+'='+[bool]($nsisText -match $specificClasses[$name]))
105 }
106 $releasePath=Join-Path $env:RUNNER_TEMP 'private-stage/release'
107 $binCount=@(Get-ChildItem -LiteralPath $releasePath -File -Filter '*.exe' -ErrorAction SilentlyContinue).Count
108 Write-Host ('PRIVATE_NSIS_RESULT_EXE_PRESENT='+[bool]($binCount -gt 0))
109 $lastLineCount=@($nsisText -split '\r?\n' | Where-Object {$_ -match '(?i)error|fail|exit|throw'}).Count
110 Write-Host ('PRIVATE_NSIS_ERROR_LIKE_LINE_COUNT='+[Math]::Min($lastLineCount,100))
111 $shortCodes=[regex]::Matches($nsisText,'\\b(?:ERR_[A-Z0-9_]{4,64}|E(?:ACCES|PERM|NOENT|EXIST|CONNRESET|TIMEDOUT|NOTFOUND|NOSPC|NAMETOOLONG|PROTO|AI_AGAIN))\\b')
112 $codes=@($shortCodes | ForEach-Object {$_.Value} | Select-Object -Unique | Select-Object -First 8)
113 if($codes.Count -gt 0){Write-Host ('PRIVATE_QA_NSIS_SAFE_ERROR_CODES='+($codes -join ','))}
114 foreach($name in $knownClasses.Keys){
115 Write-Host ('PRIVATE_QA_NSIS_DIAGNOSTIC_'+$name+'='+[bool]($nsisText -match $knownClasses[$name]))
116 }
117 }
118 $record=Get-Content $privateLog -Raw
119 $attempts=[regex]::Matches($record,'PRIVATE_QA_PHASE=NSIS_DIRECT_(?:BINARY_RETRY|RETRY_SUCCEEDED|RETRY_FAILED)')
120 Write-Host ('PRIVATE_QA_DIRECT_RETRY_MARKERS='+($attempts.Count))
121 foreach($a in $attempts){Write-Host ('PRIVATE_QA_ATTEMPT='+$a.Value)}
122 if(Test-Path -LiteralPath $nsisLog){
123 # Preapproved generic English vocabulary only. No raw log,
124 # private paths, URLs, source lines, values, IDs or credentials.
125 $allowed=@('error','failed','failure','fatal','exit','code','status','process','terminated',
126 'command','cannot','could','not','find','found','missing','invalid','unrecognized',
127 'unexpected','argument','unknown','required','option','file','directory','path',
128 'package','module','dependency','native','rebuild','electron','builder','nsis',
129 'sign','signing','certificate','installer','installation','configuration',
130 'config','schema','archive','asar','version','runtime','windows','win','setup',
131 'permission','access','denied','exception','execution','message','warning',
132 'artifact','output','input','executable','target','release','publish',
133 'upload','download','network','timeout','certificate','digest','hash',
134 'checksum','integrity','symlink','extract','copy','rename','remove',
135 'read','write','create','open','close','unsupported','environment',
136 'value','type','object','null','undefined','function','property','properties',
137 'string','number','boolean','parse','syntax','operation','system','is',
138 'was','with','at','to','in','from','for','and','or','of','on','the','a','an',
139 'after','before','during','while','as','due','because','by','already',
140 'exists','cannot','isnt','doesnt','trying','use','using','please',
141 'cannot','build','building','built','pack','packaging','unpack',
142 'not','proper','invalid','has','have','had','failed','called')
143 $failureLines=@($nsisText -split '\r?\n' | Where-Object {$_ -match '(?i)error|failed|exception|⨯'})
144 $terminalLine=if($failureLines.Count -gt 0){[string]$failureLines[$failureLines.Count-1]}else{''}
145 $words=@([regex]::Matches($terminalLine,'[A-Za-z]{2,24}') |
146 ForEach-Object {$_.Value.ToLowerInvariant()} |
147 Where-Object {$allowed -contains $_} | Select-Object -First 30)
148 Write-Host ('PRIVATE_QA_SAFE_ERROR_WORDS='+($words -join '_'))
149 }
150 $safeAuditFields=@(
151 'PRIVATE_QA_AUDIT_PROCESS_EXIT',
152 'PRIVATE_QA_AUDIT_JSON_PRESENT',
153 'PRIVATE_QA_AUDIT_HAS_METADATA',
154 'PRIVATE_QA_AUDIT_HAS_ERROR_FIELD',
155 'PRIVATE_QA_PRODUCTION_AUDIT_TOTAL',
156 'PRIVATE_QA_PRODUCTION_AUDIT_HIGH',
157 'PRIVATE_QA_PRODUCTION_AUDIT_CRITICAL',
158 'PRIVATE_QA_AUDIT_PUBLIC_VENDOR_NEXT',
159 'PRIVATE_QA_AUDIT_PUBLIC_VENDOR_REACT',
160 'PRIVATE_QA_AUDIT_PUBLIC_VENDOR_XLSX',
161 'PRIVATE_QA_AUDIT_PUBLIC_VENDOR_MSSQL'
162 )
163 foreach($field in $safeAuditFields){
164 $matching=[regex]::Match($record,[regex]::Escape($field)+'=(?:True|False|YES|[0-9]{1,4})')
165 if($matching.Success){Write-Host ('DIAGNOSTIC_'+$matching.Value)}
166 }
167 foreach($reason in @('KNOWN_PRODUCTION_DEPENDENCY_ADVISORIES_REMAIN','PRODUCTION_AUDIT_METADATA_UNAVAILABLE',
168 'PRODUCTION_AUDIT_JSON_PARSE_FAILED','PRODUCTION_AUDIT_PROCESS_NOT_CREATED',
169 'PRODUCTION_AUDIT_NONZERO_WITH_ZERO_DECLARED_ADVISORIES')){
170 Write-Host ('DIAGNOSTIC_AUDIT_REASON_'+$reason+'='+[bool]$record.Contains($reason))
171 }
172 $phases=[regex]::Matches($record,'PRIVATE_QA_PHASE=[A-Z_]+')
173 $lastPhase=if($phases.Count -gt 0){$phases[$phases.Count-1].Value}else{'PRIVATE_QA_PHASE=BEFORE_ARCHIVE_PREFLIGHT'}
174 Write-Host ('DIAGNOSTIC_LAST_VERIFIED_PHASE='+$lastPhase)
175 $match=[regex]::Match($record,$known)
176 $code=if($match.Success){$match.Value}else{'PRIVATE_BUILD_FAILED_DETAILS_RETAINED_ONLY_ON_EPHEMERAL_WINDOWS_RUNNER'}
177 try {
178 $probeRelease=Join-Path $env:RUNNER_TEMP 'private-stage/release'
179 $cand=@(Get-ChildItem -LiteralPath $probeRelease -Filter 'TreasuryFlow*.exe' -File -ErrorAction SilentlyContinue | Where-Object {$_.Length -gt 1000000})
180 Write-Host ('DIAGNOSTIC_INSTALLER_COUNT='+$cand.Count)
181 if($cand.Count -eq 1){
182 $testHome=Join-Path $env:RUNNER_TEMP 'v6-diagnostic-installed'
183 $testData=Join-Path $env:RUNNER_TEMP 'v6-diagnostic-data'
184 New-Item -ItemType Directory -Path $testData -Force | Out-Null
185 $p=Start-Process -FilePath $cand[0].FullName -ArgumentList @('/S',('/D='+$testHome)) -PassThru
186 if(!$p.WaitForExit(120000)){try{$p.Kill()}catch{};throw 'TEST_INSTALL_TIMED_OUT'}
187 if($p.ExitCode -ne 0){throw 'TEST_INSTALL_EXIT'}
188 $installedExe=@(Get-ChildItem -LiteralPath $testHome -Recurse -File -Filter 'TreasuryFlow.exe' -ErrorAction SilentlyContinue)
189 if($installedExe.Count -ne 1){throw 'TEST_EXE_NOT_INSTALLED'}
190 Write-Host 'PROBE_PASS_NSIS_INSTALL_WHILE_PACKAGER_EXIT_NONZERO'
191 & node (Join-Path $work $paths[3]) $installedExe[0].FullName $testData *> (Join-Path $work 'private-gui-probe.log')
192 if($LASTEXITCODE -eq 0){
193 $data=Get-Content (Join-Path $testData 'private-gui-report.json') -Raw | ConvertFrom-Json
194 if($data.status -eq 'PASS' -and $data.osClipboard){
195 Write-Host 'PROBE_PASS_REAL_WINDOWS_CLIPBOARD_WHILE_PACKAGER_EXIT_NONZERO'
196 }else{Write-Host 'PROBE_FAIL_GUI_ASSERTION'}
197 }else{Write-Host 'PROBE_FAIL_GUI_EXECUTION'}
198 $un=@(Get-ChildItem -LiteralPath $testHome -Recurse -File -Filter 'Uninstall*.exe' -ErrorAction SilentlyContinue)
199 if($un.Count -eq 1){
200 $up=Start-Process -FilePath $un[0].FullName -ArgumentList '/S' -PassThru
201 if($up.WaitForExit(90000) -and $up.ExitCode -eq 0){Write-Host 'PROBE_PASS_NSIS_UNINSTALL_WHILE_PACKAGER_EXIT_NONZERO'}
202 }
203 }
204 }catch{
205 Write-Host 'PROBE_FAIL_DIAGNOSTIC_INSTALL_OR_GUI'
206 }
207 throw $code
208 }
209 $deliverables=Join-Path $destination 'PRIVATE_QA_DELIVERABLES'
210 $proof=Get-Content (Join-Path $deliverables 'NONFINAL_QA_SHA256_MANIFEST.json') -Raw | ConvertFrom-Json
211 $source=Join-Path $deliverables 'TreasuryFlow_V6_1.0.1_Patched_NONFINAL_QA_Source.zip'
212 $exe=Join-Path $deliverables 'TreasuryFlow_V6_1.0.1_Patched_NONFINAL_QA_Setup.exe'
213 if(!(Test-Path $source) -or !(Test-Path $exe) -or $proof.finalRelease -ne $false -or $proof.v7FinalAccepted -ne $false -or $proof.productionNpmVulnerabilities -ne 0){throw 'NONFINAL_MANIFEST_POLICY_FAILED'}
214 if((Get-FileHash $source -Algorithm SHA256).Hash -ne $proof.patchedSourceSha256 -or
215 (Get-FileHash $exe -Algorithm SHA256).Hash -ne $proof.patchedInstallerSha256){throw 'NONFINAL_MANIFEST_DIGEST_MISMATCH'}
216 Write-Host 'PRIVATE_V6_PATCHED_SOURCE_AND_WINDOWS_SETUP_BUILD_PASS'
217 Write-Host 'PRIVATE_V6_NPM_SECURITY_TEST_TYPECHECK_LINT_BUILD_SMOKE_PASS'
218 Write-Host 'NO_SOURCE_OR_BINARY_UPLOADED_TO_PUBLIC_ARTIFACTS'
219 $env:TF_QA_STAGE_ROOT=Join-Path $env:RUNNER_TEMP 'private-stage'
220 & node --experimental-strip-types --test (Join-Path $work $paths[9]) *> (Join-Path $work 'private-validator-unit.log')
221 if($LASTEXITCODE -ne 0){throw 'EXCEL_PREVIEW_VALIDATOR_BEHAVIOR_TESTS_FAILED'}
222 Write-Host 'GATE_PASS_EXCEL_PREVIEW_IBAN_MOD97_AND_DATE_EDGE_UNIT_TESTS'
223 & node --experimental-strip-types --test (Join-Path $work $paths[11]) *> (Join-Path $work 'private-excel-fuzz.log')
224 if($LASTEXITCODE -ne 0){throw 'EXCEL_SECURITY_FUZZ_TESTS_FAILED'}
225 Write-Host 'GATE_PASS_EXCEL_SECURITY_AND_500_CASE_IBAN_FUZZ_TESTS'
226 $oldGuiSource=Get-Content (Join-Path $work $paths[3]) -Raw
227 $xlsFragment=Get-Content (Join-Path $work $paths[10]) -Raw
228 $insertBefore=" report.status='PASS';"
229 if(!$oldGuiSource.Contains($insertBefore)){throw 'WINDOWS_NATIVE_GUI_PATCH_ANCHOR_MISSING'}
230 $xlsGuiHarness=Join-Path $work 'qa/windows/v6-clipboard-xlsx-roundtrip.mjs'
231 [IO.File]::WriteAllText($xlsGuiHarness,
232 $oldGuiSource.Replace($insertBefore,$xlsFragment+$insertBefore),
233 [Text.UTF8Encoding]::new($false))
234 $env:TF_PRIVATE_STAGE=Join-Path $env:RUNNER_TEMP 'private-stage'
235 # Replay installed native GUI/clipboard acceptance on this exact built EXE.
236 & node --check $xlsGuiHarness
237 if($LASTEXITCODE -ne 0){throw 'INSTALLED_GUI_HARNESS_SYNTAX_FAILED'}
238 $env:BANK_ADAPTER_MODE='disabled'
239 $env:TREASURYFLOW_DESKTOP_LOCAL='1'
240 $env:TREASURYFLOW_ENABLE_MAYAN_EXTERNAL_READ='0'
241 $env:TREASURYFLOW_MAYAN_ENABLE_EXTERNAL_READ='0'
242 $env:TREASURYFLOW_ENABLE_SQL_LAB='0'
243 $isolation=Join-Path $env:RUNNER_TEMP 'v6-gui-test-data'
244 $installDir=Join-Path $env:RUNNER_TEMP 'TreasuryFlow-V6-Isolated-Installed'
245 New-Item -ItemType Directory -Path $isolation -Force | Out-Null
246 $install=Start-Process -FilePath $exe -ArgumentList @('/S',('/D='+$installDir)) -PassThru
247 if(!$install.WaitForExit(240000)){try{$install.Kill()}catch{};throw 'V6_NSIS_INSTALL_TIMEOUT'}
248 if($install.ExitCode -ne 0){throw 'V6_NSIS_NONZERO_EXIT'}
249 $installed=@(Get-ChildItem -LiteralPath $installDir -Recurse -Filter 'TreasuryFlow.exe' -File -ErrorAction SilentlyContinue)
250 if($installed.Count -ne 1){throw 'INSTALLED_V6_EXE_NOT_UNIQUE'}
251 Write-Host 'GATE_PASS_SAME_ARTIFACT_NSIS_INSTALL'
252 $guiLog=Join-Path $work 'private-installed-gui-log.txt'
253 & node $xlsGuiHarness $installed[0].FullName $isolation *> $guiLog
254 if($LASTEXITCODE -ne 0){
255 $guiRecord=Get-Content (Join-Path $isolation 'private-gui-report.json') -Raw | ConvertFrom-Json
256 $safe=$guiRecord.failure -replace '[^A-Z0-9_ ]',''
257 if(!$safe){$safe='UNKNOWN'}
258 throw ('V6_SAME_ARTIFACT_INSTALLED_GUI_FAILED_'+$safe)
259 }
260 $guiRecord=Get-Content (Join-Path $isolation 'private-gui-report.json') -Raw | ConvertFrom-Json
261 if($guiRecord.status -ne 'PASS' -or !$guiRecord.osClipboard -or !$guiRecord.bankDisabled -or
262 !$guiRecord.copyButton -or !$guiRecord.writable -or !$guiRecord.select){throw 'V6_SAME_ARTIFACT_GUI_REPORT_FAIL'}
263 Write-Host 'GATE_PASS_SAME_ARTIFACT_INSTALLED_WINDOWS_OS_CLIPBOARD'
264 if(!$guiRecord.excelNativeInput -or !$guiRecord.excelInvalidRejected -or
265 !$guiRecord.excelValidPreview -or !$guiRecord.excelNoPaymentSideEffects -or
266 !$guiRecord.excelRoundtrip -or !$guiRecord.excelUnsafeNumericRejected -or
267 !$guiRecord.excelInvalidDateRejected -or !$guiRecord.excelCaseFoldDuplicateRejected){throw ('NATIVE_EXCEL_ROUNDTRIP_FAILED_AT_'+([string]$guiRecord.stage -replace '[^A-Z0-9_]',''))}
268 Write-Host 'GATE_PASS_SAME_ARTIFACT_REAL_XLSX_FILE_INPUT_NEGATIVE_POSITIVE_EXPORT_ROUNDTRIP'
269
270 # Isolate SSR route availability independently of the CDP file-picker.
271 # This gate is deliberately NOT treated as positive workbook import.
272 $env:TREASURYFLOW_DATA_FILE=Join-Path $isolation 'excel-ssr-probe-only.sqlite'
273 $browser=Start-Process -FilePath $installed[0].FullName -PassThru
274 try {
275 $ready=$false
276 for($n=0;$n -lt 90;$n++){
277 try{
278 $health=Invoke-RestMethod -Uri 'http://127.0.0.1:3210/api/ready' -TimeoutSec 2
279 if($health.status -eq 'ready' -and $health.bankAdapter -eq 'disabled'){$ready=$true;break}
280 }catch{}
281 Start-Sleep -Seconds 1
282 }
283 if(!$ready){throw 'INSTALLED_EXCEL_SSR_STARTUP_FAILED'}
284 Write-Host 'GATE_PASS_EXCEL_SSR_LOCAL_APP_READY_BANK_DISABLED'
285 $page=Invoke-WebRequest -Uri 'http://127.0.0.1:3210/excel-preview' -TimeoutSec 20 -UseBasicParsing
286 Write-Host ('QA_EXCEL_ROUTE_HTTP_STATUS='+[int]$page.StatusCode)
287 $hasInput=$page.Content.Contains('xlsx-preview-upload')
288 Write-Host ('QA_EXCEL_ROUTE_SSR_HAS_FILE_INPUT='+[bool]$hasInput)
289 if($page.StatusCode -ne 200 -or !$hasInput){throw 'INSTALLED_EXCEL_SSR_ROUTE_INPUT_MISSING'}
290 Write-Host 'GATE_PASS_SAME_ARTIFACT_EXCEL_SSR_FILE_INPUT'
291 $integrationResponse=Invoke-WebRequest -Uri 'http://127.0.0.1:3210/integrations/sql-lab' -TimeoutSec 15 -UseBasicParsing
292 if($integrationResponse.StatusCode -ne 200 -or !$integrationResponse.Content.Contains('sql-lab-inactive') -or
293 $integrationResponse.Content.Contains('sql-lab-readonly')){throw 'UNAUTHORIZED_SQL_LAB_PREVIEW_NOT_DISABLED'}
294 Write-Host 'GATE_PASS_INSTALLED_SQL_LAB_UI_DISABLED_WITHOUT_EXPLICIT_FLAGS'
295 $integrationRoot=Invoke-WebRequest -Uri 'http://127.0.0.1:3210/integrations' -TimeoutSec 15 -UseBasicParsing
296 if($integrationRoot.StatusCode -ne 200 -or !$integrationRoot.Content.Contains('href="/integrations/sql-lab"')){
297 throw 'INTEGRATIONS_NAV_MISSING_READONLY_SQL_LAB_LINK'
298 }
299 Write-Host 'GATE_PASS_INSTALLED_INTEGRATIONS_NAV_SQL_LAB_LINK'
300
301
302 }finally{
303 if($browser -and !$browser.HasExited){& taskkill.exe /T /F /PID $browser.Id *> $null}
304 }
305 Write-Host 'GATE_PASS_SAME_ARTIFACT_NATIVE_EXCEL_FILE_PICKER_PREVIEW_ROUNDTRIP'
306 & node --check (Join-Path $work $paths[4])
307 if($LASTEXITCODE -ne 0){throw 'FULL_NATIVE_QA_SYNTAX_FAILED'}
308 $uatIsolation=Join-Path $env:RUNNER_TEMP 'combined-nonfinal-native-persistence'
309 New-Item -ItemType Directory -Path $uatIsolation -Force | Out-Null
310 & node (Join-Path $work $paths[4]) $installed[0].FullName $uatIsolation *> (Join-Path $work 'combined-native-persistence-private.log')
311 $uatReportPath=Join-Path $uatIsolation 'treasuryflow-native-gui.json'
312 if(!(Test-Path -LiteralPath $uatReportPath)){throw 'COMBINED_NATIVE_UAT_REPORT_MISSING'}
313 $uatResult=Get-Content -LiteralPath $uatReportPath -Raw | ConvertFrom-Json
314 if($LASTEXITCODE -ne 0 -or $uatResult.outcome -ne 'REAL_INSTALLED_ELECTRON_GUI_PASS' -or
315 $uatResult.visitedRoutes.Count -ne 10 -or !$uatResult.syntheticAccount -or
316 !$uatResult.syntheticBeneficiary -or !$uatResult.syntheticDraft -or
317 !$uatResult.durableData -or !$uatResult.auditPersisted -or !$uatResult.appReopened){
318 $safeError=[string]$uatResult.errorCode
319 $safeTypes=[ordered]@{
320 WAIT_TIMEOUT='(?:CDP_WAIT_TIMEOUT|CDP_TIMEOUT|TIMEOUT)'
321 CDP_EVALUATION='CDP_EVALUATION_ERROR'
322 CDP_WEBSOCKET='(?:CDP_WS_ERROR|CDP_WS_TIMEOUT|CDP_REMOTE_ERROR)'
323 STALE_SERVER='STALE_LOCAL_SERVER_PRESENT'
324 ELECTRON_EXIT='INSTALLED_ELECTRON_EXITED'
325 NO_LOCAL_ENTRY='NATIVE_LOCAL_ENTRY_MISSING'
326 INVALID_TITLE='NATIVE_.*(?:MISSING|NOT_READY)'
327 }
328 foreach($name in $safeTypes.Keys){Write-Host ('UAT_REDACTED_ERROR_'+$name+'='+[bool]($safeError -match $safeTypes[$name]))}
329 Write-Host ('UAT_BROWSER_CDP_CONNECTED='+[bool]$uatResult.cdp)
330 Write-Host ('UAT_LOGIN_HTTP_STATUS='+[int]$uatResult.loginHttpStatus)
331 Write-Host ('UAT_LOGIN_SSR_HEADING='+[bool]$uatResult.loginSsrHeadingSeen)
332 Write-Host ('UAT_LOGIN_CDP_RECONNECT_ATTEMPTS='+[int]$uatResult.loginCdpReconnectAttempts)
333 Write-Host ('UAT_BROWSER_DISCOVERY_TRANSIENT_COUNT='+[int]$uatResult.cdpTransientDiscoveryFailures)
334 Write-Host ('UAT_CDP_RECONNECTIONS='+[int]$uatResult.cdpReconnections)
335 Write-Host ('UAT_VISITED_ROUTE_COUNT='+[int]@($uatResult.visitedRoutes).Count)
336 throw ('COMBINED_NATIVE_UAT_FAILED_AT_'+([string]$uatResult.stage -replace '[^A-Z0-9_]', ''))
337 }
338 Write-Host 'GATE_PASS_COMBINED_SAME_INSTALLED_EXE_10ROUTES_3_SYNTHETIC_WRITES_RESTART_AUDIT'
339 $uninstall=@(Get-ChildItem -LiteralPath $installDir -Recurse -File -ErrorAction SilentlyContinue |
340 Where-Object {$_.Name -match '^uninstall.*[.]exe$'})
341 if($uninstall.Count -ne 1){throw 'V6_NSIS_UNINSTALLER_NOT_FOUND'}
342 $uninstallProcess=Start-Process -FilePath $uninstall[0].FullName -ArgumentList '/S' -PassThru
343 if(!$uninstallProcess.WaitForExit(90000)){try{$uninstallProcess.Kill()}catch{};throw 'V6_UNINSTALL_TIMEOUT'}
344 if($uninstallProcess.ExitCode -ne 0){throw 'V6_UNINSTALL_NONZERO'}
345 for($i=0;$i -lt 90;$i++){
346 $remaining=@(Get-ChildItem -LiteralPath $installDir -Recurse -File -Filter 'TreasuryFlow.exe' -ErrorAction SilentlyContinue)
347 if($remaining.Count -eq 0){break}
348 Start-Sleep -Seconds 1
349 }
350 if($remaining.Count -gt 0){throw 'V6_UNINSTALL_LEFT_BINARY'}
351 Write-Host 'GATE_PASS_SAME_ARTIFACT_NSIS_UNINSTALL'
352 Write-Host 'V6_NONFINAL_EXCEL_PREVIEW_ROUNDTRIP_PASS_FINANCIAL_IMPORT_NOT_TESTED'
353