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
+6 -6
View File
@@ -43,13 +43,13 @@ BeforeAll {
}
}
Describe 'Legacy tweak categories' {
It 'uses the category Name as CategoryId when building controls without a CategoryId' {
Describe 'Tweak category identifiers' {
It 'uses the defined CategoryId for controls and presets when it differs from Name' {
$script:Lang = Import-LanguageFile -LanguageCode 'en-US'
$feature = $script:Features['DisableTelemetry'] | Select-Object *
$feature.Category = 'Legacy Category'
$legacyCatalog = [PSCustomObject]@{
Categories = @([PSCustomObject]@{ Name = 'Legacy Category'; Icon = '' })
Categories = @([PSCustomObject]@{ Name = 'Legacy Category'; CategoryId = 'PrivacySuggestedContent'; Icon = '' })
Features = @($feature)
}
Mock Import-JsonFile { $legacyCatalog } -ParameterFilter { $filePath -eq $script:FeaturesFilePath }
@@ -59,8 +59,8 @@ Describe 'Legacy tweak categories' {
$controlName = 'Feature_DisableTelemetry_Combo'
$script:UiControlMappings.Count | Should -Be 1
$script:UiControlMappings[$controlName].CategoryId | Should -Be 'Legacy Category'
$map = Get-CategoryTweakPresetMap -Window $window -CategoryId 'Legacy Category'
$script:UiControlMappings[$controlName].CategoryId | Should -Be 'PrivacySuggestedContent'
$map = Get-CategoryTweakPresetMap -Window $window -CategoryId 'PrivacySuggestedContent'
$map.Count | Should -Be 1
$map[$controlName].Control | Should -Be ($window.FindName($controlName))
$map[$controlName].DesiredValue | Should -BeTrue
@@ -175,7 +175,7 @@ Describe 'Language changes on existing controls' {
$disabled.ToolTip.Text | Should -Be (Get-Translation -Key 'TweaksAlreadyAppliedTooltip')
[object]::ReferenceEquals($group.SelectedItem, $selectedItem) | Should -BeTrue
$group.SelectedIndex | Should -Be 2
$selectedItem.Content | Should -Be (Get-GroupValueTranslation -GroupId 'SearchIcon' -FeatureId $script:UiControlMappings['Group_SearchIconCombo'].Values[1].FeatureIds[0] -FallbackLabel 'fallback')
$selectedItem.Content | Should -Be (Get-GroupValueTranslation -GroupId 'SearchIcon' -FeatureId $script:UiControlMappings['Group_SearchIconCombo'].Values[1].FeatureIds[0])
@(Get-PendingTweakActions -Window $window -ShowAppliedTweaksMode $true | ForEach-Object { "$($_.Action):$($_.FeatureId)" } | Sort-Object) | Should -Be $before
$script:FeatureLabelLookup['DisableTelemetry'] | Should -Be $checkbox.Content
foreach ($category in $script:CategoryLanguageControls) {