diff --git a/Tests/Build-Release.Tests.ps1 b/Tests/Build-Release.Tests.ps1 index da8fc97..faab72e 100644 --- a/Tests/Build-Release.Tests.ps1 +++ b/Tests/Build-Release.Tests.ps1 @@ -3,7 +3,7 @@ BeforeAll { $buildScript = Join-Path $repositoryRoot 'Scripts/Build-Release.ps1' $releasePath = Join-Path $TestDrive 'release' $version = '2026.10.22-r2' - $originalScript = [IO.File]::ReadAllBytes((Join-Path $repositoryRoot 'Win11Debloat.ps1')) + $originalScript = [IO.File]::ReadAllText((Join-Path $repositoryRoot 'Win11Debloat.ps1')) Push-Location $TestDrive try { & $buildScript -SourcePath $repositoryRoot -Version $version -OutputDirectory 'release' } finally { Pop-Location } @@ -15,8 +15,8 @@ BeforeAll { Describe 'Release packaging' { It 'stamps only the packaged version and preserves runtime resources' { [IO.File]::ReadAllText((Join-Path $packagePath 'Win11Debloat.ps1')) | Should -Match '\$script:Version = "2026\.10\.22-r2"' - [Convert]::ToBase64String([IO.File]::ReadAllBytes((Join-Path $repositoryRoot 'Win11Debloat.ps1'))) | - Should -BeExactly ([Convert]::ToBase64String($originalScript)) + [IO.File]::ReadAllText((Join-Path $repositoryRoot 'Win11Debloat.ps1')) | + Should -BeExactly $originalScript foreach ($directory in 'Assets', 'Config', 'Regfiles', 'Schemas') { foreach ($file in Get-ChildItem -LiteralPath (Join-Path $repositoryRoot $directory) -File -Recurse) { $relativePath = $file.FullName.Substring($repositoryRoot.Length + 1) diff --git a/Tests/Get-ArchiveHash.Tests.ps1 b/Tests/Get-ArchiveHash.Tests.ps1 index d578f9f..1e20397 100644 --- a/Tests/Get-ArchiveHash.Tests.ps1 +++ b/Tests/Get-ArchiveHash.Tests.ps1 @@ -71,12 +71,6 @@ Describe 'Test-FileHashMatch' { Test-FileHashMatch $script:AbcFile $script:OtherHash | Should -BeFalse } - It 'rejects a file whose content changed' { - $changedFile = Join-Path $TestDrive 'changed.bin' - [System.IO.File]::WriteAllBytes($changedFile, [System.Text.Encoding]::ASCII.GetBytes('abd')) - - Test-FileHashMatch $changedFile $script:AbcHash | Should -BeFalse - } } Describe 'Launcher archive verification flow' { diff --git a/Tests/Invoke-SystemRestorePoint.Tests.ps1 b/Tests/Invoke-SystemRestorePoint.Tests.ps1 index eac190b..aedbe97 100644 --- a/Tests/Invoke-SystemRestorePoint.Tests.ps1 +++ b/Tests/Invoke-SystemRestorePoint.Tests.ps1 @@ -51,13 +51,6 @@ Describe 'Invoke-SystemRestorePoint' { Should -Invoke Read-Host -Times 0 -Exactly } - It 'is loaded by the main entry point' { - $entryPoint = Get-Content -LiteralPath (Join-Path $PSScriptRoot '..\Win11Debloat.ps1') -Raw - $expectedImport = [regex]::Escape('Scripts/Features/Invoke-SystemRestorePoint.ps1') - - $entryPoint | Should -Match $expectedImport - } - It 'enables disabled System Restore before creating the point in silent mode' { $script:Silent = $true Mock Get-ItemProperty { [PSCustomObject]@{ RPSessionInterval = 0 } } diff --git a/Tests/ReleaseWorkflow.Tests.ps1 b/Tests/ReleaseWorkflow.Tests.ps1 index cb947f0..50be6ea 100644 --- a/Tests/ReleaseWorkflow.Tests.ps1 +++ b/Tests/ReleaseWorkflow.Tests.ps1 @@ -7,6 +7,49 @@ BeforeAll { }) } +Describe 'Release workflow version validation' { + BeforeEach { + $locationPushed = $false + $originalTag = $env:RELEASE_TAG + $checkoutPath = Join-Path $TestDrive ([guid]::NewGuid().ToString('N')) + New-Item -ItemType Directory -Path $checkoutPath -Force | Out-Null + $scriptPath = Join-Path $checkoutPath 'Win11Debloat.ps1' + $originalSource = '$script:Version = "2026.08.24"' + [IO.File]::WriteAllText($scriptPath, $originalSource) + # Version validation needs no repository or external authentication. + function git {} + function gh {} + Mock git { $global:LASTEXITCODE = 0 } + Mock gh { $global:LASTEXITCODE = 0 } + Push-Location $checkoutPath + $locationPushed = $true + } + + AfterEach { + if ($locationPushed) { Pop-Location } + $env:RELEASE_TAG = $originalTag + } + + It 'rejects invalid release version before changing the source or calling external tools' -ForEach @( + @{ InvalidVersion = '2026.02.30-r2' } + @{ InvalidVersion = '2026.10.23-r0' } + @{ InvalidVersion = '2026.10.23-r' } + @{ InvalidVersion = '2026.10.23-r2-extra' } + ) { + $env:RELEASE_TAG = $InvalidVersion + { & $workflowBlocks[0] } | Should -Throw + [IO.File]::ReadAllText($scriptPath) | Should -BeExactly $originalSource + Should -Invoke git -Times 0 -Exactly + Should -Invoke gh -Times 0 -Exactly + } + + It 'accepts a single-digit revision and updates the source version' { + $env:RELEASE_TAG = '2026.10.23-r2' + & $workflowBlocks[0] + [IO.File]::ReadAllText($scriptPath) | Should -BeExactly '$script:Version = "2026.10.23-r2"' + } +} + Describe 'Release workflow version commit' { BeforeEach { $locationPushed = $false @@ -94,7 +137,6 @@ if ($text -notmatch [regex]::Escape($env:RELEASE_TAG)) { throw 'Tests did not se It 'commits and packages release version from the same tagged commit' -ForEach @( @{ ReleaseVersion = '2026.10.23' } - @{ ReleaseVersion = '2026.10.23-r2' } @{ ReleaseVersion = '2026.10.23-r10' } ) { $env:RELEASE_TAG = $ReleaseVersion @@ -115,17 +157,6 @@ if ($text -notmatch [regex]::Escape($env:RELEASE_TAG)) { throw 'Tests did not se Should -Match $versionPattern } - It 'rejects invalid release version before changing the source' -ForEach @( - @{ InvalidVersion = '2026.02.30-r2' } - @{ InvalidVersion = '2026.10.23-r0' } - @{ InvalidVersion = '2026.10.23-r' } - @{ InvalidVersion = '2026.10.23-r2-extra' } - ) { - $env:RELEASE_TAG = $InvalidVersion - { & $workflowBlocks[0] } | Should -Throw - [IO.File]::ReadAllText((Join-Path $checkoutPath 'Win11Debloat.ps1')) | Should -Match '2026\.08\.24' - } - It 'does not commit or push a release when tests fail' { [IO.File]::WriteAllText((Join-Path $checkoutPath 'Scripts/Run-Tests.ps1'), 'exit 1') { foreach ($block in $workflowBlocks) { & $block } } | Should -Throw '*Release tests failed*' diff --git a/Tests/Wait-ForKeyPress.Tests.ps1 b/Tests/Wait-ForKeyPress.Tests.ps1 deleted file mode 100644 index dfe9653..0000000 --- a/Tests/Wait-ForKeyPress.Tests.ps1 +++ /dev/null @@ -1,21 +0,0 @@ -Describe 'Wait-ForKeyPress' { - It 'exits cleanly without prompting when Silent is enabled' { - $scriptPath = Join-Path $PSScriptRoot '..\Scripts\CLI\Wait-ForKeyPress.ps1' - $command = "function Stop-Transcript {}; `$global:Silent = `$true; . '$scriptPath'; Wait-ForKeyPress" - $encodedCommand = [Convert]::ToBase64String([Text.Encoding]::Unicode.GetBytes($command)) - - & powershell.exe -NoProfile -EncodedCommand $encodedCommand - - $LASTEXITCODE | Should -Be 0 - } - - It 'uses the requested exit code' { - $scriptPath = Join-Path $PSScriptRoot '..\Scripts\CLI\Wait-ForKeyPress.ps1' - $command = "function Stop-Transcript {}; `$global:Silent = `$true; . '$scriptPath'; Wait-ForKeyPress -ExitCode 1" - $encodedCommand = [Convert]::ToBase64String([Text.Encoding]::Unicode.GetBytes($command)) - - & powershell.exe -NoProfile -EncodedCommand $encodedCommand - - $LASTEXITCODE | Should -Be 1 - } -} diff --git a/Tests/XamlContracts.Tests.ps1 b/Tests/XamlContracts.Tests.ps1 index cd7aefe..25fc274 100644 --- a/Tests/XamlContracts.Tests.ps1 +++ b/Tests/XamlContracts.Tests.ps1 @@ -100,23 +100,6 @@ Describe 'XAML UI contracts' { $failures | Should -BeNullOrEmpty } - It 'keeps the main window navigation and deployment controls available' { - $mainWindow = Get-Content -LiteralPath (Join-Path $script:SchemaPath 'MainWindow.xaml') -Raw - $requiredNames = @( - 'MainTabControl' - 'HomeTab' - 'DeploymentSettingsTab' - 'DeploymentApplyBtn' - 'UserSelectionCombo' - 'AppSelectionPanel' - 'AppSelectionStatus' - ) - - foreach ($name in $requiredNames) { - $mainWindow | Should -Match ('(?:x:Name|\bName)\s*=\s*"{0}"' -f [regex]::Escape($name)) - } - } - It 'exposes links as keyboard-accessible hyperlinks with automation names' -TestCases @( @{ Schema = 'AboutWindow.xaml'; LinkNames = @('ProjectLink', 'KofiLink') } @{ Schema = 'RestoreBackupWindow.xaml'; LinkNames = @('NonRevertibleWikiLink') }