Fix legacy json import compatibility, UI sidebar refactor, and improved test coverage (#4911)

* Fix backward compatibility for old-style JSON config imports

* Refactor sidebar UI generation and add tests for Get-WinUtilVariables

* Fix appnavigation config test following UI generation refactor

* Restore global sync state in variables tests

* fix(impex): migrate supported legacy selections

Keep modern imports strict while allowing legacy backups to skip retired entries with clear logging and user feedback. Add fixtures covering partial and all-retired imports.

* test: strengthen UI and global state coverage

Exercise app category rendering through Initialize-WPFUI and restore global sync without leaking test state.

* fix(impex): ignore legacy metadata fields

Limit legacy selection migration to supported WPF key families so unrelated string metadata does not produce false retired-setting warnings.

* docs: clarify legacy config imports

Distinguish strict modern flat imports from partial legacy object migration, including single-setting export shape and historical groups.

---------

Co-authored-by: Chris Titus <contact@christitus.com>
This commit is contained in:
Nikhil
2026-08-19 17:13:14 -05:00
committed by GitHub
co-authored by Chris Titus
parent 4b2fe55a7a
commit 436773df73
10 changed files with 254 additions and 23 deletions
+28 -6
View File
@@ -8,12 +8,10 @@ BeforeAll {
function Invoke-WPFUIElements {
param($configVariable, [string]$targetGridName, [int]$columncount)
}
function Initialize-WPFUI {
param([string]$TargetGridName)
}
function Invoke-WinUtilISOCheckExistingWork { }
function Reset-WPFCheckBoxes { param([bool]$doToggles) }
. (Join-Path $script:repoRoot "functions\public\Initialize-WPFUI.ps1")
. (Join-Path $script:repoRoot "functions\private\Initialize-WinUtilTabContent.ps1")
}
@@ -41,9 +39,7 @@ Describe "Initialize-WinUtilTabContent" {
Initialize-WinUtilTabContent -TabName "Install"
Initialize-WinUtilTabContent -TabName "Install"
Should -Invoke -CommandName Invoke-WPFUIElements -Times 1 -Exactly -ParameterFilter {
$targetGridName -eq "appscategory" -and $columncount -eq 1
}
Should -Invoke -CommandName Initialize-WPFUI -Times 1 -Exactly -ParameterFilter {
$TargetGridName -eq "appscategory"
}
@@ -105,6 +101,32 @@ Describe "Initialize-WinUtilTabContent" {
}
}
Describe "Initialize-WPFUI" {
BeforeEach {
$script:sync = [Hashtable]::Synchronized(@{
configs = @{
appnavigation = [pscustomobject]@{}
}
})
Mock Invoke-WPFUIElements { throw "App category rendered" }
}
AfterEach {
Remove-Variable -Name sync -Scope Script -ErrorAction SilentlyContinue
}
It "renders app navigation through the app category target" {
{ Initialize-WPFUI -TargetGridName "appscategory" } | Should -Throw "App category rendered"
Should -Invoke -CommandName Invoke-WPFUIElements -Times 1 -Exactly -ParameterFilter {
$configVariable -eq $script:sync.configs.appnavigation -and
$targetGridName -eq "appscategory" -and
$columncount -eq 1
}
}
}
Describe "Startup lazy tab wiring" {
It "builds only install tab content before first paint" {
$mainScript = Get-Content -Path (Join-Path $script:repoRoot "scripts\main.ps1") -Raw