fix: repair popup install binding, dialog titles, presets switch, radio groups, JSON, tests (#4893)

* fix: repair popup install binding, dialog titles, presets switch, radio groups, JSON, tests

- Invoke-WPFInstall: add param block so the right-click app popup binds
  -PackagesToInstall. It previously dropped the argument into $args and
  installed the whole selected list instead of the clicked app (or warned
  that nothing was selected).
- Replace undefined $AppTitle with "WinUtil" in Install/UnInstall warning
  boxes, matching the XAML window title and sibling dialogs.
- tweaks.json: remove stray nested "link" inside the WPFToggleScrollbars
  registry entry (dead property; registry entries expose only the six
  consumed fields).
- Invoke-WPFPresets: fix dead switch cases to the wildcard-pattern
  convention so selectedFeatures/selectedToggles clear correctly.
- Invoke-WPFUIElements: store the group StackPanel in radioButtonGroups so
  grouped radio buttons share one container (else branch was unreachable).
- sanity.Tests.ps1: pass the Windows PowerShell parser script via
  -EncodedCommand; -Command string marshaling corrupted backticks/quotes and
  produced false parse failures.
- install-workflow.Tests.ps1: remove the AppTitle workaround and update
  title assertions to "WinUtil"; drop orphaned cleanup lines.
- Add CHANGES.md with technical and plain-language explanations.

Verified: each bug reproduced against HEAD, fixes demonstrated to change
behavior, full Pester suite 471/471.

* Delete

* test: cover the explicit popup install parameter path

Add a regression test invoking Invoke-WPFInstall -PackagesToInstall with a
package different from the default sync.selectedApps selection and assert
the runspace receives the explicit object, mirroring the Initialize-WPFUI
popup call shape. Existing default-path coverage is unchanged.
This commit is contained in:
Mohammad Faiz
2026-08-03 12:03:03 -05:00
committed by GitHub
parent f3cf1587e0
commit f7361fdb72
7 changed files with 35 additions and 20 deletions
+21 -9
View File
@@ -66,7 +66,6 @@ BeforeAll {
$selectedApps.Add($key)
}
$script:AppTitle = "Winutil"
$script:sync = [Hashtable]::Synchronized(@{
ProcessRunning = $ProcessRunning
selectedApps = $selectedApps
@@ -122,7 +121,6 @@ Describe "Invoke-WPFInstall entrypoint" {
AfterEach {
Remove-Variable -Name sync -Scope Script -ErrorAction SilentlyContinue
Remove-Variable -Name AppTitle -Scope Script -ErrorAction SilentlyContinue
Remove-Variable -Name capturedInstallScriptBlock -Scope Script -ErrorAction SilentlyContinue
Remove-Variable -Name capturedInstallParameterList -Scope Script -ErrorAction SilentlyContinue
}
@@ -146,6 +144,23 @@ Describe "Invoke-WPFInstall entrypoint" {
}
}
It "queues the explicit app popup package over the selected apps" {
$explicitPackage = New-WinUtilPackage -Name "VLC" -Winget "VideoLAN.VLC" -Choco "vlc"
Invoke-WPFInstall -PackagesToInstall $explicitPackage
Should -Invoke -CommandName Invoke-WPFRunspace -Times 1 -Exactly -ParameterFilter {
$ScriptBlock -is [scriptblock] -and
$ParameterList.Count -eq 2 -and
$ParameterList[0][0] -eq "PackagesToInstall" -and
@($ParameterList[0][1]).Count -eq 1 -and
@($ParameterList[0][1])[0].winget -eq "VideoLAN.VLC" -and
$ParameterList[1][0] -eq "ManagerPreference" -and
$ParameterList[1][1] -eq "Winget"
}
Should -Invoke -CommandName Show-WinUtilMessage -Times 0 -Exactly
}
It "prompts and exits when no packages are selected" {
New-WinUtilInstallTestContext
@@ -153,7 +168,7 @@ Describe "Invoke-WPFInstall entrypoint" {
Should -Invoke -CommandName Show-WinUtilMessage -Times 1 -Exactly -ParameterFilter {
$Message -eq "Please select the program(s) to install or upgrade." -and
$Title -eq "Winutil" -and
$Title -eq "WinUtil" -and
$Button -eq "OK" -and
$Icon -eq "Warning"
}
@@ -167,7 +182,7 @@ Describe "Invoke-WPFInstall entrypoint" {
Should -Invoke -CommandName Show-WinUtilMessage -Times 1 -Exactly -ParameterFilter {
$Message -eq "[Invoke-WPFInstall] An Install process is currently running." -and
$Title -eq "Winutil" -and
$Title -eq "WinUtil" -and
$Button -eq "OK" -and
$Icon -eq "Warning"
}
@@ -201,7 +216,6 @@ Describe "Invoke-WPFInstall runspace body" {
AfterEach {
Remove-Variable -Name sync -Scope Script -ErrorAction SilentlyContinue
Remove-Variable -Name AppTitle -Scope Script -ErrorAction SilentlyContinue
Remove-Variable -Name capturedInstallScriptBlock -Scope Script -ErrorAction SilentlyContinue
}
@@ -289,7 +303,6 @@ Describe "Invoke-WPFUnInstall entrypoint" {
AfterEach {
Remove-Variable -Name sync -Scope Script -ErrorAction SilentlyContinue
Remove-Variable -Name AppTitle -Scope Script -ErrorAction SilentlyContinue
Remove-Variable -Name capturedUninstallScriptBlock -Scope Script -ErrorAction SilentlyContinue
Remove-Variable -Name capturedUninstallParameterList -Scope Script -ErrorAction SilentlyContinue
}
@@ -324,7 +337,7 @@ Describe "Invoke-WPFUnInstall entrypoint" {
Should -Invoke -CommandName Show-WinUtilMessage -Times 1 -Exactly -ParameterFilter {
$Message -eq "Please select the program(s) to uninstall" -and
$Title -eq "Winutil" -and
$Title -eq "WinUtil" -and
$Button -eq "OK" -and
$Icon -eq "Warning"
}
@@ -338,7 +351,7 @@ Describe "Invoke-WPFUnInstall entrypoint" {
Should -Invoke -CommandName Show-WinUtilMessage -Times 1 -Exactly -ParameterFilter {
$Message -eq "[Invoke-WPFUnInstall] Install process is currently running" -and
$Title -eq "Winutil" -and
$Title -eq "WinUtil" -and
$Button -eq "OK" -and
$Icon -eq "Warning"
}
@@ -379,7 +392,6 @@ Describe "Invoke-WPFUnInstall runspace body" {
AfterEach {
Remove-Variable -Name sync -Scope Script -ErrorAction SilentlyContinue
Remove-Variable -Name AppTitle -Scope Script -ErrorAction SilentlyContinue
Remove-Variable -Name capturedUninstallScriptBlock -Scope Script -ErrorAction SilentlyContinue
}
+2 -1
View File
@@ -53,7 +53,8 @@ if ($failed.Count -gt 0) {
}
'@
$output = & $windowsPowerShell.Source -NoProfile -NonInteractive -ExecutionPolicy Bypass -Command $parseScript 2>&1
$encodedCommand = [Convert]::ToBase64String([System.Text.Encoding]::Unicode.GetBytes($parseScript))
$output = & $windowsPowerShell.Source -NoProfile -NonInteractive -ExecutionPolicy Bypass -EncodedCommand $encodedCommand 2>&1
if ($LASTEXITCODE -ne 0) {
throw "Windows PowerShell parser failed:`n$($output | Out-String)"
}