mirror of
https://github.com/Raphire/Win11Debloat.git
synced 2026-11-26 07:26:18 +01:00
fix: update RunOnce command handling to avoid & enforce length limits (#866)
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
BeforeAll {
|
||||
$rebootFeatureLabelsScriptPath = Join-Path $PSScriptRoot '..\Scripts\Helpers\Get-RebootFeatureLabels.ps1'
|
||||
. $rebootFeatureLabelsScriptPath
|
||||
. (Join-Path $PSScriptRoot '..\Scripts\FileIO\Import-JsonFile.ps1')
|
||||
. (Join-Path $PSScriptRoot '..\Scripts\FileIO\Import-LanguageFile.ps1')
|
||||
|
||||
# Builds a $script:Lang fixture whose Features section mirrors $script:Features exactly,
|
||||
@@ -26,6 +27,60 @@ BeforeAll {
|
||||
}
|
||||
}
|
||||
|
||||
Describe 'Get-DeferredAppRemovalLabels' {
|
||||
BeforeEach {
|
||||
$script:AppsListFilePath = Join-Path $PSScriptRoot '..\Config\Apps.json'
|
||||
$script:Lang = Import-LanguageFile -LanguageCode 'en-US' -LanguagesPath (Join-Path $PSScriptRoot '..\Config\Languages')
|
||||
$script:WingetDeferredRemovals = @{}
|
||||
}
|
||||
|
||||
It 'returns one Edge label for <Ids>' -ForEach @(
|
||||
@{ Ids = @('Microsoft.Edge', 'XPFFTQ037JWMHS') }
|
||||
@{ Ids = @('XPFFTQ037JWMHS') }
|
||||
) {
|
||||
foreach ($id in $Ids) { $script:WingetDeferredRemovals[$id] = 'Alice' }
|
||||
|
||||
$labels = @(Get-DeferredAppRemovalLabels)
|
||||
|
||||
$labels | Should -HaveCount 1
|
||||
$labels[0] | Should -BeExactly 'Microsoft Edge'
|
||||
}
|
||||
|
||||
It 'retains other apps and unknown IDs alongside a grouped app' {
|
||||
$script:WingetDeferredRemovals = @{ 'Microsoft.Edge' = 'Alice'; 'XPFFTQ037JWMHS' = 'Alice'; 'Microsoft.OneDrive' = 'Alice'; 'Unknown.App' = 'Alice' }
|
||||
|
||||
$labels = @(Get-DeferredAppRemovalLabels)
|
||||
|
||||
$labels | Should -HaveCount 3
|
||||
$labels | Should -Contain 'Microsoft Edge'
|
||||
$labels | Should -Contain 'Unknown.App'
|
||||
$labels | Should -Contain (Get-Translation -Key 'Microsoft.OneDrive' -Field 'FriendlyName' -Section 'Apps')
|
||||
}
|
||||
|
||||
It 'keeps distinct catalog apps even when their translated names match' {
|
||||
Mock Import-JsonFile {
|
||||
[PSCustomObject]@{ Apps = @(
|
||||
[PSCustomObject]@{ AppId = @('First.App', 'First.Alias') }
|
||||
[PSCustomObject]@{ AppId = 'Second.App' }
|
||||
) }
|
||||
}
|
||||
$script:Lang.Apps = [PSCustomObject]@{
|
||||
'First.App' = [PSCustomObject]@{ FriendlyName = 'Shared name' }
|
||||
'Second.App' = [PSCustomObject]@{ FriendlyName = 'Shared name' }
|
||||
}
|
||||
$script:WingetDeferredRemovals = @{ 'First.App' = 'Alice'; 'First.Alias' = 'Alice'; 'Second.App' = 'Alice' }
|
||||
|
||||
$labels = @(Get-DeferredAppRemovalLabels)
|
||||
|
||||
$labels | Should -HaveCount 2
|
||||
@($labels | Where-Object { $_ -eq 'Shared name' }).Count | Should -Be 2
|
||||
}
|
||||
|
||||
It 'returns no labels without deferred removals' {
|
||||
@(Get-DeferredAppRemovalLabels) | Should -HaveCount 0
|
||||
}
|
||||
}
|
||||
|
||||
Describe 'Get-RebootFeatureLabels' {
|
||||
BeforeEach {
|
||||
$script:Params = @{
|
||||
|
||||
Reference in New Issue
Block a user