63 lines
2.5 KiB
PowerShell
63 lines
2.5 KiB
PowerShell
param(
|
|
[string]$HelperExe = "runs/win-helper/ISphereWinHelper.exe"
|
|
)
|
|
|
|
$ErrorActionPreference = "Stop"
|
|
$repo = Resolve-Path -LiteralPath (Join-Path $PSScriptRoot "..")
|
|
$scriptPath = Join-Path $repo "scripts\open-offline-chat-window-probe.ps1"
|
|
$helperPath = Join-Path $repo $HelperExe
|
|
|
|
function Assert-True([bool]$Condition, [string]$Message) {
|
|
if (-not $Condition) {
|
|
throw $Message
|
|
}
|
|
}
|
|
|
|
if (-not (Test-Path -LiteralPath $helperPath)) {
|
|
& powershell -NoProfile -ExecutionPolicy Bypass -File (Join-Path $repo "scripts\build-win-helper.ps1") | Out-Host
|
|
if ($LASTEXITCODE -ne 0) {
|
|
throw "build-win-helper.ps1 failed with exit code $LASTEXITCODE"
|
|
}
|
|
}
|
|
|
|
Assert-True (Test-Path -LiteralPath $scriptPath) "missing script: $scriptPath"
|
|
|
|
$output = & powershell -NoProfile -ExecutionPolicy Bypass -File $scriptPath `
|
|
-HelperExe $HelperExe `
|
|
-KeepOpenSeconds 2 `
|
|
-ProbeClick `
|
|
-NoScreenshot
|
|
if ($LASTEXITCODE -ne 0) {
|
|
throw "open-offline-chat-window-probe.ps1 exited with code $LASTEXITCODE. Output: $output"
|
|
}
|
|
|
|
try {
|
|
$result = $output | ConvertFrom-Json
|
|
}
|
|
catch {
|
|
throw "script output was not JSON: $output"
|
|
}
|
|
|
|
Assert-True ([bool]$result.ok) "result.ok must be true"
|
|
Assert-True ([string]$result.window_kind -eq "offline_chat_window_probe") "window_kind mismatch"
|
|
Assert-True ([string]$result.root_automation_id -eq "frmP2PChat") "root automation id must be frmP2PChat"
|
|
Assert-True ([bool]$result.send_editor_found) "rtbSendMessage must be found"
|
|
Assert-True ([bool]$result.send_button_found) "btnSend must be found"
|
|
Assert-True ([bool]$result.file_button_found) "btnSendFile or btnFile must be found"
|
|
Assert-True ([bool]$result.probe_click_marker_found) "probe click marker must be written"
|
|
Assert-True ([bool]$result.probe_clicked_ui) "probe must click the UI button"
|
|
Assert-True ([bool]$result.probe_typed_text) "probe must type into the send editor"
|
|
Assert-True ([bool]$result.probe_marker_text_matches) "probe marker text must match typed text"
|
|
Assert-True (-not [bool]$result.sent_real_message) "probe must not send a real message"
|
|
Assert-True (-not [bool]$result.uploaded_real_file) "probe must not upload a real file"
|
|
|
|
[ordered]@{
|
|
ok = $true
|
|
script = $scriptPath
|
|
hwnd = $result.hwnd
|
|
root_automation_id = $result.root_automation_id
|
|
send_editor_found = $result.send_editor_found
|
|
send_button_found = $result.send_button_found
|
|
probe_click_marker_found = $result.probe_click_marker_found
|
|
} | ConvertTo-Json -Depth 4 -Compress
|