Refactor feature label handling to utilize language catalogs (#890)

This commit is contained in:
Jeffrey
2026-11-08 17:55:46 +01:00
committed by GitHub
parent cf691cda94
commit e6184a2597
29 changed files with 173 additions and 677 deletions
+9 -1
View File
@@ -35,6 +35,7 @@ BeforeAll {
$entry = @{}
foreach ($field in 'ApplyText', 'UndoLabel', 'ApplyUndoText') {
if ($null -ne $feature.$field) { $entry[$field] = [string]$feature.$field }
$feature.PSObject.Properties.Remove($field)
}
$langFeatures[$featureId] = [PSCustomObject]$entry
}
@@ -112,7 +113,7 @@ Describe 'Invoke-FeatureApply' {
It 'imports a registry-backed feature' {
Invoke-FeatureApply -FeatureId 'RegistryFeature'
Should -Invoke Import-RegistryFile -Times 1 -Exactly -ParameterFilter { $path -eq 'feature.reg' }
Should -Invoke Import-RegistryFile -Times 1 -Exactly -ParameterFilter { $path -eq 'feature.reg' -and $Message -eq '> Apply registry feature...' }
Should -Invoke Remove-SelectedApps -Times 0 -Exactly
}
@@ -352,6 +353,7 @@ Describe 'Invoke-FeatureUndo' {
DisableTelemetry = [PSCustomObject]@{}
DisableStoreSearchSuggestions = [PSCustomObject]@{}
}
Sync-TestLangFeatures
Mock Set-StoreSearchSuggestionsEnabledForAllUsers { $true }
Mock Set-StoreSearchSuggestionsEnabled { $true }
Mock Get-StoreAppsDatabasePathForUser { 'store.db' }
@@ -380,6 +382,12 @@ Describe 'Invoke-FeatureUndo' {
$script:disabledFeatures | Should -Be @('Microsoft-Windows-Subsystem-Linux', 'VirtualMachinePlatform')
}
It 'uses the language catalog for undo messages without display metadata' {
Invoke-FeatureUndo -FeatureId 'EnableWindowsSandbox' | Should -BeTrue
Should -Invoke Write-Host -Times 1 -Exactly -ParameterFilter { $Object -eq '> Disable Sandbox...' }
}
It 'disables Sandbox and re-enables telemetry tasks' {
$script:Features.DisableTelemetry = [PSCustomObject]@{ ApplyUndoText = 'Enable telemetry'; RegistryUndoKey = 'enable-telemetry.reg' }
Invoke-FeatureUndo -FeatureId 'EnableWindowsSandbox'