2026-07-19 22:06:07 +02:00
|
|
|
BeforeAll {
|
|
|
|
|
function Show-MessageBox { param($Message, $Title, $Button, $Icon, $Owner) 'Yes' }
|
2026-09-10 21:18:43 +05:30
|
|
|
. (Join-Path $PSScriptRoot '..\Scripts\FileIO\Import-JsonFile.ps1')
|
|
|
|
|
. (Join-Path $PSScriptRoot '..\Scripts\FileIO\Import-LanguageFile.ps1')
|
2026-07-19 22:06:07 +02:00
|
|
|
. (Join-Path $PSScriptRoot '..\Scripts\Helpers\Confirm-UnsafeAppRemoval.ps1')
|
2026-09-10 21:18:43 +05:30
|
|
|
$script:LanguagesPath = Join-Path $PSScriptRoot '..\Config\Languages'
|
|
|
|
|
$script:Lang = Import-LanguageFile -LanguageCode 'en-US'
|
2026-07-19 22:06:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Describe 'Confirm-UnsafeAppRemoval' {
|
|
|
|
|
BeforeEach {
|
|
|
|
|
$global:Silent = $false
|
|
|
|
|
Mock Show-MessageBox { 'Yes' }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
AfterEach { Remove-Variable -Name Silent -Scope Global -ErrorAction SilentlyContinue }
|
|
|
|
|
|
|
|
|
|
It 'returns true without prompting for ordinary applications' {
|
|
|
|
|
Confirm-UnsafeAppRemoval -SelectedApps @('Contoso.App') | Should -BeTrue
|
|
|
|
|
Should -Invoke Show-MessageBox -Times 0 -Exactly
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
It 'skips all prompts in silent mode' {
|
|
|
|
|
$global:Silent = $true
|
|
|
|
|
|
|
|
|
|
Confirm-UnsafeAppRemoval -SelectedApps @('Microsoft.WindowsStore', 'Microsoft.WindowsTerminal') | Should -BeTrue
|
|
|
|
|
Should -Invoke Show-MessageBox -Times 0 -Exactly
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
It 'stops when Microsoft Store removal is declined' {
|
|
|
|
|
Mock Show-MessageBox { 'No' }
|
|
|
|
|
|
|
|
|
|
Confirm-UnsafeAppRemoval -SelectedApps @('Microsoft.WindowsStore', 'Microsoft.WindowsTerminal') | Should -BeFalse
|
|
|
|
|
Should -Invoke Show-MessageBox -Times 1 -Exactly
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
It 'requires confirmation for both dangerous applications' {
|
|
|
|
|
Confirm-UnsafeAppRemoval -SelectedApps @('Microsoft.WindowsStore', 'Microsoft.WindowsTerminal') | Should -BeTrue
|
|
|
|
|
Should -Invoke Show-MessageBox -Times 2 -Exactly
|
|
|
|
|
}
|
|
|
|
|
}
|